Introduced i18n for /event, /guess, /register and /unregister. Prepared other commands for i18n too
This commit is contained in:
@@ -3,6 +3,7 @@ from typing import List
|
||||
from bson import ObjectId
|
||||
from bson.errors import InvalidId
|
||||
from discord import ApplicationContext, Cog, File, option, slash_command
|
||||
from libbot.i18n import _, in_every_locale
|
||||
|
||||
from classes import PycordEvent, PycordEventStage, PycordGuild, PycordUser
|
||||
from classes.pycord_bot import PycordBot
|
||||
@@ -14,12 +15,16 @@ class CogGuess(Cog):
|
||||
def __init__(self, bot: PycordBot):
|
||||
self.bot: PycordBot = bot
|
||||
|
||||
# TODO Implement the command
|
||||
@slash_command(
|
||||
name="guess",
|
||||
description="Propose an answer to the current event stage",
|
||||
description=_("description", "commands", "guess"),
|
||||
description_localizations=in_every_locale("description", "commands", "guess"),
|
||||
)
|
||||
@option(
|
||||
"answer",
|
||||
description=_("description", "commands", "guess", "options", "answer"),
|
||||
description_localizations=in_every_locale("description", "commands", "guess", "options", "answer"),
|
||||
)
|
||||
@option("answer", description="An answer to the current stage")
|
||||
async def command_guess(self, ctx: ApplicationContext, answer: str) -> None:
|
||||
guild: PycordGuild = await self.bot.find_guild(ctx.guild.id)
|
||||
|
||||
@@ -31,7 +36,9 @@ class CogGuess(Cog):
|
||||
|
||||
if user.is_jailed:
|
||||
# TODO Make a nice message
|
||||
await ctx.respond("You are jailed and cannot interact with events. Please, contact the administrator.")
|
||||
await ctx.respond(
|
||||
"You are jailed and cannot interact with events. Please, contact the administrator."
|
||||
)
|
||||
return
|
||||
|
||||
if user.current_event_id is None or user.current_stage_id is None:
|
||||
@@ -44,7 +51,9 @@ class CogGuess(Cog):
|
||||
stage: PycordEventStage = await self.bot.find_event_stage(user.current_stage_id)
|
||||
except (InvalidId, RuntimeError):
|
||||
# TODO Make a nice message
|
||||
await ctx.respond("Your event could not be found. Please, report this issue to the event's management.")
|
||||
await ctx.respond(
|
||||
"Your event could not be found. Please, report this issue to the event's management."
|
||||
)
|
||||
return
|
||||
|
||||
if ctx.channel_id != user.event_channels[str(event._id)]:
|
||||
|
Reference in New Issue
Block a user