Refactorisation

This commit is contained in:
attilavs2 2024-02-23 16:56:15 +01:00
parent 7575ed14a4
commit b396269a54

View file

@ -26,6 +26,36 @@ guilds = []
globals()["gmembers"] = {} globals()["gmembers"] = {}
def pinguncon(message):
#fcalva's server
if message.guild.id == 750665878072328242:
await message.channel.send("<@499533339468759052>")
elif message.guild.id in [1008485562304450610, 1157767629738618941]:
await message.channel.send("<@755081785393676328>")
else:
await message.channel.send("pas dispo ici")
def pingrand(message):
choice = random.choice(globals()["gmembers"][str(message.guild.id)])
await message.channel.send("<@"+str(choice.id)+">")
def roulette(message):
roll = random.random()
if roll < 0.16666666666:
tdelt = datetime.timedelta(seconds=5)
try:
await message.author.timeout(tdelt, reason="Petit test")
except:
await message.channel.send("Une erreur s'est produite ! (Je ne peux probablement pas vous timeout)")
else:
await message.channel.send("Ouf ! Il n'y avait pas de cartouche dans la chambre...")
def ecohelp():
await message.channel.send("Eco+, un bot Eco plus pour faire des conneries\n"\
"?pinguncon : ping le con local\n"\
"?pingrand : ping un membre aléatoire du serveur\n"
"?roulette : Prennez une chance sur six de vous faire timeout")
@client.event @client.event
async def on_ready(): async def on_ready():
print(f'We have logged in as {client.user}') print(f'We have logged in as {client.user}')
@ -49,31 +79,12 @@ async def on_message(message):
await message.channel.send('henlo') await message.channel.send('henlo')
return return
if content == "?pinguncon": if content == "?pinguncon":
#fcalva's server pinguncon(message)
if message.guild.id == 750665878072328242:
await message.channel.send("<@499533339468759052>")
elif message.guild.id in [1008485562304450610, 1157767629738618941]:
await message.channel.send("<@755081785393676328>")
else:
await message.channel.send("pas dispo ici")
if content == "?pingrand": if content == "?pingrand":
choice = random.choice(globals()["gmembers"][str(message.guild.id)]) pingrand(message)
await message.channel.send("<@"+str(choice.id)+">")
if content == "?roulette": if content == "?roulette":
roll = random.random() roulette(message)
if roll < 0.16666666666:
tdelt = datetime.timedelta(seconds=5)
try:
await message.author.timeout(tdelt, reason="Petit test")
except:
await message.channel.send("Une erreur s'est produite ! (Je ne peux probablement pas vous timeout)")
else:
await message.channel.send("Ouf ! Il n'y avait pas de cartouche dans la chambre...")
if content == "?help": if content == "?help":
await message.channel.send("Eco+, un bot Eco plus pour faire des conneries\n"\ ecohelp(message)
"?pinguncon : ping le con local\n"\
"?pingrand : ping un membre aléatoire du serveur\n"
"?roulette : Prennez une chance sur six de vous faire timeout")
client.run(token) client.run(token)