Example #1
0
async def run(**env):
    for _, a in enumerate(env):
        globals().update({a: env.get(a)})

    fetched = db.fetch(roles, {'guild': g.id})

    if fetched:
        row = fetched.fetchone()
        if row.id == role.id:
            return await c.send('This role is already the muted role.')

        try:
            db.update(roles, {'guild': g.id}, {'id': args[0]})
            for x in g.categories:
                await x.edit(
                    overwrites={
                        role:
                        discord.PermissionOverwrite(send_messages=False,
                                                    add_reactions=False)
                    })
            return await c.send(
                f'Successfully set muted role to {role.mention}.')
        except Exception as e:
            print(e)
            await c.send(f'Error while setting muted role:\n{e}')
    else:
        try:
            db.insert(roles, {'id': args[0], 'guild': g.id})

            return await c.send(
                f'Successfully set muted role to {role.mention}.')
        except Exception as e:
            print(e)
            return await c.send(f'Error while setting muted role:\n{e}')
Example #2
0
async def on_message(msg):
    # ignore bots
    if msg.author.bot:
        return
    # the actual arguments
    args = msg.content[len(auth.prefix):].strip().split(' ')

    # get the command
    cmd = args.pop(0).lower()

    # used for shortening code
    c = msg.channel
    g = msg.guild
    m = msg.author
    try:
        conf = db.fetch(server_config, {'guild': g.id}).fetchone()
    except AttributeError:
        db.insert(server_config, {'guild': g.id})
    # extremely inefficient system but idgaf
    if not 'tag' in cmd:
        if (tagss := db.fetch(tags, {'guild': msg.guild.id})):
            tagls = tagss.fetchall()
            if not conf.tag_require_command:
                if conf.tag_search_all:
                    found = [x.content for x in [x for x in tagls if msg.content.find(x.name) != -1]]
                else:
                    found = [x.content for x in [x for x in tagls if msg.content == x.name]]
                if len(found) > 0:
                    return await msg.channel.send(found[0])
Example #3
0
async def run(**env):
    for _, a in enumerate(env):
        globals().update({a: env.get(a)})

    # checks the muted role
    result = db.fetch(roles, {'guild': g.id})
    if not result:
        return await c.send(
            'No muted role is set! Please set one with `setmuted`.')

    role = result.fetchone()
    muted_role = g.get_role(role.id)

    if g.me.top_role < muted_role:
        return await c.send(
            'I am at a lower level on the hierarchy than the muted role.')

    try:
        await checks.roles(m, mem, g, c)
    except:
        return

    # makes sure they aren't already muted
    if muted_role in mem.roles:
        return await c.send('That member is already muted.')

    try:
        # add the muted role to the member
        await mem.add_roles(muted_role, reason=reason)
        db.insert(mems, {
            'id': mem.id,
            'guild': g.id,
            'unmute_after': get_future(time)
        })
        await c.send(
            f'Successfully muted {mem} for {time} hours. Reason: {reason}')
        if conf.mute_dm:
            try:
                await mem.send(
                    conf.mute_dm_message.format(MEM=mem,
                                                GUILD=g,
                                                MOD=m,
                                                TIME=time,
                                                REASON=reason))
            except:
                pass
    except Exception as e:
        await c.send(f'Error while muting member: {e}')
Example #4
0
async def run(**env):
    for _, a in enumerate(env):
        globals().update({a: env.get(a)})

    if not conf.allow_all_addtag:
        try:
            await checks.perms(['manage_guild'], g, c, m)
        except:
            return

    tagname = args[0]
    #tagcont = ' '.join(args[1:len(args)])
    now = datetime.now()

    # basically, this code just adds the tag to a SQL table
    try:
        db.insert(tags,
            {'name': tagname, 'content': tagcont, 'creatortag': str(m),
            'creatorid': m.id, 'createdat': f'{now.month}/{now.day}/{now.year}, '\
            f'at {now.hour}:{now.minute}', 'guild': g.id})
        return await c.send(
            f'Successfully added tag {tagname}, with content:\n{tagcont}')
    except Exception as e:
        await c.send(f'Error while adding tag:\n{e}')
Example #5
0
async def on_guild_join(g):
    try:
        db.insert(server_config, {'guild': g.id})
    except:
        pass