【发布时间】:2019-12-12 02:28:11
【问题描述】:
当我通过 DM 向我的不和谐机器人提供命令“!say”时,我正在尝试让我的不和谐机器人向我的服务器中的频道发送消息。
我尝试了很多不同的代码,但通常以属性错误“X 对象没有属性 Y”结束
from discord.ext import commands
bot = commands.Bot(command_prefix='!')
@bot.command()
async def say(ctx):
channel = bot.get_channel('584307345065246725')
await channel.send(ctx)
当我 DM 机器人时,总是会出现错误消息,期待它发送所需的消息。
【问题讨论】:
-
您传递给
get_channel的id 应该是一个int,而不是一个字符串。此外,ctx将是一个调用上下文对象,它不能用作消息的内容。您到底想发送什么?
标签: discord.py