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."
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)}"
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}.'"
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}'."
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}'."
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}'."
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)}"
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.'
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.'