예제 #1
0
async def prune(cmd, message, args):
    channel = message.channel
    if check_man_msg(message.author, channel):
        try:
            if args[0]:
                count = int(args[0])
            else:
                count = 100
        except:
            count = 100
        try:
            if args[1]:

                def crit(m):
                    return m.author == message.mentions[0]
            else:
                crit = None
        except:
            crit = None
        try:
            await cmd.bot.purge_from(message.channel, limit=count, check=crit)
            response = await cmd.bot.send_message(message.channel,
                                                  'Done! :ok_hand:')
            await asyncio.sleep(10)
            await cmd.bot.delete_message(response)
        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 the **Manage Messages** privilege can use this command. :x:'
        )
        await asyncio.sleep(10)
        await cmd.bot.delete_message(response)
예제 #2
0
async def unblockword(cmd, message, args):
    if not check_man_msg(message.author, message.channel):
        response = discord.Embed(title='⛔ Unpermitted. Requires Manage Messages Permission.', color=0xDB0000)
    else:
        try:
            blacklist = cmd.db.get_settings(message.guild.id, 'BlockedWords')
        except:
            cmd.db.set_settings(message.guild.id, 'BlockedWords', [])
            blacklist = []
        removed = []
        failed = []
        for word in args:
            word = word.lower()
            if word not in blacklist:
                reason = 'Not found in blacklist.'
                failed.append([word, reason])
            else:
                removed.append(word)
                blacklist.remove(word)
        cmd.db.set_settings(message.guild.id, 'BlockedWords', blacklist)
        response = discord.Embed(color=0x66CC66, title='✅ Blacklist Removals Finished')
        if removed:
            response.add_field(name='Successfull Removals', value=f'```\n{", ".join(removed)}\n```', inline=False)
        if failed:
            fail_text = ''
            for failure in failed:
                fail_text += f'\n{failure[0]} - {failure[1]}'
            response.add_field(name='Failed Removals', value=f'```\n{fail_text}\n```', inline=False)
    await message.channel.send(embed=response)
예제 #3
0
async def unmute(cmd, message, args):
    channel = message.channel
    server = message.server
    if not message.mentions:
        await cmd.bot.send_message(message.channel, cmd.help())
        return
    user_q = message.mentions[0]
    if message.author is not user_q:
        if check_man_msg(message.author, channel) and check_man_roles(
                message.author, channel):
            for chan in server.channels:
                if str(chan.type).lower() == 'text':
                    if not check_write(user_q, chan):
                        await cmd.bot.delete_channel_permissions(chan, user_q)
            embed = discord.Embed(color=0x66CC66,
                                  title=':white_check_mark: ' + user_q.name +
                                  ' can write again.')
            await cmd.bot.send_message(message.channel, None, embed=embed)
        else:
            out_content = discord.Embed(
                type='rich',
                color=0xDB0000,
                title=
                ':no_entry: Insufficient Permissions. Manage Messages and Manage Roles Permissions Required.'
            )
            await cmd.bot.send_message(message.channel,
                                       None,
                                       embed=out_content)
예제 #4
0
async def warn(cmd, message, args):

    if not check_man_msg(message.author, message.channel):
        out_content = discord.Embed(color=0xDB0000, title=':no_entry: Users With Kick Permissions Only.')
        await message.channel.send(None, embed=out_content)
        return

    if not message.mentions:
        response = discord.Embed(title='❗ No user targeted.', color=0xDB0000)
        await message.channel.send(embed=response)
        return
    
    if not args:
        await message.channel.send(cmd.help()); 
        return
    
    target = message.mentions[0]
    if target.id == message.author.id:
        response = discord.Embed(title='⛔ You can\'t warn yourself.', color=0xDB0000)
        await message.channel.send(embed=response)
        return

    warning_text = ' '.join(args).replace(target.mention, '')[1:]
    warn_action(cmd, message.guild, message.channel, target, message.author, warning_text)

    out_content_local = discord.Embed(color=0xFF9900, title=f'⚠ {target.name} has been warned.')
    await message.channel.send(None, embed=out_content_local)
