async def get_spell_choices(ctx, filter_by_license=True, homebrew=True): """ Gets a list of spells in the current context for the user to choose from. :param ctx: The context. :param filter_by_license: Whether to filter out entities the user cannot access. :param homebrew: Whether to include homebrew entities. """ if filter_by_license: available_spells = await available(ctx, compendium.spells, 'spell') else: available_spells = compendium.spells if not homebrew: return available_spells # personal active tome try: tome = await Tome.from_ctx(ctx) custom_spells = tome.spells tome_id = tome.id except NoActiveBrew: custom_spells = [] tome_id = None # server tomes choices = list(itertools.chain(available_spells, custom_spells)) if ctx.guild: async for servtome in Tome.server_active(ctx): if servtome.id != tome_id: choices.extend(servtome.spells) return choices
async def tome_server_list(self, ctx): """Shows what tomes are currently active on the server.""" desc = "" async for tome in Tome.server_active(ctx, meta_only=True): desc += f"{tome['name']} (<@{tome['owner']}>)\n" await ctx.send( embed=discord.Embed(title="Active Server Tomes", description=desc))
async def tome_server_remove(self, ctx, tome_name): """Removes a server tome.""" tome_metas = [t async for t in Tome.server_active(ctx, meta_only=True)] tome_meta = await search_and_select(ctx, tome_metas, tome_name, lambda b: b['name']) tome = await Tome.from_id(ctx, tome_meta['_id']) await tome.toggle_server_active(ctx) await ctx.send(f"Ok, {tome.name} is no longer active on {ctx.guild.name}.")
async def get_spell_choices(ctx): try: tome = await Tome.from_ctx(ctx) custom_spells = tome.spells tome_id = tome.id except NoActiveBrew: custom_spells = [] tome_id = None choices = list(itertools.chain(compendium.spells, custom_spells)) if ctx.guild: async for servtome in Tome.server_active(ctx): if servtome.id != tome_id: choices.extend(servtome.spells) return choices
async def tome_list(self, ctx): """Lists your available tomes.""" available_tome_names = Tome.user_visible(ctx, meta_only=True) await ctx.send( f"Your available tomes: {', '.join([p['name'] async for p in available_tome_names])}" )