Worked on #13 and #4. There are some caching issues left, though. Introduced abstract class Cacheable. Replaced async_pymongo with pymongo

This commit is contained in:
2025-05-06 02:54:30 +02:00
parent 9d562e2e9d
commit 86c75d06fa
22 changed files with 412 additions and 137 deletions

View File

@@ -4,7 +4,7 @@ from pathlib import Path
from zoneinfo import ZoneInfo
from bson.errors import InvalidId
from discord import ApplicationContext, Cog, TextChannel, option, slash_command, File
from discord import ApplicationContext, Cog, File, TextChannel, option, slash_command
from discord.utils import basic_autocomplete
from libbot.i18n import _, in_every_locale
@@ -39,7 +39,7 @@ class CogRegister(Cog):
try:
guild: PycordGuild = await self.bot.find_guild(ctx.guild.id)
except (InvalidId, GuildNotFoundError):
await ctx.respond(self.bot._("unexpected_error", "messages", locale=ctx.locale))
await ctx.respond(self.bot._("unexpected_error", "messages", locale=ctx.locale), ephemeral=True)
return
try:
@@ -49,17 +49,21 @@ class CogRegister(Cog):
return
if not guild.is_configured():
await ctx.respond(self.bot._("guild_unconfigured", "messages", locale=ctx.locale))
await ctx.respond(
self.bot._("guild_unconfigured", "messages", locale=ctx.locale), ephemeral=True
)
return
user: PycordUser = await self.bot.find_user(ctx.author, ctx.guild)
if user.is_jailed:
await ctx.respond(self.bot._("jailed_error", "messages", locale=ctx.locale))
await ctx.respond(self.bot._("jailed_error", "messages", locale=ctx.locale), ephemeral=True)
return
if pycord_event._id in user.registered_event_ids:
await ctx.respond(self.bot._("register_already_registered", "messages", locale=ctx.locale))
await ctx.respond(
self.bot._("register_already_registered", "messages", locale=ctx.locale), ephemeral=True
)
return
await user.event_register(pycord_event._id, cache=self.bot.cache)