discord python get channel by name code example

Example 1: discord.py find voice channel by name

channel = discord.utils.find(lambda c: c.name == 'some name' and c.type == 'voice', some_list_of_channels)
if channel is not None:
    print(channel.id)

Example 2: discord.py get channel id by channel name

channel_names = ['channel1', 'channel2', 'channel3']
for ch in channel_names:
    channel = discord.get.utils(server.channels, name=ch, type="ChannelType.voice")
    full(channel)

Example 3: discord py fetch channel by id

channel = discord.utils.get(ctx.guild.channels, name=given_name)
channel_id = channel.id

Tags:

Misc Example