Example #1
0
async def get_user(client: discord.Client, message: discord.Message,
                   args: List[str]):
    state, results = permissions_manager.get_permissions(
        message.author, message.guild)

    if not state:
        await message.channel.send(embed=EmbedsManager.error_embed(results))

    if results == 0:
        await message.channel.send(embed=EmbedsManager.error_embed(
            "You don't have the necessary permissions."))
        return

    if args and args[0] == '-h':
        return await message.channel.send(
            embed=EmbedsManager.information_embed(
                "**Server command reminder:** \n\n"
                "`!user`.\n"
                "You can optionally add a mention to a user to get it profile")
        )

    if not message.mentions:
        await message.channel.send(embed=EmbedsManager.complete_embed(
            f"https://epimodo.gastbob40.ovh/moderation/profile/"))
    else:
        await message.channel.send(embed=EmbedsManager.complete_embed(
            f"https://epimodo.gastbob40.ovh/moderation/profile/{message.mentions[0].id}"
        ))
Example #2
0
async def change_prefix(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, 'prefix'):
        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']}prefix <nouveau prefix>`"))

    # Check input
    if len(args) != 1:
        await message.channel.send(embed=EmbedsManager.error_embed(
            f"Erreur dans la commande.\nRappel : `{config['prefix']}prefix <nouveau prefix>`"
        ))
        return

    await message.channel.send(embed=EmbedsManager.complete_embed(
        f"⚙ Le préfix `{config['prefix']}` a été changé par `{args[0]}`."))

    with open('run/config/config.yml', 'w', encoding='utf8') as outfile:
        yaml.dump(config,
                  outfile,
                  default_flow_style=False,
                  allow_unicode=True)
async def user_information(client: discord.Client, message: discord.Message,
                           args: List[str], config):
    if not PermissionChecker.is_moderator(message.author):
        return await message.channel.send(embed=EmbedsManager.error_embed(
            "Vous n'avez pas les permissions nécessaires."))

    # Display help
    if args and args[0] == '-h':
        return await message.channel.send(
            embed=EmbedsManager.information_embed(
                "**Rappel de la commande d'information utilisateur :**\n\n"
                "`!ui <@user>`."))

    # Check if target exist
    target: discord.Member = message.mentions[0] if len(
        message.mentions) == 1 else False

    if not target:
        return await message.channel.send(embed=EmbedsManager.error_embed(
            "Erreur dans la commande. Vous devez mentionner un utilisateur."))

    await message.channel.send(embed=EmbedsManager.sanction_embed(
        f"Voici les informations de {target.name}#{target.discriminator} :",
    ).set_thumbnail(url=target.avatar_url).add_field(
        name='Surnom', value=target.display_name, inline=True
    ).add_field(name='Tag', value=target.discriminator, inline=True).add_field(
        name='ID', value=target.id, inline=True).add_field(
            name='Compte créé le',
            value=target.created_at.strftime('%d/%m/%Y à %H:%M:%S'),
            inline=True).add_field(
                name='A rejoint le serveur le',
                value=target.joined_at.strftime('%d/%m/%Y à %H:%M:%S'),
                inline=True).set_footer(icon_url=client.user.avatar_url,
                                        text='Made By Gastbob40'))
async def take_whitelist(client: discord.Client, message: discord.Message):
    if message.channel.id != data['command_channel']:
        return

    if not message.author.permissions_in(message.channel).manage_messages:
        return await message.author.send(
            embed=EmbedsManager.error_embed(
                "Erreur",
                "Vous n'avez pas les permissions nécessaires"
            )
        )

    if message.author.voice is None:
        return await message.author.send(
            embed=EmbedsManager.error_embed(
                "Erreur",
                "Vous devez être connecté en vocal pour faire une whitelist."
            )
        )

    if WhiteListQueue.is_empty():
        return await message.author.send(
            embed=EmbedsManager.error_embed(
                "Erreur",
                "Il n'y a personne à faire passer."
            )
        )

    await WhiteListQueue.take_player(message.author)
