fix(core:i18n): fix crash for DMs

This commit is contained in:
Romain J 2021-05-13 16:44:18 +02:00
parent ba21cf859b
commit f00ff8d345
3 changed files with 5 additions and 50 deletions

View file

@ -1,24 +0,0 @@
import tortoise
from tortoise import fields
class Alias(tortoise.Model):
id = fields.BigIntField(pk=True)
user_id = fields.BigIntField()
alias = fields.TextField(max_length=255)
command = fields.TextField(max_length=255)
guild = fields.BigIntField()
class Meta:
table = "aliases"
def __str__(self):
return (
f"<Alias id={self.id} "
f"user_id={self.user_id} "
f"alias='{self.alias}' "
f"command='{self.command}' "
f"guild={self.guild}>"
)
__repr__ = __str__

View file

@ -1,24 +0,0 @@
import tortoise
from tortoise import fields
class Warn(tortoise.Model):
id = fields.BigIntField(pk=True)
server_id = fields.BigIntField()
user_id = fields.BigIntField()
reason = fields.TextField(max_length=255)
created_at = fields.DatetimeField()
class Meta:
table = "warns"
def __str__(self):
return (
f"<Warn id={self.id} "
f"server_id={self.server_id} "
f"user_id={self.user_id} "
f"reason='{self.reason}' "
f"created_at={self.created_at}>"
)
__repr__ = __str__

View file

@ -75,9 +75,12 @@ class Translator:
if user_locale: if user_locale:
return self.translations[user_locale][untranslated] return self.translations[user_locale][untranslated]
guild_locale = search_for( guild_locale = (
config.Servers, ctx.guild.id, "locale", None search_for(config.Servers, ctx.guild.id, "locale", None)
if ctx.guild
else None
) )
if guild_locale: if guild_locale:
return self.translations[guild_locale][untranslated] return self.translations[guild_locale][untranslated]