discord.py dmed时的modmail消息

xriantvc  于 2021-07-14  发布在  Java
关注(0)|答案(0)|浏览(189)

所以,我已经写了这个代码,modmail工作得很好。但我想补充一点。因此,当用户dms这个bot时,会弹出一条消息,比如modmail ticket,请稍候,支持人员正在到达
到目前为止代码是这样的

@commands.Cog.listener()
    async def on_message(self, message):
        if message.author.bot:
            return

        if isinstance(message.channel, discord.DMChannel):
            guild = self.bot.get_guild(803860448104677376)
            categ = utils.get(guild.categories, name = "Support")
            if not categ:
                overwrites = {
                    guild.default_role : discord.PermissionOverwrite(read_messages = False),
                    guild.me : discord.PermissionOverwrite(read_messages = True)
                }
                categ = await guild.create_category(name = "Support", overwrites = overwrites)

            channel = utils.get(categ.channels, topic = str(message.author.id))
            if not channel:
                channel = await categ.create_text_channel(name = f"{message.author.name}#{message.author.discriminator}", topic = str(message.author.id))
                await channel.send(f"@here New modmail created by {message.author.mention}")

            embed = discord.Embed(description = message.content, colour = 0x696969)
            embed.set_author(name = message.author, icon_url = message.author.avatar_url)
            await channel.send(embed = embed)

        elif isinstance(message.channel, discord.TextChannel):
            if message.content.startswith(self.bot.command_prefix):
                pass
            else:
                topic = message.channel.topic
                if topic:
                    member = message.guild.get_member(int(topic))
                    if member:
                        embed = discord.Embed(description = message.content, colour = 0x696969)
                        embed.set_author(name = message.author, icon_url = message.author.avatar_url)
                        await member.send(embed = embed)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题