[英]Discord bot doesnt respond
這是我第一次制作 discord 機器人。 我已經按照教程的每個步驟進行操作,但我的機器人對 .test 命令沒有反應。 我確實在 discord 服務器中看到了該機器人。 請幫忙
這是我第一次制作 discord 機器人。 我已經按照教程的每個步驟進行操作,但我的機器人對 .test 命令沒有反應。 我確實在 discord 服務器中看到了該機器人。 請幫忙
首先,在第 15 行, if(message.content.startswith(:test):
的 if 語句位於返回之后。機器人永遠不會到達這些行。您將不得不將縮進移回(python 中的縮進很煩人)。
if message.author == client.user:
return
if message.content.startswith('!test'):
await message.channel.send("Hello!")
await client.process_commands(message)
其次, await client.process_commands(message)
僅適用於命令客戶端,不適用於基礎 discord.Client()。 客戶必須是類似的東西
from discord.ext import commands
client = commands.Bot(command_prefix="!")
請參閱Bot 和 Client 之間有什么區別? 對於 discord.Client() 和 commands.Bot() 之間的區別。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.