예제 #5
0
async def mute(cmd, message, args):
    channel = message.channel
    server = message.server
    if not message.mentions:
        await cmd.bot.send_message(message.channel, cmd.help())
        return
    user_q = message.mentions[0]
    overwrite = PermissionOverwrite()
    overwrite.send_messages = False
    if message.author is not user_q:
        if check_man_msg(message.author, channel) and check_man_roles(
                message.author, channel):
            try:
                for chan in server.channels:
                    if str(chan.type).lower() == 'text':
                        if check_write(user_q, chan):
                            await cmd.bot.edit_channel_permissions(
                                chan, user_q, overwrite)
                await cmd.bot.send_message(
                    message.channel, 'Execution Successful.\nUser **' +
                    user_q.name + '** was muted')
            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 the **Manage Messages and Manage Roles** privilege can use this command. :x:'
            )
            await asyncio.sleep(10)
            await cmd.bot.delete_message(response)
예제 #6
0
파일: blind.py 프로젝트: Blitzfrog/Sickle
async def blind(cmd, message, args):
    channel = message.channel
    server = message.server
    if not message.mentions:
        await cmd.bot.send_message(message.channel, cmd.help())
        return
    user_q = message.mentions[0]
    overwrite = discord.PermissionOverwrite()
    overwrite.read_messages = False
    if message.author is not user_q:
        if check_man_msg(message.author, channel) and check_man_roles(
                message.author, channel):
            for chan in server.channels:
                if not chan.is_default:
                    if str(chan.type).lower() == 'text':
                        if check_write(user_q, chan):
                            await cmd.bot.edit_channel_permissions(
                                chan, user_q, overwrite)
            embed = discord.Embed(color=0x66CC66,
                                  title='✅ ' + user_q.name + ' Was Blinded!')
            await cmd.bot.send_message(message.channel, None, embed=embed)
        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)
예제 #7
0
파일: mute.py 프로젝트: Blitzfrog/Sickle
async def mute(cmd, message, args):
    channel = message.channel
    server = message.server
    if not message.mentions:
        await cmd.bot.send_message(message.channel, cmd.help())
        return
    user_q = message.mentions[0]
    overwrite = discord.PermissionOverwrite()
    overwrite.send_messages = False
    if message.author is not user_q:
        if check_man_msg(message.author, channel) and check_man_roles(
                message.author, channel):
            if args:
                try:
                    timeout_period = int(args[0])
                except:
                    embed = discord.Embed(
                        color=0xDB0000,
                        title='❗ Invalid number of seconds for the timeout.')
                    await cmd.bot.send_message(message.channel,
                                               None,
                                               embed=embed)
                    return
            else:
                timeout_period = None
            for chan in server.channels:
                if str(chan.type).lower() == 'text':
                    if check_write(user_q, chan):
                        await cmd.bot.edit_channel_permissions(
                            chan, user_q, overwrite)
            embed = discord.Embed(color=0x66CC66,
                                  title='✅ ' + user_q.name + ' muted.')
            await cmd.bot.send_message(message.channel, None, embed=embed)
            if timeout_period:
                await asyncio.sleep(timeout_period)
                for chan in server.channels:
                    if str(chan.type).lower() == 'text':
                        if not check_write(user_q, chan):
                            await cmd.bot.delete_channel_permissions(
                                chan, user_q)
                embed = discord.Embed(color=0x66CC66,
                                      title='✅ ' + user_q.name +
                                      ' can write again.')
                await cmd.bot.send_message(message.channel, None, embed=embed)
        else:
            out_content = discord.Embed(
                type='rich',
                color=0xDB0000,
                title=
                '⛔ Insufficient Permissions. Requires Manage Messages and Manage Roles Permissions.'
            )
            await cmd.bot.send_message(message.channel,
                                       None,
                                       embed=out_content)
