T
T
tatsuki12021-10-15 17:14:19
Python
tatsuki1, 2021-10-15 17:14:19

How to mention the channel in which the message was deleted?

Greetings. I'm writing a logging system in discord.py and I want the bot to mention the channel in which a message was deleted. But when I write - message.channel.mention it doesn't write anything at all. Code below

@commands.Cog.listener()
    async def on_message_delete(self, message):

        delete=discord.Embed(color=0xff0000,title="Удалено сообщение", description = 
        f'Пользователь: {message.author}\n'
        f'Канал: {message.channel.id}\n'
        f'Сообщение: {message.content}'
        )
        delete.set_footer(text =
        f'ID пользователя: `{message.author.id}`'
        )
        logschannel = self.client.get_channel(888878814720061551)
        await logschannel.send(embed = delete)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Telmor, 2021-10-15
@Telmor

@bot.event
async def on_message_delete(message):
    channel = bot.get_channel(885959481186476062)
    emb = discord.Embed(title='Удаление Сообщения!', color=0x7C00FF)
    emb.add_field(name=f'> Содержание Удалёного Сообщения:', value=f'{message.content}')
    emb.add_field(name=f'> Автор:',value=f'{message.author.mention}')
    emb.add_field(name=f'> Канал:',value=f'{message.channel.mention}')
    emb.set_footer(text='Авто-Логирование Сообщений')
    emb.set_thumbnail(url=message.author.avatar_url)
    await channel.send(embed = emb)

My code. True, he is without cogs. I hope it helps you)
(and if not, then mention the channel by id, i.e. <#id> - where id is the channel ID)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question