L
L
lekasnet2021-03-26 19:32:08
Python
lekasnet, 2021-03-26 19:32:08

DISCORD.py how to get channel id by its name? or another way to send a message to a channel?

I want to make the bot, when connected, be able to manually configure which channels it will write messages to.
For example, registration confirmations, he will read and write only from registration, but how to make it possible to write him

!permission register-main_channel
, i.e. how to get the channel id knowing the name? Or is it possible to access the channel knowing only the name? for example, is it possible to replace id with name in the following case?
@bot.event
async def on_member_join(member):
    channel = bot.get_channel(8152*******905) #здесь числовой id, можно ли заменить на название?

    await channel.send(embed=discord.Embed(
        description=f"{member.name}, приветствуем!"))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-03-26
@lekasnet

channel = discord.utils.get(member.guild.channels, name="Имя")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question