Fixed messages about not created channels
This commit is contained in:
@@ -98,10 +98,27 @@ class PycordBot(LibPycordBot):
|
||||
await user._set(self.cache, current_event_id=event._id, current_stage_id=first_stage._id)
|
||||
|
||||
# Create a channel for each participant
|
||||
await user.setup_event_channel(self, guild, pycord_guild, event, cache=self.cache)
|
||||
user_channel: TextChannel | None = await user.setup_event_channel(
|
||||
self, guild, pycord_guild, event, cache=self.cache
|
||||
)
|
||||
|
||||
# Send a notification about event start
|
||||
user_channel: TextChannel = guild.get_channel(user.event_channels[str(event._id)])
|
||||
if user_channel is None:
|
||||
logger.error(
|
||||
"Event channel was not created for user %s from guild %s and event %s after registration.",
|
||||
user.id,
|
||||
guild.id,
|
||||
event._id,
|
||||
)
|
||||
|
||||
discord_user: User = self.get_user(user.id)
|
||||
|
||||
await self.notify_admins(
|
||||
guild,
|
||||
pycord_guild,
|
||||
f"Event channel could not be created for user **{discord_user.display_name}** ({discord_user.mention}) and event **{event.name}**.",
|
||||
)
|
||||
|
||||
continue
|
||||
|
||||
thumbnail: File | None = (
|
||||
None
|
||||
@@ -109,8 +126,8 @@ class PycordBot(LibPycordBot):
|
||||
else File(Path(f"data/{event.thumbnail['id']}"), event.thumbnail["filename"])
|
||||
)
|
||||
|
||||
# Send a notification about event start
|
||||
# TODO Make a nice message
|
||||
# TODO Also send a thumbnail, event info and short explanation on how to play
|
||||
await user_channel.send(
|
||||
f"Event **{event.name}** is starting!\n\nUse slash command `/guess` to suggest your answers to each event stage.",
|
||||
file=thumbnail,
|
||||
|
@@ -270,9 +270,9 @@ class PycordUser:
|
||||
pycord_guild: "PycordGuild",
|
||||
pycord_event: "PycordEvent",
|
||||
cache: Optional[Cache] = None,
|
||||
):
|
||||
) -> TextChannel | None:
|
||||
if str(pycord_event._id) in self.event_channels.keys():
|
||||
return
|
||||
return None
|
||||
|
||||
discord_member: Member | None = guild.get_member(self.id)
|
||||
discord_category: GuildChannel | None = bot.get_channel(pycord_guild.category_id)
|
||||
@@ -316,6 +316,8 @@ class PycordUser:
|
||||
|
||||
await self.set_event_channel(pycord_event._id, channel.id, cache=cache)
|
||||
|
||||
return channel
|
||||
|
||||
async def lock_event_channel(
|
||||
self,
|
||||
guild: Guild,
|
||||
|
Reference in New Issue
Block a user