Skip to content

Commit

Permalink
feat(axo): better migration support
Browse files Browse the repository at this point in the history
  • Loading branch information
ZRunner committed Dec 15, 2022
1 parent 59d8d2d commit 753ccae
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion fcts/languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,16 @@ async def tr(self, source: SourceType, string_id: str, **args):
else:
used_langs = await self.bot.get_cog('Utilities').get_languages(recipient, limit=1)
lang_opt = used_langs[0][0] if len(used_langs) > 0 else self.default_language
else:
elif isinstance(source, int):
# get lang from server ID
lang_id = await self.bot.get_config(source, "language")
if lang_id is None:
lang_opt = self.default_language
else:
lang_opt = self.languages[lang_id]
self.serv_opts[source] = lang_opt
else:
raise TypeError(f"Unknown type for translation source: {type(source)}")
if lang_opt not in self.languages:
# if lang not known: fallback to default
lang_opt = self.default_language
Expand Down
3 changes: 3 additions & 0 deletions fcts/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ async def global_check(self, ctx: MyContext):
return True
return False
if await self.bot.check_axobot_presence(ctx=ctx):
if ctx.prefix.strip() == self.bot.user.mention:
invite = 'http://discord.gg/N55zY88'
await ctx.send(await self.bot._(ctx.guild.id, "errors.zbot-migration", invite=invite))
return False
if not isinstance(ctx, commands.Context) or self.config is None:
return True
Expand Down
3 changes: 2 additions & 1 deletion lang/errors/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@
"rolenotfound": "Unable to find the role `%{r}`",
"toomanytxtchan": "You have too many accessible text channels",
"unknown": "Oops, an error occurred :confused: Try again later, or contact support (command `about`).",
"usernotfound": "Unable to find the user `%{u}` :confused:"
"usernotfound": "Unable to find the user `%{u}` :confused:",
"zbot-migration": "This server now use Axobot, the new identity of Zbot. If you need help with the migration, don't hesitate to ask us at <%{invite}>!"
}
3 changes: 2 additions & 1 deletion lang/errors/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@
"rolenotfound": "Impossible de trouver le rôle `%{r}`",
"toomanytxtchan": "Vous avez trop de salons textuels accessibles",
"unknown": "Oups, une erreur est survenue :confused: Réessayez plus tard, ou contactez le support (commande `about`).",
"usernotfound": "Impossible de trouver l'utilisateur `%{u}` :confused:"
"usernotfound": "Impossible de trouver l'utilisateur `%{u}` :confused:",
"zbot-migration": "Ce serveur utilise désormais Axobot, la nouvelle identité de Zbot. Si vous avez besoin d'aide pour la migration, n'hésitez pas à nous demander à <%{invite}> !"
}

0 comments on commit 753ccae

Please sign in to comment.