我正在尝试创建一个将消息发送到通道的报告命令。例如* report username#1234推理放在这里等等等
频道由{作者}报告的{用户}收到{原因}。 并向作者发送了一条私人消息,告诉他们报告通过了。
但是,如果所报告的用户具有“踢”权限,则其也会发送到第二个频道。 并私下发送给我所有者的消息。与{作者}为{原因}报告的{用户}的结构相同。
但是...我不断收到一些奇怪的错误,例如未定义的bot(即使已定义)。
async def report(self, ctx, user, *, reason=None):
logger = bot.get_channel(644966241835941898)
channel = bot.get_channel(641639710183129113)
if reason is None:
await ctx.author.send('Hey I get that you are trying to report someone but I need a reason. Please try again.')
elif ctx.message.author.guild_permissions.read_messages:
await ctx.channel.send(f'{user} reported by {author} for {reason}')
elif user.guild_permissions.kick_members:
await ctx.logger.send(f'{user}, reported by {author} for {reason}')
await ctx.channel.send(author, user, reason)
await ctx.author.send("""Im going to put this in a safe spot for the wizard himself to review.""")```
答案 0 :(得分:0)
您需要使用户参数看起来像这样: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()
如果您想为有踢烫的人提供一份特殊报告,则if语句将类似于Permissions.kick_members。您可以在api中轻松找到它。
下次再做更多研究,但是如果您需要任何东西,请发表评论:)