所以我现在在discord.py中,每当我直接编辑bot.py(我的主文件)时,我都可以实现我的uggest命令的版本。
@bot.command(name = 'suggest', help = 'Use this command to give a suggestion to the server')
async def suggest(ctx, content):
channel = discord.utils.get(bot.guilds[0].channels, name = 'suggestions')
print('Suggest command triggered, content is {}'.format(content))
await channel.send(content)
^机器人只是我的客户端版本
这工作得很好(除了我只得到内容第一个单词的事实,所以如果有人能够解决这个问题,那也很好
但是当我将粘贴复制到我的齿轮中
@commands.command(name = 'suggest', help = 'Use this command to give a suggestion to the server')
async def suggest(self, bot, ctx, content):
print('Suggest command triggered')
channel = discord.utils.get(bot.guilds[0].channels, name = 'suggestions')
print('Content is {}'.format(content))
await channel.send(content)
它无效,有人可以帮我吗?
答案 0 :(得分:0)
对于齿轮来说,bot
参数是不必要的,因此您只需输入
@commands.command(name = 'suggest', help = 'Use this command to give a suggestion to the server')
async def suggest(self, ctx, content):
print('Suggest command triggered')
channel = discord.utils.get(bot.guilds[0].channels, name = 'suggestions')
print('Content is {}'.format(content))
await channel.send(content)
对于仅有的第一个单词,discord.py通过单词分隔参数,因此您可以像这样将它们全部用*
分组:
async def suggest(self, ctx, *content): # gets all the words in a tuple