Wafaduck
Wafaduck

Reputation: 25

discord.py How do I let my bot send a message to different channels with different names

So this is currently my code. You can see that I tried to add one more channel but it doesnt seem to work it that way.

@commands.has_permissions(kick_members=True)
async def alert(ctx, *, msg): #COMMAND NAME
    for guild in client.guilds:
        role = get(guild.roles, name = 'Wafaduck Alerts') # roles
        for channel in guild.channels:
            if(channel.name == '👑│🐤wafaduck-alerts', 'wafaduck-alerts'):
                await channel.send(f"{role.mention}")```

Upvotes: 1

Views: 123

Answers (1)

stijndcl
stijndcl

Reputation: 5647

Use the in operator with a list/tuple of possible names to see if the name is one of those.

if channel.name in ('👑│🐤wafaduck-alerts', 'wafaduck-alerts')

Upvotes: 1

Related Questions