async def reset(self, ctx: Context, to_defaults: bool = False): """ Reset all drinks to defaults. Barman role required. """ Drink.delete().where(Drink.server == ctx.guild.id).execute() if to_defaults: await add_default_drinks(ctx.guild)
async def lang(self, ctx: Context, lang_code: str = None): """ If lang is provided, sets the language. Requires Manage Guild permission. Return the list of available languages and quick reminder how to set it. """ if lang_code: if lang_code not in get_langs(): await ctx.send(conf.international("incorrect_language")) else: logger.info("Updated lang on {0} to {1}".format( ctx.guild.id, lang_code)) with db.atomic(): server = get_server_or_create(ctx.guild.id, ctx.guild.preferred_locale) Server.update(lang=lang_code).where( Server.sid == ctx.guild.id).execute() Drink.delete().where(Drink.server == server.id).execute() await add_default_drinks(ctx.guild) await ctx.send(conf.lang(lang_code, "lang_selected")) else: langs = "\n".join( "{0}, lang_code \"{1}\"".format(conf.lang(lang, "name"), lang) for lang in conf.get_langs()) await ctx.send( conf.international("lang_list").format(self.bot.command_prefix) + '\n' + langs)
async def on_guild_remove(self, guild): log.info("Removing guild {0}".format(guild.id)) server = get_server_or_create(guild.id, guild.preferred_locale) with db.atomic(): Drink.delete().where(Drink.server == server).execute() Person.delete().where(Person.server == server).execute() server.delete_instance() return True
async def reset(self, ctx: Context, to_defaults: bool = False): """ Reset all drinks to defaults. Barman role required. """ server = get_server_from_context(ctx) lang = server.lang Drink.delete().where(Drink.server == server).execute() if to_defaults: await add_default_drinks(ctx.guild) await ctx.send(conf.lang(lang, "reset_to_defaults_complete")) else: await ctx.send(conf.lang(lang, "reset_complete"))