GoldyBot.utility.guild_events.event
1from __future__ import annotations 2 3import GoldyBot 4from datetime import datetime 5 6MODULE_NAME = __name__.upper() 7 8class GuildEvent(): 9 """This class allows you to control a guild event.""" 10 def __init__(self, ctx, name:str, description:str, entity_type:GoldyBot.nextcord.ScheduledEventEntityType, start_time:datetime, end_time:datetime=None, 11 channel:GoldyBot.Channel=None, metadata:GoldyBot.nextcord.EntityMetadata = None, image:GoldyBot.File=None, reason:str="Becauwse WatAshi said uwu and bawked, that's why i dow thiws"): 12 13 self.ctx = ctx 14 self.guild:GoldyBot.utility.guilds.guild.Guild = GoldyBot.cache.FindGuilds().find_object_by_id(ctx.guild.id) 15 16 self._name = name 17 self._description = description 18 self._entity_type = entity_type 19 self._start_time = start_time 20 self._end_time = end_time 21 self._channel = channel 22 self._metadata = metadata 23 self._image = image 24 self._reason = reason 25 26 self.scheduled_event:GoldyBot.nextcord.ScheduledEvent = None 27 28 if self.guild == None: 29 raise GoldyBot.errors.GoldyBotError("Guild is none. Guild does not exist in cache for some reason uwu.") 30 31 #TODO: Added more methods like e.g delete() and edit() method. 32 33 @property 34 def name(self) -> str: 35 """The name of the guild event.""" 36 return self._name 37 38 @property 39 def description(self) -> str: 40 """The description of the guild event.""" 41 return self._description 42 43 @property 44 def entity_type(self) -> GoldyBot.nextcord.ScheduledEventEntityType: 45 """The entity type of the guild.""" 46 return self._entity_type 47 48 @property 49 def start_time(self) -> datetime: 50 """Returns the start time and date of the event in datetime object.""" 51 return self._start_time 52 53 @property 54 def end_time(self) -> datetime|None: 55 """Returns the end time and date of the event in datetime object.""" 56 return self._end_time 57 58 @property 59 def channel(self) -> GoldyBot.channel.Channel: 60 """Returns the channel of this event.""" 61 return self._channel 62 63 @property 64 def metadata(self) -> GoldyBot.nextcord.EntityMetadata: 65 return self._metadata 66 67 @property 68 def image(self) -> GoldyBot.File: 69 return self._image 70 71 @property 72 def reason(self) -> str: 73 """Returns the set reasoning of this event, if none a sussy default message is returned instead.""" 74 return self._reason 75 76 77 async def create(self) -> GoldyBot.nextcord.ScheduledEvent|None: 78 """Creates the ⭐ fancy guild event.""" 79 80 if self.entity_type == GoldyBot.nextcord.ScheduledEventEntityType.external: 81 if self.end_time is None: 82 GoldyBot.log("error", f"[{MODULE_NAME}] End time is required for external events. end_time was None.") 83 return None 84 85 if self.metadata is None: 86 GoldyBot.log("error", f"[{MODULE_NAME}] Location is required on metadata for external events.") 87 return None 88 89 90 self.scheduled_event = await self.guild.nextcord_guild_object.create_scheduled_event( 91 name=self.name, description=self.name, entity_type=self.entity_type, start_time=self.start_time, 92 end_time=(lambda end_time: GoldyBot.nextcord.utils.MISSING if end_time is None else end_time)(self.end_time), 93 channel=(lambda channel: GoldyBot.nextcord.utils.MISSING if channel is None else channel.channel)(self.channel), 94 metadata=(lambda metadata: GoldyBot.nextcord.utils.MISSING if metadata is None else metadata)(self.metadata), 95 image=GoldyBot.nextcord.File(self.image.get_file()), reason=self.reason # I think this was not working... 96 ) 97 98 GoldyBot.logging.log("info_2", f"[{MODULE_NAME}] Created guild event in '{self.channel.display_name}'.") 99 100 return self.scheduled_event
class
GuildEvent:
9class GuildEvent(): 10 """This class allows you to control a guild event.""" 11 def __init__(self, ctx, name:str, description:str, entity_type:GoldyBot.nextcord.ScheduledEventEntityType, start_time:datetime, end_time:datetime=None, 12 channel:GoldyBot.Channel=None, metadata:GoldyBot.nextcord.EntityMetadata = None, image:GoldyBot.File=None, reason:str="Becauwse WatAshi said uwu and bawked, that's why i dow thiws"): 13 14 self.ctx = ctx 15 self.guild:GoldyBot.utility.guilds.guild.Guild = GoldyBot.cache.FindGuilds().find_object_by_id(ctx.guild.id) 16 17 self._name = name 18 self._description = description 19 self._entity_type = entity_type 20 self._start_time = start_time 21 self._end_time = end_time 22 self._channel = channel 23 self._metadata = metadata 24 self._image = image 25 self._reason = reason 26 27 self.scheduled_event:GoldyBot.nextcord.ScheduledEvent = None 28 29 if self.guild == None: 30 raise GoldyBot.errors.GoldyBotError("Guild is none. Guild does not exist in cache for some reason uwu.") 31 32 #TODO: Added more methods like e.g delete() and edit() method. 33 34 @property 35 def name(self) -> str: 36 """The name of the guild event.""" 37 return self._name 38 39 @property 40 def description(self) -> str: 41 """The description of the guild event.""" 42 return self._description 43 44 @property 45 def entity_type(self) -> GoldyBot.nextcord.ScheduledEventEntityType: 46 """The entity type of the guild.""" 47 return self._entity_type 48 49 @property 50 def start_time(self) -> datetime: 51 """Returns the start time and date of the event in datetime object.""" 52 return self._start_time 53 54 @property 55 def end_time(self) -> datetime|None: 56 """Returns the end time and date of the event in datetime object.""" 57 return self._end_time 58 59 @property 60 def channel(self) -> GoldyBot.channel.Channel: 61 """Returns the channel of this event.""" 62 return self._channel 63 64 @property 65 def metadata(self) -> GoldyBot.nextcord.EntityMetadata: 66 return self._metadata 67 68 @property 69 def image(self) -> GoldyBot.File: 70 return self._image 71 72 @property 73 def reason(self) -> str: 74 """Returns the set reasoning of this event, if none a sussy default message is returned instead.""" 75 return self._reason 76 77 78 async def create(self) -> GoldyBot.nextcord.ScheduledEvent|None: 79 """Creates the ⭐ fancy guild event.""" 80 81 if self.entity_type == GoldyBot.nextcord.ScheduledEventEntityType.external: 82 if self.end_time is None: 83 GoldyBot.log("error", f"[{MODULE_NAME}] End time is required for external events. end_time was None.") 84 return None 85 86 if self.metadata is None: 87 GoldyBot.log("error", f"[{MODULE_NAME}] Location is required on metadata for external events.") 88 return None 89 90 91 self.scheduled_event = await self.guild.nextcord_guild_object.create_scheduled_event( 92 name=self.name, description=self.name, entity_type=self.entity_type, start_time=self.start_time, 93 end_time=(lambda end_time: GoldyBot.nextcord.utils.MISSING if end_time is None else end_time)(self.end_time), 94 channel=(lambda channel: GoldyBot.nextcord.utils.MISSING if channel is None else channel.channel)(self.channel), 95 metadata=(lambda metadata: GoldyBot.nextcord.utils.MISSING if metadata is None else metadata)(self.metadata), 96 image=GoldyBot.nextcord.File(self.image.get_file()), reason=self.reason # I think this was not working... 97 ) 98 99 GoldyBot.logging.log("info_2", f"[{MODULE_NAME}] Created guild event in '{self.channel.display_name}'.") 100 101 return self.scheduled_event
This class allows you to control a guild event.
GuildEvent( ctx, name: str, description: str, entity_type: nextcord.enums.ScheduledEventEntityType, start_time: datetime.datetime, end_time: datetime.datetime = None, channel: GoldyBot.objects.channel.Channel = None, metadata: nextcord.scheduled_events.EntityMetadata = None, image: GoldyBot.files.File = None, reason: str = "Becauwse WatAshi said uwu and bawked, that's why i dow thiws")
11 def __init__(self, ctx, name:str, description:str, entity_type:GoldyBot.nextcord.ScheduledEventEntityType, start_time:datetime, end_time:datetime=None, 12 channel:GoldyBot.Channel=None, metadata:GoldyBot.nextcord.EntityMetadata = None, image:GoldyBot.File=None, reason:str="Becauwse WatAshi said uwu and bawked, that's why i dow thiws"): 13 14 self.ctx = ctx 15 self.guild:GoldyBot.utility.guilds.guild.Guild = GoldyBot.cache.FindGuilds().find_object_by_id(ctx.guild.id) 16 17 self._name = name 18 self._description = description 19 self._entity_type = entity_type 20 self._start_time = start_time 21 self._end_time = end_time 22 self._channel = channel 23 self._metadata = metadata 24 self._image = image 25 self._reason = reason 26 27 self.scheduled_event:GoldyBot.nextcord.ScheduledEvent = None 28 29 if self.guild == None: 30 raise GoldyBot.errors.GoldyBotError("Guild is none. Guild does not exist in cache for some reason uwu.")
image: GoldyBot.files.File
reason: str
Returns the set reasoning of this event, if none a sussy default message is returned instead.
async def
create(self) -> nextcord.scheduled_events.ScheduledEvent | None:
78 async def create(self) -> GoldyBot.nextcord.ScheduledEvent|None: 79 """Creates the ⭐ fancy guild event.""" 80 81 if self.entity_type == GoldyBot.nextcord.ScheduledEventEntityType.external: 82 if self.end_time is None: 83 GoldyBot.log("error", f"[{MODULE_NAME}] End time is required for external events. end_time was None.") 84 return None 85 86 if self.metadata is None: 87 GoldyBot.log("error", f"[{MODULE_NAME}] Location is required on metadata for external events.") 88 return None 89 90 91 self.scheduled_event = await self.guild.nextcord_guild_object.create_scheduled_event( 92 name=self.name, description=self.name, entity_type=self.entity_type, start_time=self.start_time, 93 end_time=(lambda end_time: GoldyBot.nextcord.utils.MISSING if end_time is None else end_time)(self.end_time), 94 channel=(lambda channel: GoldyBot.nextcord.utils.MISSING if channel is None else channel.channel)(self.channel), 95 metadata=(lambda metadata: GoldyBot.nextcord.utils.MISSING if metadata is None else metadata)(self.metadata), 96 image=GoldyBot.nextcord.File(self.image.get_file()), reason=self.reason # I think this was not working... 97 ) 98 99 GoldyBot.logging.log("info_2", f"[{MODULE_NAME}] Created guild event in '{self.channel.display_name}'.") 100 101 return self.scheduled_event
Creates the ⭐ fancy guild event.