Answer the question
In order to leave comments, you need to log in
How to check which server a user is logged into via discord.py?
I have a bot on several servers and I decided to make a function for each server in the bot. The essence of the function: The administrator specifies how much time must pass from the moment the user registers an account before he can enter the server (otherwise he will be kicked). And so not only on the 1st server, but on several. I know how to make this check on the 1st server. But how to do it for multiple servers? Sample code as I did for 1 server:
@bot.event
async def on_member_join(member):
if time.time() - member.created_at.timestamp() < 259200:
emb = discord.Embed(title='Ошибка', description=f'{member.mention}, Ваш аккаунт был создан недавно. Повторите попытку позже.')
emb.set_footer(text=f'Дата регистрации вашего аккаунта меньше 3-х дней назад.)
emb.set_thumbnail(url=member.avatar_url)
await member.send(embed=emb)
reason = "Новый аккаунт < 3 дней"
await member.kick(reason=reason)
else:
...
Answer the question
In order to leave comments, you need to log in
Well, what's the problem? Have a separate setting for each server?
DB to help, you make a table like "server id - term", when a user logs in, you make a selection from it by server id. If nothing is found, use the default time (I would default to 0 so that the function only works if the admin configured it).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question