예제 #8
0
async def blockinvites(cmd, message, args):
    if not check_man_msg(message.author, message.channel):
        response = discord.Embed(title='⛔ Unpermitted. Requires Manage Messages Permission.', color=0xDB0000)
    else:
        active = cmd.db.get_settings(message.guild.id, 'BlockInvites')
        if active:
            cmd.db.set_settings(message.guild.id, 'BlockInvites', False)
            response = discord.Embed(color=0x66CC66, title='✅ Invite Blocking Has Been Disabled')
        else:
            cmd.db.set_settings(message.guild.id, 'BlockInvites', True)
            response = discord.Embed(color=0x66CC66, title='✅ Invite Blocking Has Been Enabled')
    await message.channel.send(None, embed=response)
예제 #9
0
async def warns(cmd, message, args):
    try:
        warned_users = cmd.db.get_settings(message.guild.id, 'WarnedUsers')
    except KeyError:
        cmd.db.set_settings(message.guild.id, 'WarnedUsers', {})
        warned_users = {}
    if not check_man_msg(message.author, message.channel):
        target = message.author
        target_id = str(target.id)
        if target_id not in warned_users:
            embed = discord.Embed(color=0x0099FF,
                                  title='ℹ You Were Never Warned')
        else:
            embed = discord.Embed(color=0x0099FF)
            embed.add_field(name='ℹ You Were Warned For...',
                            value='```\n- ' +
                            '\n- '.join(warned_users[target_id]['Reasons']) +
                            '\n```')
        await message.channel.send(None, embed=embed)
        return
    if not message.mentions:
        if len(warned_users) == 0:
            embed = discord.Embed(color=0x0099FF,
                                  title='ℹ There Are No Warned Users')
        else:
            warn_user_list = []
            for key in warned_users:
                for member in message.guild.members:
                    if member.id == warned_users[key]['UserID']:
                        warn_user_list.append(
                            f'{member.name}#{member.discriminator}')
            embed = discord.Embed(color=0x0099FF)
            embed.add_field(name='ℹ List of Warned Users',
                            value='```\n' + ', '.join(warn_user_list) +
                            '\n```')
    else:
        target = message.mentions[0]
        target_id = str(target.id)
        if target_id not in warned_users:
            embed = discord.Embed(color=0x0099FF,
                                  title='ℹ ' + target.name +
                                  ' Was Never Warned')
        else:
            embed = discord.Embed(color=0x0099FF)
            embed.add_field(name='ℹ ' + target.name + ' Was Warned For...',
                            value='```\n- ' +
                            '\n- '.join(warned_users[target_id]['Reasons']) +
                            '\n```')
    await message.channel.send(None, embed=embed)
