W
W
wetwixs2020-08-21 12:34:56
Python
wetwixs, 2020-08-21 12:34:56

How to make event work on one server?

Good afternoon. Suppose I have such an event

@client.event
async def on_message_delete(message):
    channel = client.get_channel(703596630892478506)
    if message.content is None:
        return;
    embed = discord.Embed(color = random.choice(colors), description=f"{message.author.mention} `Удалил сообщение в канале` {message.channel.mention} \n \n**Удаленное сообщение** - {message.content}",timestamp=message.created_at)

    embed.set_author(name=f"{message.author}", icon_url=f'{message.author.avatar_url}')
    embed.set_footer(text=f'ID Пользователя: {message.author.id} | ID Сообщения: {message.id}')
    await channel.send(embed=embed)
    return


But I also have a bot on 8 servers, so all remote messages go there, so the question is how to make it log a message only on a specific server. Suppose how to do this with a command, I know it is if ctx.guild.id == ID: , but what about event?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2020-08-21
@wetwixs

so you want to make the command universal for all servers, did I understand correctly?
what for to you then a line ? remove it and replace it withchannel = client.get_channel(703596630892478506)
await channel.send(embed=embed)await nessage.channel.send(embed=embed)

M
Maxim Nevzorov, 2020-08-21
@fixator10

Get the server from the message object: discord.Message.guild

if message.guild.id != 282480459897027773:
    return

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question