async def remove_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']}remove_command <command_id>`"))

    # Check inputs
    if len(args) != 1:
        return await message.channel.send(
            embed=EmbedsManager.error_embed(f":x: Erreur dans la commande."))

    command_name = args[0]
    custom_commands: List[CustomCommand] = session.query(
        CustomCommand).filter_by(command=command_name).all()

    if len(custom_commands) != 1:
        return await message.channel.send(embed=EmbedsManager.error_embed(
            f":x: Erreur. Je ne trouve pas cette commande."))

    session.delete(custom_commands[0])
    session.commit()

    await message.channel.send(embed=EmbedsManager.complete_embed(
        f"Je viens de supprimer la commande **{command_name}**."))
Example #6
0
async def donation_ask(client: discord.Client, message: discord.Message,
                       args: List[str], config):
    # Display help
    if args and args[0] == '-h':
        return await message.channel.send(
            embed=EmbedsManager.information_embed(
                "**Rappel de la commande de don :**\n\n"
                "`!don`."))

    donation_link = 'http://clash-of-clans-francais.ovh/faire-un-don/'

    await message.author.send(embed=discord.Embed(color=0xFFFFFF).set_author(
        icon_url=
        'https://pbs.twimg.com/profile_images/1142194267319873541/imd-tTed_400x400.jpg',
        name='Commande de don'
    ).set_thumbnail(
        url=
        'https://pbs.twimg.com/profile_images/1142194267319873541/imd-tTed_400x400.jpg'
    ).add_field(
        name=
        "Vous pouvez suivre les instructions suivantes pour effectuer un don.",
        value=
        f'Le site de don est le suivant : [{donation_link}]({donation_link})\n\n'
        f'Votre identifiant unique est `{message.author.id}`',
        inline=False))

    await message.channel.send(embed=EmbedsManager.complete_embed(
        'Les informations concernants les dons vous ont été envoyé en message privé.'
    ))
Example #7
0
async def banned_come_back(client: discord.Client, member: discord.Member, config):
    if member.guild.id != 278653494846685186:
        return

    api_manager = APIManager(config['api']['url'], config['api']['token'])

    state, res = api_manager.get_data(
        'temp-bans',
        user_id=str(member.id),
        is_active=True,
    )

    if not res:
        return

    with open("src/_data/roles.yml", 'r') as stream:
        roles = yaml.safe_load(stream)

    role = [Role(data=x) for x in roles if x['slug'].startswith('ban')]

    for r in role:
        await member.add_roles(member.guild.get_role(r.role_id),
                               reason=f"Bantemp")

    for channel in [config['channels']['moderator'], config['channels']['log_reactions']]:
        await client.get_channel(channel).send(
            embed=EmbedsManager.sanction_embed(
                f"{member.display_name} vient de contourner son bantemp",
                f"Il avait été bantemp pour : `{res[0]['reason']}`.")
                .set_footer(icon_url=client.user.avatar_url, text='Made By Gastbob40')
        )

    await client.get_channel( config['channels']['flood']).send(
        embed=EmbedsManager.secret_embed(
            f"je vous prie d'accueillir {member.display_name} qui vient d'essayer de contourner son ban temp.")
            .set_footer(icon_url=client.user.avatar_url, text='Made By Gastbob40')
    )

    await member.send(
        embed=EmbedsManager.sanction_embed(
            f"Bonjour {member.display_name} !",
            f"Vous nous avez fait peur en quittant {member.guild.name}, mais heureusement que vous êtes revenu.\n\n"
            f"Mais ne vous inquiétez pas, nous vous avons gardé votre bantemp rien que pour vous :wink:.")
            .set_footer(icon_url=client.user.avatar_url, text='Made By Gastbob40')
    )

    for channel in member.guild.channels:
        try:
            if isinstance(channel, discord.TextChannel):
                if member.permissions_in(channel).read_messages:
                    await channel.set_permissions(member,
                                                  send_messages=False)
            elif isinstance(channel, discord.VoiceChannel):
                if member.permissions_in(channel).connect:
                    await channel.set_permissions(member,
                                                  connect=False)
        except:
            pass
Example #8
0
async def annonce_msg(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, 'annonce'):
        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']}annonce <#channel> <couleur> <contenue>`\n"
            f"La couleur doit etre au format hexadécimale (FFFFFF) sans le #."
            f" Une image peut etre ajouté à la commande."))

    if len(message.channel_mentions) != 1:
        return await message.channel.send(embed=EmbedsManager.error_embed(
            f":x: Erreur dans la commande. Merci de specifier un channel"))

    # Get channel
    channel: discord.TextChannel = message.channel_mentions[0]
    args.pop(0)

    # Get color
    if not args:
        return await message.channel.send(embed=EmbedsManager.error_embed(
            f":x: Erreur dans la commande. Merci de specifier une couleur valide."
        ))

    try:
        color = int(args.pop(0), 16)
    except:
        return await message.channel.send(embed=EmbedsManager.error_embed(
            f":x: Erreur dans la commande. Merci de specifier une couleur valide."
        ))

    # Get content
    if not args:
        return await message.channel.send(embed=EmbedsManager.error_embed(
            f":x: Erreur dans la commande. Merci de specifier un contenue valide."
        ))

    content = ' '.join(args)
    embed = discord.Embed(color=color)
    embed.description = content

    # Get image
    if message.attachments:
        embed.set_image(url=message.attachments[0].url)

    try:
        await channel.send(embed=embed)
        await message.channel.send(embed=EmbedsManager.complete_embed(
            f"Le message a bien été envoyé dans {channel} : \n {content}"))
    except:
        await message.channel.send(embed=EmbedsManager.error_embed(
            "Je n'ai pas les permissions pour ce salon."))
async def mention_moderator(client: discord.Client, message: discord.Message,
                            config):
    role: discord.Role

    for role in message.role_mentions:
        if role.id == 490155585371766814:
            archer_role: discord.Role = message.guild.get_role(
                497451928058462221)

            if not archer_role in message.author.roles:
                return await message.channel.send(embed=EmbedsManager.error_embed(
                    f"Erreur, il faut être niveau 7 (soit {archer_role.name}) afin de mentionner un modérateur.\n"
                    f"Vous pouvez cependant vous adresser à un modérateur connecté."
                ).set_footer(icon_url=client.user.avatar_url,
                             text='Made By Gastbob40'))

            await client.get_channel(
                config['channels']['moderator']
            ).send(embed=EmbedsManager.sanction_embed(
                f"{message.author.name}#{message.author.discriminator} vient de mentionner les modérateurs."
            ).add_field(
                name='Message', value=message.content, inline=True).add_field(
                    name='Salon', value=message.channel.mention, inline=True).
                   add_field(name="Lien",
                             value=f"[{message.jump_url}]({message.jump_url})",
                             inline=False).set_footer(
                                 icon_url=client.user.avatar_url,
                                 text='Made By Gastbob40'))

            await client.get_channel(
                config['channels']['log_reactions']
            ).send(embed=EmbedsManager.sanction_embed(
                f"{message.author.name}#{message.author.discriminator} vient de mentionner les modérateurs."
            ).add_field(
                name='Message', value=message.content, inline=True).add_field(
                    name='Salon', value=message.channel.mention, inline=True).
                   add_field(name="Lien",
                             value=f"[{message.jump_url}]({message.jump_url})",
                             inline=False).set_footer(
                                 icon_url=client.user.avatar_url,
                                 text='Made By Gastbob40'))

            mentionable_message = ''
            for modo in message.guild.get_role(278656056228315136).members:
                mentionable_message += modo.mention

            msg: discord.Message = await message.channel.send(
                mentionable_message)
            await msg.delete()
Example #10
0
async def get_reasons_list(client: discord.Client, message: discord.Message):
    if not PermissionsManager.has_perm(message.author, 'manage_reason'):
        await message.channel.send(embed=EmbedsManager.error_embed(
            "Vous n'avez pas les permissions pour cette commande."))
        return

    with open('run/config/reasons.yml', 'r', encoding='utf8') as file:
        reasons = yaml.safe_load(file)

    content = f"{message.author.mention} voici la liste des **raisons** des sanctions :\n"

    for i in range(len(reasons)):
        content += f"\n**Raison {i+1} :** {reasons[i]}"

    await message.channel.send(embed=EmbedsManager.complete_embed(content))
Example #11
0
 async def run(client: discord.client, user: discord.member):
     guild: discord.guild = user.guild
     pass  # TODO TO FIX
     return
     embed = EmbedsManager.welcome_msg_embed(
         OnMemberJoin.msg_fr.format(guild.name),
         OnMemberJoin.msg_eng.format(guild.name))
     try:
         await user.send(embed=embed)
     except discord.Forbidden:
         await LogManager.error_log(
             client, "OnMemberJoin: Unable to send msg to " + user.nick +
             " -> Forbidden", guild)
     except discord.HTTPException:
         await LogManager.error_log(
             client, "OnMemberJoin: Unable to send msg to " + user.nick +
             " -> HTTPException", guild)
     except discord.InvalidArgument:
         await LogManager.error_log(
             client, "OnMemberJoin: Unable to send msg to " + user.nick +
             " -> InvalidArgument", guild)
     except:
         await LogManager.error_log(
             client, "OnMemberJoin: Unable to send msg to " + user.nick +
             " -> Unknown", guild)
Example #12
0
    async def complete_log(client: discord.Client,
                           sanction_type: str,
                           author: discord.Member or discord.User,
                           guild: discord.Guild,
                           reason: str,
                           image_url: str = ''):
        state, results = api_manager.get_data('servers', discord_id=guild.id)

        if not state:
            return

        log_channel_id = results[0]['discord_log_channel_id']
        log_channel: discord.TextChannel = client.get_channel(log_channel_id)
        embed = EmbedsManager.sanction_embed(sanction_type, guild, reason,
                                             image_url)
        embed.description = f"Sanction by {author.display_name}"

        if log_channel:
            await log_channel.send(embed=embed)

        with open('run/config/config.yml', 'r') as file:
            config = yaml.safe_load(file)

        main_channel_log = client.get_channel(
            config['channels']['log_channel'])
        if main_channel_log:
            embed.set_thumbnail(url=guild.icon_url)
            await main_channel_log.send(embed=embed)
Example #13
0
async def print_news(client: discord.Client, news_id: str, group: str,
                     group_manager: NewsGroupManager) -> datetime:
    info = dict()
    _, head = group_manager.NNTP.head(news_id)
    last = "NULL"
    for l in head.lines:
        s = l.decode(group_manager.encoding).split(": ", 1)
        if len(s) != 2:
            info[last] = info[last] + nntplib.decode_header(s[0])
            continue
        last = s[0]
        info[s[0]] = nntplib.decode_header(s[1])
    author = info["From"]
    subject = info["Subject"]
    d = info["Date"][:25]
    if d[-1] == " ":
        d = d[:-1]
    date = datetime.strptime(d, "%a, %d %b %Y %H:%M:%S")

    _, body = group_manager.NNTP.body(news_id)
    content = ""
    for l in body.lines:
        content += l.decode(group_manager.encoding) + "\n"

    # get the tags
    tags = []
    s = subject.split("]", 1)
    while len(s) != 1:
        tags.append((s[0])[1:])
        s = s[1].split("]", 1)
    subject = s[0]
    # slice the msg in chunk of 5120 char
    msg = [content[i:i + 5120] for i in range(0, len(content), 5120)]
    # print msg in every channel newsgroup_filler_embed
    embed = EmbedsManager.newsgroup_embed(subject, tags, msg[0], author, date,
                                          group_manager.groups[group]["name"])
    for channel in group_manager.groups[group]["channels"]:
        await client.get_channel(channel).send(embed=embed)
    for m in msg:
        embed = EmbedsManager.newsgroup_filler_embed(
            m, author, date, group_manager.groups[group]["name"])
        for channel in group_manager.groups[group]["channels"]:
            await client.get_channel(channel).send(embed=embed)

    return date
Example #14
0
async def add_reason(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, 'manage_reason'):
        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']}reason_add <reason>`"
            )
        )

    # Check inputs
    if len(args) < 2:
        return await message.channel.send(
            embed=EmbedsManager.error_embed(
                f":x: Merci de mettre une raison d'au moins deux mots."
            )
        )

    # Process code
    with open('run/config/reasons.yml', 'r', encoding='utf8') as file:
        reasons = yaml.safe_load(file)
    reasons.append((' '.join(args)))

    with open('run/config/reasons.yml', 'w', encoding='utf8') as outfile:
        yaml.dump(reasons, outfile, default_flow_style=False, allow_unicode=True)

    await message.channel.send(
        embed=EmbedsManager.complete_embed(
            f"{message.author.mention} La raison `{reasons[-1]}` a été ajouté à la liste.\n"
            f"Son numéro d'attribution est le {len(reasons)}."
        )
    )
Example #15
0
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()
Example #16
0
async def report_message(client: discord.Client, reaction: discord.Reaction, user: discord.User):
    guild = reaction.message.guild

    await reaction.remove(user)

    state, results = permissions_manager.get_permissions(user, guild)

    if not state:
        return await reaction.message.channel.send(
            embed=EmbedsManager.error_embed(results)
        )

    # Check lvl permissions
    if results == 0:
        return await reaction.message.channel.send(
            embed=EmbedsManager.error_embed("You don't have the necessary permissions.")
        )

    # Check role
    _, target_results = permissions_manager.get_permissions(reaction.message.author, guild)

    if target_results >= results:
        return await reaction.message.channel.send(
            embed=EmbedsManager.error_embed("You cannot warn someone greater than or equal to you.")
        )

    reason = reaction.message.content

    api_manager.post_data('warns',
                          target_id=reaction.message.author.id,
                          author_id=user.id,
                          server_id=guild.id,
                          reason='Reported Message: ' + reason,
                          )

    await LogManager.complete_log(client, 'warns', user, guild, reason)

    try:
        await reaction.message.author.send(
            embed=EmbedsManager.sanction_embed('Reported Message', guild, reason)
        )
    except Exception as e:
        print(e)
Example #17
0
async def warn_member(client: discord.Client, message: discord.Message,
                      args: List[str], config):
    api_manager = APIManager(config['api']['url'], config['api']['token'])

    if not PermissionChecker.is_moderator(message.author):
        return await message.channel.send(embed=EmbedsManager.error_embed(
            "You don't have the necessary permissions."))

    # Display help
    if args and args[0] == '-h':
        return await message.channel.send(
            embed=EmbedsManager.information_embed(
                "**Warning command reminder:**\n\n"
                "`!av <@user> <reason>`."))

    # Check if target exist
    target: discord.Member = message.mentions[0] if len(
        message.mentions) == 1 else False

    if not target:
        return await message.channel.send(embed=EmbedsManager.error_embed(
            "Error in the command. You must mention an user."))

    args = args[1:]

    if len(args) == 0:
        return await message.channel.send(embed=EmbedsManager.error_embed(
            "Error in the command. You must add a reason."))

    warn = Warn()
    warn.user_id = target.id
    warn.moderator_id = message.author.id
    warn.reason = ' '.join(args)
    warn.save()

    _, res = api_manager.get_data('warns', user_id=target.id)
    nb_warns = len(res)

    await message.channel.send(embed=EmbedsManager.sanction_embed(
        f"Avertissement du membre {target.display_name}.",
        f"Vous venez de l'avertir pour : `{warn.reason}`.").add_field(
            name="Nombre :", value=nb_warns, inline=False).set_footer(
                icon_url=client.user.avatar_url, text='Made By Gastbob40'))

    await client.get_channel(
        config['channels']['log_reactions']
    ).send(embed=EmbedsManager.sanction_embed(
        f"Avertissement du membre {target.display_name}.",
        f"Il a été averti pour : `{warn.reason}`.").set_footer(
            icon_url=client.user.avatar_url, text='Made By Gastbob40').
           add_field(name="Auteur :", value=message.author.display_name))

    await target.send(embed=EmbedsManager.sanction_embed(
        f"Vous venez de subir un avertissement.",
        f"Vous venez d'être averti pour : `{warn.reason}`.").set_footer(
            icon_url=client.user.avatar_url, text='Made By Gastbob40'
        ).add_field(name="Auteur :", value=message.author.display_name))
Example #18
0
async def list_customcommands(client: discord.Client, message: discord.Message,
                              args: List[str]):
    with open('run/config/config.yml', 'r') as file:
        config = yaml.safe_load(file)

    # 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']}list_command`"))

    custom_commands: List[CustomCommand] = session.query(CustomCommand).all()

    content = "Voici les commandes personnalisées :"

    for custom_command in custom_commands:
        content += f'\n - `{custom_command.command}`'

    await message.channel.send(embed=EmbedsManager.complete_embed(content))
Example #19
0
async def load_custom_commands(client: discord.Client,
                               message: discord.Message, args: List[str],
                               config):

    api_manager = APIManager(config['api']['url'], config['api']['token'])

    if not PermissionChecker.is_owner(message.author):
        return await message.channel.send(embed=EmbedsManager.error_embed(
            "You don't have the necessary permissions."))

    state, res = api_manager.get_data('custom-commands')

    if not state:
        return await message.channel.send(embed=EmbedsManager.error_embed(res))

    with open('src/_data/custom_commands.yml', 'w') as file:
        documents = yaml.dump(res, file, sort_keys=True)

    return await message.channel.send(embed=EmbedsManager.complete_embed(
        "The command was successful.",
        f'{len(res)} custom commands have been loaded.'))
Example #20
0
    async def take_player(staff: discord.Member):
        target: discord.Member = await staff.guild.fetch_member(WhiteListQueue.requests[0])

        await target.send(
            embed=EmbedsManager.complete_embed(
                'Entretient en cours',
                f'{staff.display_name} vient de vous prendre en entretient.'
            )
        )

        await target.move_to(staff.voice.channel)
        await WhiteListQueue.remove_player(target, False)
Example #21
0
    async def remove_player(member: discord.Member, contact=True):
        if member.id not in WhiteListQueue.requests:
            return

        WhiteListQueue.requests.remove(member.id)

        if contact:
            await member.send(
                embed=EmbedsManager.error_embed(
                    "Vous venez de quitter la file d'attente",
                    f"Vous perdez donc votre priorité dans la file d'attente."
                )
            )

        for i in range(len(WhiteListQueue.requests)):
            target: discord.User = await WhiteListQueue.client.fetch_user(WhiteListQueue.requests[i])

            await target.send(
                embed=EmbedsManager.complete_embed(
                    "Avancement dans la file d'attente",
                    f"Vous êtes maintenant en position **{i + 1}** dans la file d'attente.\n\n"
                )
            )
Example #22
0
async def mute(client: discord.Client, reaction: discord.Reaction,
               user: discord.User):
    state, results = permissions_manager.get_permissions(
        user, reaction.message.guild)

    if not state:
        return await reaction.message.channel.send(
            embed=EmbedsManager.error_embed(results))

    # Check lvl permissions
    if results == 0:
        return

    target: discord.Member = reaction.message.author

    # Check role
    _, target_results = permissions_manager.get_permissions(
        target, reaction.message.guild)

    if target_results >= results:
        return

    try:
        if target.permissions_in(reaction.message.channel).read_messages:
            await reaction.message.channel.set_permissions(target,
                                                           send_messages=False)
        else:
            return
    except Exception as e:
        await reaction.message.channel.send(embed=EmbedsManager.error_embed(
            f"Error in muting the member : {e}"))

    await LogManager.complete_log(
        client, 'mutes', user, reaction.message.guild,
        f"muted {target.display_name} in channel(s) : "
        f"{reaction.message.channel.name}.", '')
Example #23
0
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()
Example #24
0
async def get_mutes(client: discord.Client, message: discord.Message, args: List[str]):
    state, results = permissions_manager.get_permissions(message.author, message.guild)

    if not state:
        return await message.channel.send(
            embed=EmbedsManager.error_embed(results)
        )

    # Check lvl permissions
    if results == 0:
        return await message.channel.send(
            embed=EmbedsManager.error_embed("You don't have the necessary permissions.")
        )

    # Display help
    if args and args[0] == '-h':
        return await message.channel.send(
            embed=EmbedsManager.information_embed("**Muting command reminder:**\n\n"
                                                  "`!get_mute <@user>`.\n")
        )

    # Check if target exist
    target: discord.Member = message.mentions[0] if len(message.mentions) == 1 else False

    if not target:
        return await message.channel.send(
            embed=EmbedsManager.error_embed("Error in the command. You must mention an user.")
        )

    # Check role
    _, target_results = permissions_manager.get_permissions(target, message.guild)

    if target_results >= results:
        return await message.channel.send(
            embed=EmbedsManager.error_embed("You cannot get mutes for someone greater than or equal to you.")
        )
    channels = []
    try:
        for channel in message.guild.channels:
            if not target.permissions_in(channel).send_messages:
                channels.append(channel)
        await message.channel.send(
            embed=EmbedsManager.complete_embed(f"{target.display_name} is muted in the following channel(s) : " +
                                               "{}.".format(',\n '.join([chan.name for chan in channels])))
        )

    except Exception as e:
        await message.channel.send(
            embed=EmbedsManager.error_embed(f"Error in muting the member. : {e}")
        )
Example #25
0
async def unmute(client: discord.Client, message: discord.Message,
                 args: List[str]):
    state, results = permissions_manager.get_permissions(
        message.author, message.guild)

    if not state:
        return await message.channel.send(
            embed=EmbedsManager.error_embed(results))

    # Check lvl permissions
    if results == 0:
        return await message.channel.send(embed=EmbedsManager.error_embed(
            "You don't have the necessary permissions."))

    # Display help
    if args and args[0] == '-h':
        return await message.channel.send(
            embed=EmbedsManager.information_embed(
                "**UnMuting command reminder:**\n\n"
                "`!unmute <@user> (<#channel>)`.\n"))

    # Check if target exist
    target: discord.Member = message.mentions[0] if len(
        message.mentions) == 1 else False

    if not target:
        return await message.channel.send(embed=EmbedsManager.error_embed(
            "Error in the command. You must mention an user."))

    # Check role
    _, target_results = permissions_manager.get_permissions(
        target, message.guild)

    if target_results >= results:
        return await message.channel.send(embed=EmbedsManager.error_embed(
            "You cannot unmute someone greater than or equal to you."))

    channels = message.channel_mentions if len(
        message.channel_mentions) >= 1 else [message.channel]
    await message.channel.send(embed=EmbedsManager.complete_embed(
        f"You just unmuted {target.display_name} in channel(s) : "
        f"{' '.join([chan.name for chan in channels]) }."))

    await LogManager.complete_log(
        client, 'unmutes', message.author, message.guild,
        f"unmuted {target.display_name} in channel(s) : "
        f"{' '.join([chan.name for chan in channels]) }.", '')

    for channel in channels:
        try:
            if not target.permissions_in(channel).send_messages:
                await channel.set_permissions(target, overwrite=None)
        except:
            pass
Example #26
0
    async def error_log(client: discord.Client, error_content: str,
                        guild: discord.Guild):
        state, results = api_manager.get_data('servers', discord_id=guild.id)

        if not state:
            return

        log_channel_id = results[0]['discord_log_channel_id']
        log_channel: discord.TextChannel = client.get_channel(log_channel_id)
        embed = EmbedsManager.error_embed(error_content)

        if log_channel:
            await log_channel.send(embed=embed)

        main_channel_log = client.get_channel(553974648258166800)
        if main_channel_log:
            embed.set_thumbnail(url=guild.icon_url)
            await main_channel_log.send(embed=embed)
async def unfreeze_server(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, 'freeze'):
        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']}rfreeze`"))

    # Check inputs
    current_message: discord.Message = await message.channel.send(
        embed=EmbedsManager.complete_embed(
            f"{message.author.mention} Vous avez décidé de dégeler le serveur.\n"
            + f"Confirmer vous ce choix ?"))

    await current_message.add_reaction('✅')
    await current_message.add_reaction('❌')

    def check(reaction: discord.Reaction, user: discord.User):
        return user == message.author and (str(reaction.emoji) == '✅'
                                           or str(reaction.emoji) == '❌')

    try:
        reaction, user = await client.wait_for('reaction_add',
                                               timeout=20.0,
                                               check=check)
    except asyncio.TimeoutError:
        await message.channel.send(embed=EmbedsManager.error_embed(
            f"Vous avez __refusé__ le dégel du serveur."))
    else:
        if str(reaction.emoji) == '❌':
            return await message.channel.send(embed=EmbedsManager.error_embed(
                f"Vous avez __refusé__ le dégel du serveur."))

        await message.channel.send(
            embed=EmbedsManager.complete_embed(f"Le serveur a été dégelé"))

        members: List[discord.Member] = message.guild.members

        for member in members:
            if not member.guild_permissions.manage_messages:
                for channel in message.guild.channels:
                    if not member.permissions_in(channel).send_messages:
                        await channel.set_permissions(member, overwrite=None)
Example #28
0
    async def add_player(member: discord.Member):
        WhiteListQueue.requests.append(member.id)

        await member.send(
            embed=EmbedsManager.complete_embed(
                "Vous venez de rejoindre la file d'attente",
                f"Vous êtes en position **{len(WhiteListQueue.requests)}** dans la file d'attente.\n\n"
                f"Un staff s'occupera de vous dès qu'il sera disponible."
            )
        )

        print(
            colored("[FRaternity Whitelist]", 'yellow'),
            colored(
                f"{member.name}#{member.discriminator} ({member.id}) just join the queue at pos {len(WhiteListQueue.requests)}",
                'blue'
            )
        )
Example #29
0
async def revoke_mute(client: discord.Client, message: discord.Message,
                      args: List[str]):
    with open('run/config/config.yml', 'r') as file:
        config = yaml.safe_load(file)

    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']}rmute <mute_id>`"))

    if len(args) != 1:
        return await message.channel.send(embed=EmbedsManager.error_embed(
            f":x: Erreur dans la commande, merci de spécifier l'index du mute."
        ))

    if not args[0].startswith("m"):
        return await message.channel.send(
            embed=EmbedsManager.error_embed(":x: Erreur, index invalide."))

    index = int(args[0][1:])
    current_mute: Mute = session.query(Mute).filter_by(id=index).first()

    if current_mute is None:
        return await message.channel.send(
            embed=EmbedsManager.error_embed(":x: Erreur, index invalide."))

    if not current_mute.is_active:
        return await message.channel.send(embed=EmbedsManager.error_embed(
            ":x: Erreur, ce mute est déjà révoqué."))

    current_mute.is_active = False
    session.commit()

    target: discord.Member = message.guild.get_member(current_mute.target_id)
    for channel in message.guild.channels:
        if not target.permissions_in(channel).send_messages:
            await channel.set_permissions(target, overwrite=None)

    await message.channel.send(embed=EmbedsManager.complete_embed(
        f"⚠ Le mute **{args[0]}** a été révoqué."))
Example #30
0
    async def error_log(client: discord.Client, error_content: str,
                        guild: discord.Guild):
        main_channel_log = client.get_channel(692055209429565498)
        embed = EmbedsManager.error_embed(error_content)
        if main_channel_log:
            if guild is not None:
                embed.set_thumbnail(url=guild.icon_url)
            await main_channel_log.send(embed=embed)
        if guild is None:
            return
        state, results = api_manager.get_data('servers', discord_id=guild.id)

        if not state:
            return

        log_channel_id = results[0]['discord_log_channel_id']
        log_channel: discord.TextChannel = client.get_channel(log_channel_id)

        if log_channel:
            await log_channel.send(embed=embed)