예제 #10
0
async def unwarn(cmd, message, args):
    
    if not check_man_msg(message.author, message.channel):
        out_content = discord.Embed(color=0xDB0000, title='⛔ Users With Manage Messages Permissions Only.')
        await message.channel.send(None, embed=out_content)
        return
    
    if not args or not message.mentions:
        await message.channel.send(cmd.help()); 
        return
    
    target = message.mentions[0]
    target_id = str(target.id)
    
    try: warned_users = cmd.db.get_settings(str(message.guild.id), 'WarnedUsers')
    except KeyError:
        cmd.db.set_settings(str(message.guild.id), 'WarnedUsers', {})
        warned_users = {}
    
    if target_id not in warned_users:
        response = discord.Embed(color=0x0099FF, title=f'ℹ {target.name} is not in the list of warned users.')
        await message.channel.send(None, embed=response)
        return

    del warned_users[target_id]
    cmd.db.set_settings(str(message.guild.id), 'WarnedUsers', warned_users)
       
    # Logging Part
    try: log_channel_id = cmd.db.get_settings(str(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

            response = discord.Embed(color=0xFF9900, timestamp=arrow.utcnow().datetime)
            response.set_author(name=f'A User\'s Warnings Have Been Removed', icon_url=user_avatar(target))
            response.add_field(name='⚠ Unwarned User', value=f'{target.mention}\n{target.name}#{target.discriminator}', inline=True)
            response.add_field(name='🛡 Responsible', value=f'{author.mention}\n{author.name}#{author.discriminator}', inline=True)
            response.set_footer(text=f'UserID: {target.id}')
            await log_channel.send(embed=response)

    response = discord.Embed(color=0x66CC66, title=f'✅ {target.name} has been removed from the warning list.')
    await message.channel.send(None, embed=response)
    
예제 #11
0
async def prune(cmd, message, args):
    channel = message.channel
    if check_man_msg(message.author, channel):
        limit = 100
        target = cmd.bot.user
        if not args:
            limit = 100
            target = cmd.bot.user
        if len(args) == 1 and message.mentions:
            limit = 100
            target = message.mentions[0]
        if len(args) > 1 and message.mentions:
            target = message.mentions[0]
            limit = abs(int(args[0]))
        if len(args) == 1 and not message.mentions:
            target = None
            limit = abs(int(args[0]))
        try:
            await cmd.bot.delete_message(message)
        except:
            pass

        def author_check(msg):
            return msg.author == target

        if target:
            deleted = await cmd.bot.purge_from(message.channel,
                                               limit=limit,
                                               check=author_check)
        else:
            deleted = await cmd.bot.purge_from(message.channel, limit=limit)
        embed = discord.Embed(
            color=0x66CC66,
            title=f':white_check_mark: Deleted {len(deleted)} Messages')
    else:
        embed = discord.Embed(
            title=
            ':warning: Unpermitted. Only Those With The Manage Message Permission Allowed.',
            color=0xDB0000)
    notify_msg = await cmd.bot.send_message(message.channel, None, embed=embed)
    await asyncio.sleep(5)
    try:
        await cmd.bot.delete_message(notify_msg)
    except:
        pass
예제 #12
0
async def textmute(cmd, message, args):
    if not check_man_msg(message.author, message.channel):
        response = discord.Embed(title='⛔ Unpermitted. Manage Messages Permission Needed.', color=0xDB0000)
    else:
        if not message.mentions:
            response = discord.Embed(title='❗ No user targeted.', color=0xDB0000)
        else:
            target = message.mentions[0]
            if target.id != message.author.id or check_admin(target, message.channel):
                try:
                    mute_list = cmd.db.get_settings(message.guild.id, 'MutedUsers')
                except:
                    mute_list = []
                if target.id in mute_list:
                    response = discord.Embed(title='❗ User already muted.', color=0xDB0000)
                else:
                    mute_list.append(target.id)
                    cmd.db.set_settings(message.guild.id, 'MutedUsers', mute_list)
                    response = discord.Embed(color=0x66CC66,
                                             title=f'✅ {target.name}#{target.discriminator} has been text muted.')
                    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_embed = discord.Embed(color=0x696969, timestamp=arrow.utcnow().datetime)
                            log_embed.set_author(name='A Member Has Been Muted', icon_url=user_avatar(target))
                            log_embed.add_field(name='🔇 Muted User',
                                                value=f'{target.mention}\n{target.name}#{target.discriminator}',
                                                inline=True)
                            author = message.author
                            log_embed.add_field(name='🛡 Responsible',
                                                value=f'{author.mention}\n{author.name}#{author.discriminator}',
                                                inline=True)
                            if len(args) > 1:
                                log_embed.add_field(name='📄 Reason', value=f"```\n{' '.join(args[1:])}\n```", inline=False)
                            log_embed.set_footer(text=f'UserID: {target.id}')
                            await log_channel.send(embed=log_embed)
            else:
                response = discord.Embed(title='❗ You can\'t mute yourself.', color=0xDB0000)
    await message.channel.send(embed=response)
예제 #13
0
async def prune(cmd, message, args):
    channel = message.channel
    if check_man_msg(message.author, channel):
        limit = 100
        target = cmd.bot.user
        if not args:
            limit = 100
            target = cmd.bot.user
        if len(args) == 1 and message.mentions:
            limit = 100
            target = message.mentions[0]
        if len(args) > 1 and message.mentions:
            target = message.mentions[0]
            limit = abs(int(args[0]))
        if len(args) == 1 and not message.mentions:
            target = None
            limit = abs(int(args[0]))
        try:
            await message.delete()
        except:
            pass

        def author_check(msg):
            return msg.author.id == target.id

        if target:
            deleted = await message.channel.purge(limit=limit,
                                                  check=author_check)
        else:
            deleted = await message.channel.purge(limit=limit)
        embed = discord.Embed(color=0x66CC66,
                              title=f'✅ Deleted {len(deleted)} Messages')
        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:
                response = discord.Embed(color=0x696969,
                                         timestamp=arrow.utcnow().datetime)
                response.set_author(name=f'#{channel.name} Has Been Pruned',
                                    icon_url=user_avatar(message.author))
                if target:
                    target_text = f'{target.mention}'
                else:
                    target_text = 'No Filter'
                response.add_field(
                    name='🗑 Prune Details',
                    value=
                    f'Amount: {len(deleted)} Messages\nTarget: {target_text}',
                    inline=True)
                author = message.author
                response.add_field(
                    name='🛡 Responsible',
                    value=
                    f'{author.mention}\n{author.name}#{author.discriminator}',
                    inline=True)
                response.set_footer(text=f'ChannelID: {channel.id}')
                await log_channel.send(embed=response)
    else:
        embed = discord.Embed(
            title=
            '⚠ Unpermitted. Only Those With The Manage Message Permission Allowed.',
            color=0xDB0000)
    notify_msg = await message.channel.send(None, embed=embed)
    await asyncio.sleep(5)
    try:
        await notify_msg.delete()
    except:
        pass
예제 #14
0
async def warn(cmd, message, args):
    if not check_man_msg(message.author, message.channel):
        out_content = discord.Embed(
            color=0xDB0000,
            title='⛔ Users With Manage Messages Permissions Only.')
        await message.channel.send(None, embed=out_content)
        return
    if not args or not message.mentions:
        return
    target = message.mentions[0]
    warning_text = ' '.join(args).replace(target.mention, '')[1:]
    if not warning_text or warning_text == '':
        warning_text = 'No Reason Given'
    try:
        warned_users = cmd.db.get_settings(message.guild.id, 'WarnedUsers')
    except KeyError:
        cmd.db.set_settings(message.guild.id, 'WarnedUsers', {})
        warned_users = {}
    target_id = str(target.id)
    if target_id in warned_users:
        warn_data = {
            'UserID': warned_users[target_id]['UserID'],
            'Warns': warned_users[target_id]['Warns'] + 1,
            'Reasons': warned_users[target_id]['Reasons'] + [warning_text],
            'Timestamp': arrow.utcnow().timestamp
        }
    else:
        warn_data = {
            'UserID': target.id,
            'Warns': 1,
            'Reasons': [warning_text],
            'Timestamp': arrow.utcnow().timestamp
        }
    warned_users.update({target_id: warn_data})
    out_content_to_user = discord.Embed(color=0xFF9900)
    out_content_to_user.add_field(name=f'⚠ Warning on {message.guild.name}',
                                  value=f'Reason:\n```\n{warning_text}\n```')
    try:
        await target.send(None, embed=out_content_to_user)
    except:
        pass
    out_content_local = discord.Embed(
        color=0xFF9900, title=f'⚠ {target.name} has been warned.')
    await message.channel.send(None, embed=out_content_local)
    cmd.db.set_settings(message.guild.id, 'WarnedUsers', warned_users)
    # 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:
            response = discord.Embed(color=0xFF9900,
                                     timestamp=arrow.utcnow().datetime)
            response.set_author(name=f'A User Has Been Warned',
                                icon_url=user_avatar(target))
            response.add_field(
                name='⚠ Warned User',
                value=f'{target.mention}\n{target.name}#{target.discriminator}',
                inline=True)
            author = message.author
            response.add_field(
                name='🛡 Responsible',
                value=f'{author.mention}\n{author.name}#{author.discriminator}',
                inline=True)
            if warning_text:
                response.add_field(name='📄 Reason',
                                   value=f"```\n{warning_text}\n```",
                                   inline=False)
            response.set_footer(text=f'UserID: {target.id}')
            await log_channel.send(embed=response)