【发布时间】:2020-09-12 13:52:44
【问题描述】:
我遇到了我的机器人无法响应命令的问题。这是我的代码:
import os
import discord
from discord.ext import commands
from discord.ext.commands import Bot
import random
client = discord.Client()
bot = commands.Bot(command_prefix='!')
@client.event #server + member list
async def on_ready():
guild = discord.utils.get(client.guilds, name=GUILD)
print(
f'{client.user} is connected to the following guild:\n'
f'{guild.name}(id: {guild.id})\n'
)
members = '\n - '.join([member.name for member in guild.members])
print(f'Guild Members:\n - {members}')
@bot.command()
async def test(ctx, arg):
await ctx.send(arg)
client.run(TOKEN)
我在代码中为机器人提供了其他客户端事件,例如对消息做出反应和回复消息。即使在我注释掉了所有其他 cmets 之后,我上面的代码也没有工作。在运行程序时,我在我的不和谐频道中输入了 !test arg,但只有在没有被注释掉时才从我的机器人那里得到编程的反应。
【问题讨论】:
标签: python discord discord.py