async def kick_member(client: discord.Client, message: discord.Message, args: List[str]): with open('run/config/config.yml', 'r') as file: config = yaml.safe_load(file) # Check permissions if not PermissionsManager.has_perm(message.author, 'kick'): return await message.channel.send(embed=EmbedsManager.error_embed( "Vous n'avez pas les permissions pour cette commande.")) # Help message if args and args[0] == '-h': return await message.channel.send( embed=EmbedsManager.information_embed( "Rappel de la commande : \n" f"`{config['prefix']}kick <@pseudo> <reason>`\n" f"`{config['prefix']}kick <@pseudo> -r <reason_id>`")) # Check inputs if len(message.mentions) != 1: return await message.channel.send(embed=EmbedsManager.error_embed( ":x: Erreur dans la commande. Merci de mentionner un utilisateur.") ) if len(args) < 2: return await message.channel.send(embed=EmbedsManager.error_embed( ":x: Erreur dans la commande. Merci de mettre une raison.")) with open('run/config/reasons.yml', 'r', encoding='utf8') as file: reasons = yaml.safe_load(file) current_reason = "" if args[0] == '-r': # Saved reason try: for reason_index in args[1:]: current_reason += f"- {reasons[int(reason_index)]}\n" except: return await message.channel.send(embed=EmbedsManager.error_embed( ":x: Erreur dans la commande. Merci de mettre un index d'erreur valide." )) else: # Custom reason current_reason = " ".join(args) new_kick = Kick(message.mentions[0].id, message.author.id, current_reason) session.add(new_kick) session.commit() await message.channel.send(embed=EmbedsManager.complete_embed( f"👢 Le membre **{message.mentions[0]}** a été kické (id `k{new_kick.id}`):\n{current_reason}" )) await message.mentions[0].kick()
async def add_customcommands(client: discord.Client, message: discord.Message, args: List[str]): with open('run/config/config.yml', 'r') as file: config = yaml.safe_load(file) # Check permissions if not PermissionsManager.has_perm(message.author, 'custom_commands'): return await message.channel.send( embed=EmbedsManager.error_embed( "Vous n'avez pas les permissions pour cette commande." ) ) # Help message if args and args[0] == '-h': return await message.channel.send( embed=EmbedsManager.information_embed( "Rappel de la commande : \n" f"`{config['prefix']}add_command <name> <content>`" ) ) # Process code if len(args) < 2: return await message.channel.send( embed=EmbedsManager.error_embed( f":x: Erreur dans la commande." ) ) command_name = args[0] command_content = ' '.join(args[1:]) await message.channel.send( embed=EmbedsManager.complete_embed( f"{message.author.mention} vient de créer une nouvelle commande :\n" f"**Nom :** {command_name}\n" f"**Contenue :** {command_content}." ) ) custom_command = CustomCommand(command_name, command_content) session.add(custom_command) session.commit()
async def on_mp(client: discord.Client, message: discord.Message): with open('run/config/config.yml', 'r') as file: config = yaml.safe_load(file) author: discord.User = message.author link: Channel = session.query(Channel).filter_by( author_id=author.id).first() if not link: # Pas encore connecté now = datetime.now() topic = f"Username : {author.name}#{author.discriminator}\n" \ f"ID : {author.id}\n" \ f"Conversation commencé le : {now.day}/{now.month}/{now.year} à {now.hour}:{now.minute}" channel = await client.get_guild( config['guild_id']).create_text_channel( author.name[:10], category=client.get_guild(config['guild_id']).get_channel( config['category_id']), topic=topic) link = Channel(author.id, channel.id) session.add(link) session.commit() await message.channel.send( "Merci pour votre message! " "Notre équipe de modérateurs vous répondra dans les plus brefs délais.\n" "Tous les messages que vous posterez ici (y compris votre précédent message), " "sera retransmis au staff.") await client.get_channel(link.channel_id).send( f"**Une discussion vient de commencer avec " f"{author.name}#{author.discriminator} | {author.id}.**") if message.content: await client.get_channel(link.channel_id).send(message.content) for attachment in message.attachments: await client.get_channel(link.channel_id).send(attachment.proxy_url) await message.add_reaction('📨')
async def mute_member(client: discord.Client, message: discord.Message, args: List[str]): with open('run/config/config.yml', 'r') as file: config = yaml.safe_load(file) # Check permissions if not PermissionsManager.has_perm(message.author, 'mute'): return await message.channel.send(embed=EmbedsManager.error_embed( "Vous n'avez pas les permissions pour cette commande.")) # Help message if args and args[0] == '-h': return await message.channel.send( embed=EmbedsManager.information_embed( "Rappel de la commande : \n" f"`{config['prefix']}mute <@pseudo> <reason>`\n" f"`{config['prefix']}mute <@pseudo> -r <reason_id>`")) # Check inputs if len(message.mentions) != 1: return await message.channel.send(embed=EmbedsManager.error_embed( f":x: Erreur dans la commande. Merci de mentionner un utilisateur." )) if len(args) < 3: return await message.channel.send(embed=EmbedsManager.error_embed( f":x: Erreur dans la commande. Merci de mettre une raison.")) # Process code args = args[1:] if not args[0].isdigit(): return await message.channel.send(embed=EmbedsManager.error_embed( f":x: Erreur dans la commande. Merci de mettre une durée valide.")) duration: int = int(args[0]) args = args[1:] with open('run/config/reasons.yml', 'r', encoding='utf8') as file: reasons = yaml.safe_load(file) current_reason = "" if args[0] == '-r': # Saved reason try: for reason_index in args[1:]: current_reason += f"- {reasons[int(reason_index)]}\n" except: return await message.channel.send(embed=EmbedsManager.error_embed( f":x: Erreur dans la commande. Merci de mettre un index d'erreur valide." )) else: # Custom reason current_reason = " ".join(args) new_mute = Mute(message.mentions[0].id, message.author.id, current_reason, duration) session.add(new_mute) session.commit() # Remove permission target: discord.Member = message.mentions[0] for channel in message.guild.channels: if target.permissions_in(channel).read_messages: await channel.set_permissions(target, send_messages=False) await message.channel.send(embed=EmbedsManager.complete_embed( f"⚠ Le membre **{message.mentions[0]}** a été mute (id `m{new_mute.id}`):\n{current_reason}" ))