使用discordpython报告命令

使用discordpython报告命令,python,discord.py,Python,Discord.py,我正在尝试创建一个报告命令,将消息发送到通道。比如*报告用户名#1234推理放在这里等等 通道由{author}出于{reason}报告的{user}接收它。 一条私人信息被发送给作者,告诉他们报告已经通过 但是,如果报告的用户具有“kick”权限,则其也会被发送到第二个通道。 还有一条私人信息发给我主人。结构与{author}出于{reason}报告的{user}相同 但是。。。我不断地遇到一些奇怪的错误,比如没有定义的机器人(即使已经定义) 您需要使用户参数如下所示:user:discord

我正在尝试创建一个报告命令,将消息发送到通道。比如*报告用户名#1234推理放在这里等等

通道由{author}出于{reason}报告的{user}接收它。 一条私人信息被发送给作者,告诉他们报告已经通过

但是,如果报告的用户具有“kick”权限,则其也会被发送到第二个通道。 还有一条私人信息发给我主人。结构与{author}出于{reason}报告的{user}相同

但是。。。我不断地遇到一些奇怪的错误,比如没有定义的机器人(即使已经定义)


您需要使用户参数如下所示:
user:discord.Members
以及在用户之后获取所有输入的原因参数。我不确定拥有一个记录器和一个通道有什么意义

async def report(self, ctx, user : discord.Member, *reason)
    channel = self.bot.get_channel(your channel id) #since it's a cog u need self.bot
    author = ctx.message.author
    rearray = ' '.join(reason[:]) #converts reason argument array to string
    if not rearray: #what to do if there is no reason specified
        await channel.send(f"{author} has reported {user}, reason: Not provided")
        await ctx.message.delete() #I would get rid of the command input
    else:
        await channel.send(f"{author} has reported {user}, reason: {rearray}")
        await ctx.message.delete()
额外的 如果您想为使用kick perms的人创建一个特殊报告,它将类似于If语句的Permissions.kick_成员。您可以在api中轻松找到它

下一次做更多的研究,但如果你需要什么,只需评论:)

async def report(self, ctx, user : discord.Member, *reason)
    channel = self.bot.get_channel(your channel id) #since it's a cog u need self.bot
    author = ctx.message.author
    rearray = ' '.join(reason[:]) #converts reason argument array to string
    if not rearray: #what to do if there is no reason specified
        await channel.send(f"{author} has reported {user}, reason: Not provided")
        await ctx.message.delete() #I would get rid of the command input
    else:
        await channel.send(f"{author} has reported {user}, reason: {rearray}")
        await ctx.message.delete()