Answer the question
In order to leave comments, you need to log in
The bot does not write a message when a participant enters (discord bot). What is the problem?
I can't get the bot to PM a member when they log in.
The code
import discord
from discord.ext import commands
from discord.utils import get
TOKEN = "токен"
bot = commands.Bot(command_prefix=('!'))
bot.remove_command( 'help' )
@bot.event
async def on_member_join(member):
member_id = member.id
user = bot.get_user(member_id)
await user.send('privet')
@bot.event
async def on_ready():
print("Я запущен!")
@bot.command()
async def hello(ctx):
embed = discord.Embed(
title="Привет всем!",
)
await ctx.send(embed=embed)
bot.run(TOKEN)
Answer the question
In order to leave comments, you need to log in
1. Do the bots have rights? The participant can prohibit privates not from contacts, for example.
2. Check the intents requested by the bot and allowed in the bot's account settings. Does the bot actually receive the on_member_join event?
In the bot settings , in the Bot item, there should be checkboxes opposite PRESENCE INTENT and SERVER MEMBERS INTENT , after reconnecting the bot to the server ( Delete and re-add )
Also, for the bot test, in the OAuth2 tab in the SCOPES section, select bot , and then in BOT PERMISSIONS select Administrator and reconnect the bot to the server using the link received
. The code itself for work:
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix=('!'), intents=intents)
@bot.event
async def on_member_join(member):
await member.send('Добро пожаловать на сервер!')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question