Skip to content

Commit

Permalink
Fix handling of unfetchable/unfindable guilds in guild info command
Browse files Browse the repository at this point in the history
  • Loading branch information
Iapetus-11 committed Jun 27, 2024
1 parent 532f06e commit 980e8cb
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
10 changes: 7 additions & 3 deletions bot/cogs/commands/useful.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,20 +477,24 @@ async def stats(self, ctx: Ctx):

@commands.command(name="serverinfo", aliases=["server", "guild", "guildinfo"])
@commands.guild_only()
async def server_info(self, ctx: Ctx, *, guild: discord.Guild | int = None):
async def server_info(self, ctx: Ctx, *, guild: int | discord.Guild | None = None):
with suppress(Exception):
await ctx.defer()

if isinstance(guild, int):
guild_id = guild
guild = self.bot.get_guild(guild)

if guild is None:
try:
guild = await self.bot.fetch_guild(guild)
guild = await self.bot.fetch_guild(guild_id)
except discord.HTTPException:
pass

if guild is None:
if guild is None:
await ctx.reply_embed(ctx.l.useful.ginf.not_found)
return
elif guild is None:
guild = ctx.guild

db_guild = await self.db.fetch_guild(guild.id)
Expand Down
3 changes: 2 additions & 1 deletion bot/data/text/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,8 @@
"cmd_prefix": "Prefix",
"lang": "Language",
"diff": "Difficulty",
"joined_at": "Joined"
"joined_at": "Joined",
"not_found": "Not Found"
},
"meth": {
"oops": "Oops, something went wrong..."
Expand Down
3 changes: 2 additions & 1 deletion bot/data/text/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,8 @@
"cmd_prefix": "Prefijo",
"lang": "Idioma",
"diff": "Dificultad",
"joined_at": "Unido"
"joined_at": "Unido",
"not_found": "No se ha encontrado"
},
"meth": {
"oops": "Oops, algo salió mal..."
Expand Down
3 changes: 2 additions & 1 deletion bot/data/text/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,8 @@
"cmd_prefix": "Préfixe",
"lang": "Langue",
"diff": "Difficulté",
"joined_at": "A Rejoint"
"joined_at": "A Rejoint",
"not_found": "Non trouvé"
},
"meth": {
"oops": "Oups, quelque chose a mal tourné ..."
Expand Down
3 changes: 2 additions & 1 deletion bot/data/text/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,8 @@
"cmd_prefix": "Prefixo",
"lang": "Idioma",
"diff": "Dificuldade",
"joined_at": "Juntou-se"
"joined_at": "Juntou-se",
"not_found": "Não encontrado"
},
"meth": {
"oops": "Oops, algo deu errado..."
Expand Down
1 change: 1 addition & 0 deletions bot/models/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ class Useful_Ginf(ImmutableBaseModel):
lang: str
diff: str
joined_at: str
not_found: str


class Useful_Meth(ImmutableBaseModel):
Expand Down

0 comments on commit 980e8cb

Please sign in to comment.