Function "say" throws up an AttributeError: 'str' object has no attribute 'channel' error

时间:2019-01-15 18:26:29

标签: python python-3.x discord.py discord.py-rewrite

I'm setting up a new discord bot using the @bot.command() functionality, however, my !say command will not take the user's input and then have the bot say it

@bot.command()
async def say(message):
  #await bot.delete_message(message)
  await bot.send_message(message.channel, message)

This is for a discord server and the bot is to auto admin things for me aswell as provide the discord members functions to use. I've tried:

  • bot.say(message)
  • bot.say(message.channel, message)
  • bot.send_message(messsage)
  • bot.send_message(message.channel, messsage)

The expected result is for the bot to "say" the user's message e.g. with !say Hello the bot would reply with "Hello"

1 个答案:

答案 0 :(得分:0)

例如,您必须使用channel.send()

@bot.command()
async def foo(ctx, arg):
    await ctx.send(arg)

您可以在以下位置查看更多说明的示例:https://discordpy.readthedocs.io/en/rewrite/ext/commands/commands.html