print("Lancement du bot de la licence") import discord from discord.ext import commands from setup import token # on décide du prefix # on dit d'ignorer les majuscules/minuscules quand on tape une commande # plus d'infos sur l'intent ici : https://discordpy.readthedocs.io/en/latest/intents.html (j'ai pas encore tout compris c'est nouveau) client = commands.Bot(command_prefix = ".", case_insensitive = True, intents = discord.Intents.all()) @client.event async def on_connect(): print("Connecté.") print("Chargement des extensions & librairie...") client.load_extension("cogs.commands") client.load_extension("cogs.help") # le status du bot @client.event async def on_ready(): await client.change_presence(status = discord.Status.online, activity = discord.Activity(name = "https://code.up8.edu/Anri/bot-licence", type = discord.ActivityType.competing)) print("Bot prêt.") @client.event async def on_raw_reaction_add(payload): # check toutes les nouvelles réactions if payload.message_id == 765470422149365760: # on check si on réagis au message que l'on veut # en fonction de la réaction on donne le role if payload.emoji.name == '🟡': role = discord.utils.get(payload.member.guild.roles, name="L1A1") await payload.member.add_roles(role) if payload.emoji.name == '🟠': role = discord.utils.get(payload.member.guild.roles, name="L1A2") await payload.member.add_roles(role) if payload.emoji.name == '🔵': role = discord.utils.get(payload.member.guild.roles, name="L1B1") await payload.member.add_roles(role) if payload.emoji.name == '🟣': role = discord.utils.get(payload.member.guild.roles, name="L1B2") await payload.member.add_roles(role) if payload.emoji.name == '🟤': role = discord.utils.get(payload.member.guild.roles, name="L1C1") await payload.member.add_roles(role) if payload.emoji.name == '🟢': role = discord.utils.get(payload.member.guild.roles, name="L1C2") await payload.member.add_roles(role) # meme systeme qu'au dessus sauf que c'est plus compliqué de choppé le membre pour lui retirer son rôle @client.event async def on_raw_reaction_remove(payload): if payload.message_id == 765470422149365760: if payload.emoji.name == '🟡': guild = discord.utils.find(lambda g : g.id == payload.guild_id, client.guilds) member = discord.utils.find(lambda m: m.id == payload.user_id, guild.members) role = discord.utils.get(guild.roles, name="L1A1") await member.remove_roles(role) if payload.emoji.name == '🟠': guild = discord.utils.find(lambda g : g.id == payload.guild_id, client.guilds) member = discord.utils.find(lambda m: m.id == payload.user_id, guild.members) role = discord.utils.get(guild.roles, name="L1A2") await member.remove_roles(role) if payload.emoji.name == '🔵': guild = discord.utils.find(lambda g : g.id == payload.guild_id, client.guilds) member = discord.utils.find(lambda m: m.id == payload.user_id, guild.members) role = discord.utils.get(guild.roles, name="L1B1") await member.remove_roles(role) if payload.emoji.name == '🟣': guild = discord.utils.find(lambda g : g.id == payload.guild_id, client.guilds) member = discord.utils.find(lambda m: m.id == payload.user_id, guild.members) role = discord.utils.get(guild.roles, name="L1B2") await member.remove_roles(role) if payload.emoji.name == '🟤': guild = discord.utils.find(lambda g : g.id == payload.guild_id, client.guilds) member = discord.utils.find(lambda m: m.id == payload.user_id, guild.members) role = discord.utils.get(guild.roles, name="L1C1") await member.remove_roles(role) if payload.emoji.name == '🟢': guild = discord.utils.find(lambda g : g.id == payload.guild_id, client.guilds) member = discord.utils.find(lambda m: m.id == payload.user_id, guild.members) role = discord.utils.get(guild.roles, name="L1C2") await member.remove_roles(role) # pour lancer le bot client.run(token)