mirror of
https://github.com/UiO-Gaming/ShiteMusicBot.git
synced 2026-11-06 14:24:30 +01:00
Added command for setting server localization and a command for reloading localization files
This commit is contained in:
1 parent
a0a8c96ab4
commit
c9869d9bbe
4 files changed
+22
-2
No files matched your search
@@ -17,6 +17,13 @@ class BotSettings:
|
||||
await ctx.invoke(self.bot.get_command('help'),
|
||||
ctx.command.qualified_name)
|
||||
|
||||
@commands.guild_only()
|
||||
@_set.command(name='serverlocale')
|
||||
async def _set_guild_locale(self, ctx, locale):
|
||||
self.settings.set_locale(ctx.guild.id, locale)
|
||||
locale = self.settings.get_locale(ctx.guild.id)
|
||||
await ctx.send(f'Locale set to {locale}')
|
||||
|
||||
@commands.guild_only()
|
||||
@_set.command(name='serverprefix')
|
||||
async def _set_guild_prefix(self, ctx, *prefixes):
|
||||
|
||||
@@ -41,6 +41,13 @@ class Misc:
|
||||
guilds += f"{guild.name}\n"
|
||||
await ctx.send(guilds)
|
||||
|
||||
|
||||
@commands.command(name="reloadlocale")
|
||||
async def reload_locale(self, ctx):
|
||||
self.bot.localizer.index_localizations()
|
||||
self.bot.localizer.load_localizations()
|
||||
await ctx.send("Localizations reloaded.")
|
||||
|
||||
@commands.command()
|
||||
async def info(self, ctx):
|
||||
"""
|
||||
|
||||
@@ -37,7 +37,7 @@ def is_even():
|
||||
def is_owner():
|
||||
def predicate(ctx):
|
||||
is_owner = (ctx.message.author.id == 120970603556503552 or
|
||||
ctx.message.author.id == 142212883512557569)
|
||||
ctx.message.author.id == 142212883512557569 or ctx.message.author.id == 212635519706726410)
|
||||
return is_owner
|
||||
return commands.check(predicate)
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class Settings:
|
||||
|
||||
if not os.path.isfile(self.SETTINGS_PATH):
|
||||
with codecs.open(self.SETTINGS_PATH, "w+", encoding='utf8') as f:
|
||||
json.dump({"prefixes": {},
|
||||
json.dump({"locale": {}, "prefixes": {},
|
||||
"roles": {}}, f, indent=4)
|
||||
|
||||
with codecs.open(self.SETTINGS_PATH, "r", encoding='utf8') as f:
|
||||
@@ -67,6 +67,12 @@ class Settings:
|
||||
with codecs.open(self.SETTINGS_PATH, "w", encoding='utf8') as f:
|
||||
json.dump(self.settings, f, indent=4)
|
||||
|
||||
def set_locale(self, guild_id, locale):
|
||||
guild_id = str(guild_id)
|
||||
self.settings["locale"][guild_id] = locale
|
||||
with codecs.open(self.SETTINGS_PATH, "w", encoding='utf8') as f:
|
||||
json.dump(self.settings, f, indent=4)
|
||||
|
||||
def get_locale(self, guild_id):
|
||||
guild_id = str(guild_id)
|
||||
return self.settings.get("locale", {}).get(guild_id, self.default_locale).lower()
|
||||
|
||||
Reference in new issue
Block a user