added old bot.py
This commit is contained in:
parent
31a4098476
commit
7e83820ed0
33
bot.py
33
bot.py
@ -1,33 +0,0 @@
|
||||
import discord
|
||||
from discord.ext import tasks
|
||||
import os
|
||||
import asyncio
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from dotenv import load_dotenv
|
||||
|
||||
intents = discord.Intents.default()
|
||||
intents.members = True
|
||||
intents.presences = True
|
||||
client = discord.Client(intents=intents)
|
||||
|
||||
@client.event
|
||||
async def on_ready():
|
||||
print('Logged in as {0.user}'.format(client))
|
||||
check_active.start()
|
||||
|
||||
|
||||
@tasks.loop(seconds = 20) # repeat after every 20 seconds
|
||||
async def check_active():
|
||||
await client.wait_until_ready()
|
||||
for member in client.get_all_members():
|
||||
# Vérifie si le membre est actif sur Discord depuis 20 minutes ou plus
|
||||
if member.name == "Anselme" and member.status != discord.Status.offline and member.activity is not None and (datetime.now(timezone.utc) - member.activity.created_at) > timedelta(minutes=20):
|
||||
try:
|
||||
# Envoie un message privé de rappel
|
||||
await member.send("Il est temps d'arrêter de procrastiner !")
|
||||
except:
|
||||
pass
|
||||
|
||||
load_dotenv()
|
||||
token = os.getenv('DISCORD_TOKEN', "NO_TOKEN")
|
||||
client.run(token)
|
Loading…
x
Reference in New Issue
Block a user