C
C
Cos22020-10-01 18:44:02
Python
Cos2, 2020-10-01 18:44:02

How to make a bot greet a new player in a specific Discord.py channel?

Well, everything is clear here. I want to make a hello channel

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
KeySh1e, 2020-10-02
@Cos2

Of course, it’s a shame not to know this, there is an API and Google, but still keep it

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix = '!')
guild_welcome = {727877261159694496} #Тут ID канала, в которые приходит сообщение и приветствие

@bot.event
async def on_ready():
    print("Ready!")

@bot.event
async def on_member_join(member):
    welcome = bot.get_channel(guild_welcome[member.guild.id]) #Получение канала для приветствия
    embed=discord.Embed(title="Добро пожаловать!", description=f"К нам в {member.guild.name} приехал {member.mention}!", color=0xCC974F) #Embed
    await welcome.send(embed=embed) #Отправка сообщения

Pay attention to tabs!

5f76447a9e6af985164346.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question