Closes #11
This commit is contained in:
@@ -275,9 +275,10 @@ class PycordUser:
|
||||
guild: Guild,
|
||||
pycord_guild: "PycordGuild",
|
||||
pycord_event: "PycordEvent",
|
||||
ignore_exists: bool = False,
|
||||
cache: Optional[Cache] = None,
|
||||
) -> TextChannel | None:
|
||||
if str(pycord_event._id) in self.event_channels.keys():
|
||||
if not ignore_exists and str(pycord_event._id) in self.event_channels.keys():
|
||||
return None
|
||||
|
||||
discord_member: Member | None = guild.get_member(self.id)
|
||||
@@ -314,6 +315,43 @@ class PycordUser:
|
||||
|
||||
return channel
|
||||
|
||||
# TODO Add documentation
|
||||
async def fix_event_channel(
|
||||
self,
|
||||
bot: Bot,
|
||||
guild: Guild,
|
||||
pycord_guild: "PycordGuild",
|
||||
pycord_event: "PycordEvent",
|
||||
cache: Optional[Cache] = None,
|
||||
) -> TextChannel | None:
|
||||
# Configure channel if not set
|
||||
if str(pycord_event._id) not in self.event_channels.keys():
|
||||
return await self.setup_event_channel(bot, guild, pycord_guild, pycord_event, cache=cache)
|
||||
|
||||
discord_member: Member | None = guild.get_member(self.id)
|
||||
|
||||
if discord_member is None:
|
||||
raise DiscordGuildMemberNotFoundError(self.id, guild.id)
|
||||
|
||||
channel: TextChannel = guild.get_channel(self.event_channels[str(pycord_event._id)])
|
||||
|
||||
if channel is None:
|
||||
return await self.setup_event_channel(
|
||||
bot, guild, pycord_guild, pycord_event, ignore_exists=True, cache=cache
|
||||
)
|
||||
|
||||
await channel.set_permissions(
|
||||
discord_member,
|
||||
overwrite=PermissionOverwrite(
|
||||
view_channel=True,
|
||||
send_messages=True,
|
||||
use_application_commands=True,
|
||||
),
|
||||
reason=f"Updated event channel of {self.id} for event {pycord_event._id}",
|
||||
)
|
||||
|
||||
return channel
|
||||
|
||||
# TODO Add documentation
|
||||
async def lock_event_channel(
|
||||
self,
|
||||
|
Reference in New Issue
Block a user