async def status_default(self, ctx, ip_port=None): """ Set the default server/server alias for the status command [e.g. 0.0.0.0:19132] To ping all aliases set to [all] """ with GuildConfig(ctx.guild.id) as guildconfig: if ip_port is None: ip_port = guildconfig['status']['default'] else: guildconfig['status']['default'] = ip_port try: alias_value = guildconfig['status']['aliases'][ip_port] except: alias_value = None if ip_port == 'all': await ctx.send( '`status` command will ping all aliases by default\nRun `status_aliases` to get a list of them' ) elif alias_value is not None: await ctx.send( f'`status` command will ping {ip_port} ({alias_value}) by default' ) else: await ctx.send(f'`status` command will ping {ip_port} by default')
async def groups_add(self, ctx, role, group=None): """Add a role to a group""" # Check if role exists roleid = None for r in ctx.guild.roles: if role == r.name: roleid = r.id break if roleid == None: await ctx.send( f'`{role}` role for {ctx.guild.name} cannot be found') return role = role.lower() group = group.lower() if group is not None else None with GuildConfig(ctx.guild.id) as guildconfig: # Add roleid to guild config dictionary if not already if role not in guildconfig['roles']: guildconfig['roles'].update({role: roleid}) if group is None: return if role in guildconfig['group'][group]: await ctx.send(f'`{role}` role is already in {group}') return guildconfig['group'][group].append(role) await ctx.send(f'Added `{role}` role as {group}')
async def _updates_off(self, ctx, branch: str = 'all'): """Disable MCBE updates for a channel""" branch = branch.lower() with GuildConfig(ctx.guild.id) as guildconfig: # Get guild's update channel dictionary update_channels = guildconfig['updates'] all_branches = list(update_channels.keys()) # Default to all update branches # Check [branch] argument if branch == 'all': setlist = all_branches elif branch in all_branches: setlist = [branch] else: valid = ', '.join(all_branches) await ctx.send( f'`{branch}` is not a valid update branch: {valid}') for _branch in setlist: guildconfig['updates'][_branch] = None await ctx.send(f'Disabled receiving {branch} updates')
async def _updates_set(self, ctx, channel: Optional[TextChannel] = None, branch: str = 'all'): """Enable MCBE updates for a channel""" # Defaults to current channel if channel is None: channel = ctx.channel branch = branch.lower() with GuildConfig(ctx.guild.id) as guildconfig: # Get guild's update channel dictionary update_channels = guildconfig['updates'] all_branches = list(update_channels.keys()) # Default to all update branches # Check [branch] argument if branch == 'all': setlist = all_branches elif branch in all_branches: setlist = [branch] else: valid = ', '.join(all_branches) await ctx.send( f'`{branch}` is not a valid update branch: {valid}') for _branch in setlist: guildconfig['updates'][_branch] = channel.id await ctx.send(f'Channel for {branch} updates set to {channel.mention}' )
async def status_alias_remove(self, ctx, alias): """Remove a server alias for the status command""" with GuildConfig(ctx.guild.id) as guildconfig: if alias not in guildconfig['status']['aliases']: await ctx.send(f'`{alias}` is not a status alias') return del guildconfig['status']['aliases'][alias] await ctx.send(f'Removed `{alias}` as a status alias')
async def status_alias_add(self, ctx, alias, ip_port): """ Add a server alias for the status command [e.g. 0.0.0.0:19132] """ with GuildConfig(ctx.guild.id) as guildconfig: try: guildconfig['status']['aliases'].update({alias: ip_port}) except: guildconfig['status']['aliases'] = {alias: ip_port} await ctx.send(f'Added `{alias}` as a status alias')
async def groups_remove(self, ctx, role, group): """Remove a role from a group""" role = role.lower() group = group.lower() with GuildConfig(ctx.guild.id) as guildconfig: if role not in guildconfig['group'][group]: await ctx.send(f'`{role}` role is not in {group}') return if role == 'admin': await ctx.send(f'Cannot remove Admin role') return guildconfig['group'][group].remove(role) await ctx.send(f'Removed `{role}` role as {group}')
async def _set_prefix(self, ctx, prefix: str): """Set prefix for TRB""" with GuildConfig(ctx.guild.id) as guildconfig: guildconfig['prefix'] = prefix await ctx.send(f'Set `{prefix}` as the TRB prefix')
async def toggle_memes(self, ctx): """Toggle 'Welcome to BE' listener""" with GuildConfig(ctx.guild.id) as guildconfig: memes = not guildconfig['toggle']['memes'] guildconfig['toggle']['memes'] = memes await ctx.send(f'`Welcome to BE` set to {memes}')