我有一個使用 Discord.py 的預制代碼并使用 Heroku 托管,它目前在線,除了每當我使用命令時,它什么都不回傳,但是當使用Notepad 命令在本地運行它時作業得很好。
主檔案
import discord
from discord.ext import commands
token = 'OBVIOUSLY THE TOKEN IS HERE'
prefix = "?"
intents = discord.Intents.default() # or .all() if you ticked all, that is easier
intents.members = True # If you ticked the SERVER MEMBERS INTENT
bot = commands.Bot(command_prefix=prefix, intents=intents) # "Import" the intents
@bot.event
async def on_ready():
print('Internal has connected to Discord!')
await bot.change_presence(activity=discord.Game(name="Discord"))
@bot.command()
async def ping(ctx):
await ctx.send(f'Pong! In {round(bot.latency * 1000)}ms')
@bot.command()
async def about(ctx):
embed = discord.Embed(title='About me!', description=f'Im an Utility bot, that is coded under discord.py\n\n> Statistics\nLatency: `{round(bot.latency * 1000)}`ms', color=0xEE8700)
await ctx.send(embed=embed)
@bot.command()
async def say(ctx, *, content:str):
await ctx.send(content)
bot.run(token)
版本:
python= 3.8.8
discord.py= 1.7.3
uj5u.com熱心網友回復:
(添加這個作為答案,因為我認為其他人會遇到這個問題)
在 discord.py 版本 1.7.3 中,查看訊息內容所需的訊息意圖默認設定為啟用。但是,在 2.x 中,您需要單獨設定它。
您可以通過以下方式解決問題:
- 強制 discord.py 版本回到 1.7.3 in
requirements.txt; 或者 - 通過做明確地啟用意圖
intents.message_content = True。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/467614.html
上一篇:將“初學者的Django”應用程式部署到Heroku失敗并出現ModuleNotFoundError:沒有名為“_tkinter”的模塊
