Beispiel #1
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 = 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)
Beispiel #2
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)
async def announcementchannel(cmd, message, args):
    if not check_admin(message.author, message.channel):
        # user is no server admin
        embed = discord.Embed(title='⛔ Unpermitted. Server Admin Only.', color=0xDB0000)
    else:
        if message.channel_mentions:
            # argument exists and is a channel
            newchannel = message.channel_mentions[0]
            if check_write(message.server.get_member(cmd.bot.user.id), newchannel):
                # channel can be written to -> turn on announcements and set channelid
                cmd.db.set_settings(message.server.id, 'Announcement', True)
                cmd.db.set_settings(message.server.id, 'AnnouncementChannel', newchannel.id)
                embed = discord.Embed(
                    title='✅ Announcements will be posted to #' + newchannel.name, color=0x66CC66)
            else:
                embed = discord.Embed(title='⛔ Missing write permissions for this channel', color=0xDB0000)
        else:
            if len(args) == 0:
                # no argument given, announcements will be turned off
                cmd.db.set_settings(message.server.id, 'Announcement', False)
                embed = discord.Embed(title='✅ Announcements turned OFF for this server',
                                      color=0x66CC66)
                embed.add_field(name='Note:',
                                value='Use "' + Prefix + 'announcementchannel #channel_name" to turn them back on.')
            else:
                # given argument is not a channel
                embed = discord.Embed(title=':x: "' + args[0] + '" is not a channel', color=0xDB0000)
                embed.add_field(name='Note:',
                                value='Enter a channel in this format: "#channel_name" or leave blank to turn announcements off.')
    await cmd.bot.send_message(message.channel, None, embed=embed)
Beispiel #4
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)
Beispiel #5
0
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)