async def view(self, CommandArgs): """view your server settings""" guild = CommandArgs.guild guild_data = CommandArgs.guild_data response = CommandArgs.response trello_board = CommandArgs.trello_board prefix = CommandArgs.prefix embed = Embed(title="Bloxlink Settings") text_buffer = [] options_trello_data = {} donator_profile, _ = await get_features(Object(id=guild.owner_id), guild=guild) premium = donator_profile.features.get("premium") if premium: text_buffer.append( "**This is a [Premium Server](https://www.patreon.com/join/bloxlink?)**\n" ) embed.colour = GOLD_COLOR if trello_board: options_trello_data, _ = await get_options(trello_board) guild_data.update(options_trello_data) for option_name, option_data in OPTIONS.items(): value = None if option_data[0]: value = str(option_data[0](guild, guild_data)) # pylint: disable=not-callable else: try: value = str( guild_data.get(option_name, DEFAULTS.get(option_name, "False"))) except KeyError: value = str( guild_data.get(option_name, DEFAULTS.get(option_name, "False"))) if option_data[3] and not premium: value = str(DEFAULTS.get(option_name, "False")) value = value.replace("{prefix}", prefix) text_buffer.append(f"**{option_name}** {ARROW} {value}") embed.description = "\n".join(text_buffer) embed.set_footer(text="Powered by Bloxlink", icon_url=Bloxlink.user.avatar.url) embed.set_author(name=guild.name, icon_url=guild.icon.url if guild.icon else "") await response.send(embed=embed)
async def help(self, CommandArgs): """provides a description of all changeable settings""" guild = CommandArgs.message.guild embed = Embed(title="Bloxlink Settings Help") embed.set_footer(text="Powered by Bloxlink", icon_url=Bloxlink.user.avatar_url) embed.set_author(name=guild.name, icon_url=guild.icon_url) for option_name, option_data in OPTIONS.items(): desc = option_data[4].format(prefix=CommandArgs.prefix, templates=NICKNAME_TEMPLATES) embed.add_field(name=option_name, value=desc, inline=False) await CommandArgs.response.send(embed=embed)
from os import environ as env from discord.errors import Forbidden from aiotrello.exceptions import TrelloUnauthorized, TrelloNotFound, TrelloBadRequest get_prefix, post_event = Bloxlink.get_module("utils", attrs=["get_prefix", "post_event"]) get_options = Bloxlink.get_module("trello", attrs=["get_options"]) parse_message = Bloxlink.get_module("commands", attrs=["parse_message"]) clear_guild_data, set_guild_value = Bloxlink.get_module("cache", attrs=["clear_guild_data", "set_guild_value"]) get_features = Bloxlink.get_module("premium", attrs=["get_features"]) RESET_CHOICES = ("everything", "binds") options_keys = [o for o, o_d in OPTIONS.items() if not o_d[3]] premium_option_keys = [o for o, o_d in OPTIONS.items() if o_d[3]] options_combined = options_keys + premium_option_keys options_strings = ", ".join([o for o, o_d in OPTIONS.items() if not o_d[3]]) premium_options_strings = ", ".join([o for o, o_d in OPTIONS.items() if o_d[3]]) @Bloxlink.command class SettingsCommand(Bloxlink.Module): """change, view, or reset your Bloxlink settings""" def __init__(self): permission = Bloxlink.Permissions().build("BLOXLINK_MANAGER") permission.allow_bypass = True self.permissions = permission self.category = "Administration"