Beispiel #1
0
async def modstate(client, message, statecontent):
    if utils.check_admin_or_mod(message):
        await do_the_state(client, message, statecontent)
        return
    # if not right role
    author = message.author.name
    discrim = message.author.discriminator
    return f"{author}#{discrim} is not in the sudoers file. This incident will be reported."
Beispiel #2
0
async def unset_config(client, message, config=None):
    if check_admin_or_mod(message):
        return "You don't have permission to do that."

    if config not in CONFIG_OPTIONS:
        options = '\n'.join(CONFIG_OPTIONS.keys())
        return f"'{config}' isn't a valid configuration option. Valid options are: ```{options}```"
    CONFIG_STORE.del_val('s', message, config)
    return f":tada: Reset {config} to its default of {CONFIG_STORE.get_global(config)}"
Beispiel #3
0
async def remove_perm_role(client, message, permname=None, role=None):
    # Check that user has permissions to use this cmd
    if not check_admin_or_mod(message):
        return "You don't have permission to do that."
    roles = PERM_STORE.get_default('s', message.server, permname, [])
    roleid = get_or_extract_id(role)
    if roleid in roles:
        roles.remove(roleid)
    PERM_STORE.set_val('s', message, permname, roles)
    return f"Removed <@&{roleid}> from perm '{permname}.'"
Beispiel #4
0
async def unbind_role(client, message, keyword=None):
    if not check_admin_or_mod(message):
        return "You don't have permission to do that."
    keyword = keyword.strip()
    bindings = STORE.get_default('s', message.server, 'bindings', {})
    if keyword in bindings:
        roleid = bindings.pop(keyword)
        STORE.set_val('s', message, 'bindings', bindings)
        return f"Unbound <@&{roleid}> from '{keyword}'."
    return f"There's nothing bound to '{keyword}'."
Beispiel #5
0
async def add_perm_role(client, message, permname=None, role=None):
    # Check that user has permissions to use this cmd
    if not check_admin_or_mod(message):
        return "You don't have permission to do that."
    roles = PERM_STORE.get_default('s', message.server, permname, [])
    roleid = get_or_extract_id(role)
    roles.append(roleid)
    # remove duplicates
    roles = list(set(roles))
    PERM_STORE.set_val('s', message, permname, roles)
    return f"Added <@&{roleid}> to perm '{permname}'."
Beispiel #6
0
async def bind_role(client, message, role=None, keyword=None):
    if not check_admin_or_mod(message):
        return "You don't have permission to do that."

    bindings = STORE.get_default('s', message.server, 'bindings', {})
    keyword = keyword.strip()
    if len(keyword) == 0:
        return "Keywords need to not be empty."
    if keyword in bindings:
        return f"The keyword '{keyword}' is already bound to <@&{bindings[keyword]}>."
    # Bind role!
    roleid = get_or_extract_id(role)
    bindings[keyword] = roleid
    STORE.set_val('s', message, 'bindings', bindings)
    return f"Bound role <@&{roleid}> to '{keyword}'."
Beispiel #7
0
async def set_config(client, message, config=None, input=None):
    if not check_admin_or_mod(message):
        return "You don't have permission to do that."

    if config not in CONFIG_OPTIONS:
        options = '\n'.join(CONFIG_OPTIONS.keys())
        return f"'{config}' isn't a valid configuration option. Valid options are: ```{options}```"
    option = CONFIG_OPTIONS[config]

    if input is None:
        return option.desc.format(CONFIG_STORE.get_global(config))

    try:
        option.parse_and_set(message.server, input)
        return f"Set {config} to '{input}'."
    except TokenMismatch as e:
        return f"The provided value '{input}' isn't valid for {config} because: {str(e)}"
Beispiel #8
0
async def undesignate_pingchannel(client, message):
    if utils.check_admin_or_mod(message):
        unset_pingchannel(message)
        return 'Unset ping channel.'
    return 'Only a mod or admin can do that.'
Beispiel #9
0
async def designate_pingchannel(client, message):
    if utils.check_admin_or_mod(message):
        set_pingchannel(message)
        return 'Set this channel to put message pings in.'
    return 'Only a mod or admin can do that.'