Implemented /event add
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
|
||||
|
||||
from discord import (
|
||||
ApplicationContext,
|
||||
CategoryChannel,
|
||||
@@ -27,13 +29,21 @@ class Config(Cog):
|
||||
)
|
||||
@option("category", description="Category where channels for each user will be created", required=True)
|
||||
@option("channel", description="Text channel for admin notifications", required=True)
|
||||
@option("timezone", description="Timezone in which events take place", required=True)
|
||||
async def command_config_set(
|
||||
self, ctx: ApplicationContext, category: CategoryChannel, channel: TextChannel
|
||||
self, ctx: ApplicationContext, category: CategoryChannel, channel: TextChannel, timezone: str
|
||||
) -> None:
|
||||
guild: PycordGuild = await self.bot.find_guild(ctx.guild.id)
|
||||
|
||||
try:
|
||||
timezone_parsed: ZoneInfo = ZoneInfo(timezone)
|
||||
except ZoneInfoNotFoundError:
|
||||
await ctx.respond(f"Timezone {timezone} was not found.")
|
||||
return
|
||||
|
||||
await guild.set_channel(channel.id, cache=self.bot.cache)
|
||||
await guild.set_category(category.id, cache=self.bot.cache)
|
||||
await guild.set_timezone(str(timezone_parsed), cache=self.bot.cache)
|
||||
|
||||
# TODO Make a nice message
|
||||
await ctx.respond("Okay.")
|
||||
@@ -54,6 +64,7 @@ class Config(Cog):
|
||||
|
||||
await guild.reset_channel(cache=self.bot.cache)
|
||||
await guild.reset_category(cache=self.bot.cache)
|
||||
await guild.reset_timezone(cache=self.bot.cache)
|
||||
|
||||
# TODO Make a nice message
|
||||
await ctx.respond("Okay.")
|
||||
|
Reference in New Issue
Block a user