繁体   English   中英

有没有办法接收其他用户对我的建议,所以在 discord.py

[英]Is there a way to receive suggestions by other users to me so in discord.py

我正在 discord.py 中制作一个机器人。 我希望用户在他们的服务器本身中提出建议,并且这些建议会传达给我。 我不知道这是否可能以及这怎么可能。 请考虑帮助我。 到目前为止,我只有正常建议命令的代码,它可以完全工作

@client.command()
    async def suggest(self, ctx, *,suggestion):

        
        await ctx.channel.purge(limit = 1)
        channel = discord.utils.get(ctx.guild.text_channels, name = 'suggestions')

        suggestEmbed = discord.Embed(colour = 0xFF0000)
        suggestEmbed.set_author(name=f'Suggested by {ctx.message.author}', icon_url = f'{ctx.author.avatar_url}')
        suggestEmbed.add_field(name = 'New suggestion!', value = f'{suggestion}')

        message = await ctx.send(embed=suggestEmbed)

        await message.add_reaction('✅')
        await message.add_reaction('❌')

假设您是机器人的所有者。 您可以使用bot.owner_id获取您的 id。

async def suggest(self, ctx, *, suggestion):
     #make embed here
     owner = self.bot.get_user(self.bot.owner_id)
     await owner.send(embed=embed)

如果get_user不起作用

async def suggest(self, ctx, *, suggestion):
     #make embed here
     owner = await self.bot.fetch_user(self.bot.owner_id)
     await owner.send(embed=embed)

如果您不是机器人的所有者,只需在 get_user 中硬编码您的 id

参考:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM