Пример #1
0
async def softban(cmd, message, args):
    channel = message.channel
    if args[0]:
        user_q = message.mentions[0]
        if message.author is not user_q:
            if check_ban(message.author, channel):
                try:
                    await cmd.bot.ban(user_q)
                    await cmd.bot.unban(message.server, user_q)
                    embed = discord.Embed(color=0x66CC66,
                                          title=':white_check_mark: ' +
                                          user_q.name +
                                          ' has been soft-banned.')
                    await cmd.bot.send_message(message.channel,
                                               None,
                                               embed=embed)
                except Exception as e:
                    cmd.log.error(e)
                    await cmd.bot.send_message(message.channel, str(e))
            else:
                out_content = discord.Embed(
                    type='rich',
                    color=0xDB0000,
                    title=
                    ':no_entry: Insufficient Permissions. Ban Permission Required.'
                )
                await cmd.bot.send_message(message.channel,
                                           None,
                                           embed=out_content)
Пример #2
0
async def unban(cmd, message, args):
    channel = message.channel
    if args:
        user_q = args[0]
        if message.author is not user_q:
            if check_ban(message.author, channel):
                try:
                    ban_list = await cmd.bot.get_bans(message.server)
                    target_user = None
                    for user in ban_list:
                        if user.name.lower() == user_q.lower():
                            target_user = user
                            break
                    if target_user:
                        await cmd.bot.unban(message.server, target_user)
                        await cmd.bot.send_message(
                            message.channel,
                            'User **' + user_q + '** has been unbanned.')
                    else:
                        await cmd.bot.send_message(
                            message.channel,
                            'A user with that name was not found in the server ban list.'
                        )
                except SyntaxError as e:
                    cmd.log.error(e)
                    await cmd.bot.send_message(message.channel, str(e))
            else:
                response = await cmd.bot.send_message(
                    message.channel,
                    'Only a user with **Ban** privileges can use this command. :x:'
                )
                await asyncio.sleep(10)
                await cmd.bot.delete_message(response)
    else:
        await cmd.bot.send_message(message.channel, cmd.help())
Пример #3
0
async def unban(cmd, message, args):
    channel = message.channel
    if args:
        user_q = args[0]
        if message.author is not user_q:
            if check_ban(message.author, channel):
                ban_list = await message.guild.bans()
                target_user = None
                for user in ban_list:
                    if user.name.lower() == user_q.lower():
                        target_user = user
                        break
                if target_user:
                    await cmd.bot.unban(message.guild, target_user)
                    out_content = discord.Embed(type='rich',
                                                color=0x66CC66,
                                                title='✅ ' + target_user.name +
                                                'Unbanned.')
                    await message.channel.send(None, embed=out_content)
                else:
                    out_content = discord.Embed(
                        type='rich',
                        color=0xFF9900,
                        title='⚠ User Not Found In Ban List.')
                    await message.channel.send(None, embed=out_content)
            else:
                out_content = discord.Embed(
                    type='rich',
                    color=0xDB0000,
                    title='⛔ Insufficient Permissions. Ban Permission Required.'
                )
                await message.channel.send(None, embed=out_content)
    else:
        await message.channel.send(cmd.help())
Пример #4
0
async def ban(cmd, message, args):
    channel = message.channel
    if message.mentions:
        user_q = message.mentions[0]
        if message.author is not user_q:
            if check_ban(message.author, channel):
                await cmd.bot.ban(user_q)
                out_content = discord.Embed(color=0xFF9900,
                                            title=':hammer: User **' +
                                            user_q.name +
                                            '** has been banned!')
                await cmd.bot.send_message(message.channel,
                                           None,
                                           embed=out_content)
            else:
                out_content = discord.Embed(
                    color=0xDB0000,
                    title=
                    '⛔ Insufficient Permissions. Users with Ban permissions only.'
                )
                await cmd.bot.send_message(message.channel,
                                           None,
                                           embed=out_content)
        else:
            await cmd.bot.send_message(message.channel, cmd.help())
    else:
        await cmd.bot.send_message(message.channel, cmd.help())
Пример #5
0
async def unban(cmd, message, args):
    if not check_ban(message.author, message.channel):
        response = discord.Embed(
            title='⛔ Unpermitted. Ban Permissions Needed.', color=0xDB0000)
    else:
        if args:
            user_search = ' '.join(args)
            target = None
            banlist = await message.guild.bans()
            for entry in banlist:
                if entry.user.name.lower() == user_search.lower():
                    target = entry.user
                    break
            if target:
                await message.guild.unban(
                    target,
                    reason=
                    f'Unbanned by {message.author.name}#{message.author.discriminator}.'
                )
                response = discord.Embed(
                    title=f'✅ {target.name} has been unbanned.',
                    color=0x66CC66)
                # Logging Part
                try:
                    log_channel_id = cmd.db.get_settings(
                        message.guild.id, 'LoggingChannel')
                except:
                    log_channel_id = None
                if log_channel_id:
                    log_channel = discord.utils.find(
                        lambda x: x.id == log_channel_id,
                        message.guild.channels)
                    if log_channel:
                        log_response = discord.Embed(
                            color=0x993300, timestamp=arrow.utcnow().datetime)
                        log_response.set_author(
                            name=f'A User Has Been Unbanned',
                            icon_url=user_avatar(target))
                        log_response.add_field(
                            name='🔨 Unbanned User',
                            value=
                            f'{target.mention}\n{target.name}#{target.discriminator}',
                            inline=True)
                        author = message.author
                        log_response.add_field(
                            name='🛡 Responsible',
                            value=
                            f'{author.mention}\n{author.name}#{author.discriminator}',
                            inline=True)
                        log_response.set_footer(text=f'UserID: {target.id}')
                        await log_channel.send(embed=log_response)
            else:
                response = discord.Embed(
                    title=f'🔍 {user_search} not found in the ban list.')
        else:
            response = discord.Embed(title='❗ No user targeted.',
                                     color=0xDB0000)
    await message.channel.send(embed=response)
Пример #6
0
async def ban(cmd, message, args):

    if not check_ban(message.author, message.channel):
        response = discord.Embed(title='⛔ Unpermitted. Ban Permissions Needed.', color=0xDB0000)
        await message.channel.send(embed=response)
        return

    if not message.mentions:
        response = discord.Embed(title='❗ No user targeted.', color=0xDB0000)
        await message.channel.send(embed=response)
        return

    target = message.mentions[0]

    if target.id == message.author.id:
        response = discord.Embed(title='⛔ You can\'t ban yourself.', color=0xDB0000)
        await message.channel.send(embed=response)
        return
        
    if len(args) > 1:
        ban_reason = ' '.join(args[1:])
    else:
        ban_reason = 'No reason given.'
        
    await target.ban(reason=f'Banned by {message.author.name}#{message.author.discriminator}.\n{ban_reason}')
                
    # Logging Part
    try: log_channel_id = cmd.db.get_settings(message.guild.id, 'LoggingChannel')
    except: log_channel_id = None

    if log_channel_id:
        log_channel = discord.utils.find(lambda x: x.id == log_channel_id, message.guild.channels)
        
        if log_channel:
            author = message.author

            log_response = discord.Embed(color=0x993300, timestamp=arrow.utcnow().datetime)
            log_response.set_author(name=f'A User Has Been Banned', icon_url=user_avatar(target))
            log_response.add_field(name='🔨 Banned User', value=f'{target.mention}\n{target.name}#{target.discriminator}', inline=True)
            log_response.add_field(name='🛡 Responsible', value=f'{author.mention}\n{author.name}#{author.discriminator}', inline=True)
            log_response.add_field(name='📄 Reason', value=f"```\n{ban_reason}\n```", inline=False)
            log_response.set_footer(text=f'UserID: {target.id}')
            await log_channel.send(embed=log_response)
    
    response = discord.Embed(title=f'🔨 {target.name} has been banned.', color=0x993300)            
    await message.channel.send(embed=response)
Пример #7
0
async def ban(cmd, message, args):
    channel = message.channel
    if args[0]:
        user_q = message.mentions[0]
        if message.author is not user_q:
            if check_ban(message.author, channel):
                try:
                    await cmd.bot.ban(user_q)
                    await cmd.bot.send_message(message.channel, 'User **' + user_q.name + '** has been banned.')
                except Exception as e:
                    cmd.log.error(e)
                    await cmd.bot.send_message(message.channel, str(e))
            else:
                response = await cmd.bot.send_message(message.channel, 'Only a user with **Ban** privileges can use this command. :x:')
                await asyncio.sleep(10)
                await cmd.bot.delete_message(response)
        else:
            await cmd.bot.send_message(message.channel, cmd.help())
    else:
        await cmd.bot.send_message(message.channel, cmd.help())