Fixed /config show, added /event show, added stubs for /stage and /guess
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
from typing import List
|
||||
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError, available_timezones
|
||||
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
|
||||
|
||||
from discord import (
|
||||
ApplicationContext,
|
||||
@@ -7,25 +6,13 @@ from discord import (
|
||||
SlashCommandGroup,
|
||||
TextChannel,
|
||||
option,
|
||||
AutocompleteContext,
|
||||
)
|
||||
from discord.ext.commands import Cog
|
||||
from discord.utils import basic_autocomplete
|
||||
|
||||
from classes import PycordGuild
|
||||
from classes.pycord_bot import PycordBot
|
||||
|
||||
|
||||
# TODO Move to staticmethod or to a separate module
|
||||
async def get_timezones(ctx: AutocompleteContext) -> List[str]:
|
||||
return sorted(list(available_timezones()))
|
||||
|
||||
|
||||
# TODO Move to staticmethod or to a separate module
|
||||
async def get_languages(ctx: AutocompleteContext) -> List[str]:
|
||||
# TODO Discord normally uses a different set of locales.
|
||||
# For example, "en" being "en-US", etc. This will require changes to locale handling later.
|
||||
return ctx.bot.locales.keys()
|
||||
from modules.utils import autofill_timezones, autofill_languages
|
||||
|
||||
|
||||
class Config(Cog):
|
||||
@@ -47,13 +34,13 @@ class Config(Cog):
|
||||
@option(
|
||||
"timezone",
|
||||
description="Timezone in which events take place",
|
||||
autocomplete=basic_autocomplete(get_timezones),
|
||||
autocomplete=basic_autocomplete(autofill_timezones),
|
||||
required=True,
|
||||
)
|
||||
@option(
|
||||
"language",
|
||||
description="Language for bot's messages",
|
||||
autocomplete=basic_autocomplete(get_languages),
|
||||
autocomplete=basic_autocomplete(autofill_languages),
|
||||
required=True,
|
||||
)
|
||||
async def command_config_set(
|
||||
@@ -107,12 +94,12 @@ class Config(Cog):
|
||||
name="show",
|
||||
description="Show the guild's configuration",
|
||||
)
|
||||
async def command_config_reset(self, ctx: ApplicationContext) -> None:
|
||||
async def command_config_show(self, ctx: ApplicationContext) -> None:
|
||||
guild: PycordGuild = await self.bot.find_guild(ctx.guild.id)
|
||||
|
||||
# TODO Make a nice message
|
||||
await ctx.respond(
|
||||
f"**Guild config**\n\nChannel: <#{guild.channel_id}>\nCategory: <#{guild.category_id}>"
|
||||
f"**Guild config**\n\nChannel: <#{guild.channel_id}>\nCategory: <#{guild.category_id}>\nTimezone: {guild.timezone}\nLanguage: {guild.language}"
|
||||
)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user