所以我在discord.py 上遇到了問題。我想發出命令來踢/禁止人們。我一開始嘗試了這個,但沒有成功,所以我去檢查命令是否對我有用。顯然事實并非如此。我已經嘗試了一切,但沒有任何效果。import discordfrom discord.ext import commandsclient = discord.Client()bot = commands.Bot(command_prefix='!')Token = 'TOKEN'@bot.command(pass_context=True)async def test(ctx): await ctx.send('test')client.run(Token)我在頻道上輸入 !test 但沒有任何反應。我基本上已經嘗試了一切。我改變了前綴,done:,@bot.command(name='test)基本上你能想到的一切。什么都不起作用。我想知道我是否遺漏了一些重要的東西。就像我必須先下載一些東西,還是我在代碼中遺漏了一些東西,或者我需要啟用哪些權限。我已經查看了discord py API 參考資料。任何事情都會有幫助謝謝。
1 回答

守著一只汪
TA貢獻1872條經驗 獲得超4個贊
你的問題是因為bot = commands.Bot(). 您可以使用以下代碼代替:
import discord
from discord.ext import commands
client = commands.Bot(command_prefix="!")
@client.command()
async def test(ctx):
await ctx.send('test')
client.run(token)
所以你只需刪除bot = commands.Bot()然后替換@bot.command()為@client.command.
添加回答
舉報
0/150
提交
取消