0
votes

I've got a pretty decent bot that I'm planning to launch soon. It's called moderator and it's supposed to be the perfect moderator bot so that a server won't need actual moderators anymore. So I want it to send a welcome message when it joins the server, but because all servers have different channel names and channels, I can't get a generic channel name to send the welcome message too.

channel = find(lambda x: x.name == 'general', guild.text_channels)
if channel and channel.permissions_for(guild.me).send_messages:
    await channel.send(embed=embedvar)

This is what I have right now and as you can see it finds a channel named general and sends the welcome embed message to the general channel. But since not every server has a general channel, I want to have the bot find the 1st channel where it has permission to send messages. Is there a way to do that? Thanks!

1

1 Answers

0
votes

You can get the first channel of the guild with this way: channel = client.get_guild(guild id).text_channels[0] So with this code, you can do something like that:

@client.event
async def on_guild_join(guild):
    channel = guild.text_channels[0]
    embed = discord.Embed(title=guild.name, description="Hello, I'm here")
    await channel.send(embed=embed)