Introduced prefer_emojis for PycordGuild

This commit is contained in:
2025-05-03 00:55:13 +02:00
parent aa2f90e1c5
commit 2d9bf1cfb9
4 changed files with 32 additions and 5 deletions

View File

@@ -26,6 +26,7 @@ class PycordGuild:
channel_id: int | None
category_id: int | None
timezone: str
prefer_emojis: bool
@classmethod
async def from_id(
@@ -145,6 +146,7 @@ class PycordGuild:
"channel_id": self.channel_id,
"category_id": self.category_id,
"timezone": self.timezone,
"prefer_emojis": self.prefer_emojis,
}
# TODO Add documentation
@@ -155,6 +157,7 @@ class PycordGuild:
"channel_id": None,
"category_id": None,
"timezone": "UTC",
"prefer_emojis": False,
}
@staticmethod

View File

@@ -43,7 +43,14 @@ class CogConfig(Cog):
),
required=True,
)
@option("channel", description="Text channel for admin notifications", required=True)
@option(
"channel",
description=_("description", "commands", "config_set", "options", "channel"),
description_localizations=in_every_locale(
"description", "commands", "config_set", "options", "channel"
),
required=True,
)
@option(
"timezone",
description=_("description", "commands", "config_set", "options", "timezone"),
@@ -53,12 +60,21 @@ class CogConfig(Cog):
autocomplete=basic_autocomplete(autocomplete_timezones),
required=True,
)
@option(
"prefer_emojis",
description=_("description", "commands", "config_set", "options", "prefer_emojis"),
description_localizations=in_every_locale(
"description", "commands", "config_set", "options", "prefer_emojis"
),
required=True,
)
async def command_config_set(
self,
ctx: ApplicationContext,
category: CategoryChannel,
channel: TextChannel,
timezone: str,
prefer_emojis: bool,
) -> None:
try:
guild: PycordGuild = await self.bot.find_guild(ctx.guild.id)
@@ -79,6 +95,7 @@ class CogConfig(Cog):
channel_id=channel.id,
category_id=category.id,
timezone=str(timezone_parsed),
prefer_emojis=prefer_emojis,
)
await ctx.respond(self.bot._("config_set", "messages", locale=ctx.locale))
@@ -131,6 +148,7 @@ class CogConfig(Cog):
channel_id=guild.channel_id,
category_id=guild.category_id,
timezone=guild.timezone,
prefer_emojis=guild.prefer_emojis,
)
)

View File

@@ -65,9 +65,11 @@ class CogGuess(Cog):
return
if answer.lower() != stage.answer.lower():
# TODO Make a nice message
# await ctx.respond("Provided answer is wrong.")
await ctx.respond(self.bot.config["emojis"]["guess_wrong"])
await ctx.respond(
self.bot.config["emojis"]["guess_wrong"]
if guild.prefer_emojis
else self.bot._("guess_incorrect", "messages", locale=ctx.locale)
)
return
next_stage_index = stage.sequence + 1

View File

@@ -6,7 +6,7 @@
"admin_user_completed_stage": "User **{display_name}** ({mention}) has completed the stage {stage_sequence} of the event **{event_name}**.",
"config_reset": "Configuration has been reset. You can update it using `/config set`, otherwise no events can be held.",
"config_set": "Configuration has been updated. You can review it anytime using `/config show`.",
"config_show": "**Guild config**\n\nChannel: <#{channel_id}>\nCategory: <#{category_id}>\nTimezone: `{timezone}`",
"config_show": "**Guild config**\n\nChannel: <#{channel_id}>\nCategory: <#{category_id}>\nTimezone: `{timezone}`\nPrefer emojis: `{prefer_emojis}`",
"event_cancelled": "Event **{event_name}** was cancelled.",
"event_created": "Event **{event_name}** has been created and will take place <t:{start_time}:R>.",
"event_dates_parsing_failed": "Could not parse start and end dates. Please, make sure these are provided in `DD.MM.YYYY HH:MM` format.",
@@ -23,6 +23,7 @@
"event_start_past": "Start date must not be in the past",
"event_updated": "Event **{event_name}** has been updated and will take place <t:{start_time}:R>.",
"guess_completed_event": "Congratulations! You have completed the event!",
"guess_incorrect": "Provided answer is wrong.",
"guess_incorrect_channel": "Usage outside own event channel is not allowed.",
"guess_incorrect_event": "Your event could not be found. Please, contact the administrator.",
"guess_unregistered": "You have no ongoing events. You can register for events using the `/register` command.",
@@ -67,6 +68,9 @@
},
"timezone": {
"description": "Timezone in which events take place"
},
"prefer_emojis": {
"description": "Prefer emojis over text messages where available"
}
}
},