Guilds#
GUILD#
- class daf.guild.GUILD(snowflake: Union[int, Guild], messages: Optional[List[Union[TextMESSAGE, VoiceMESSAGE]]] = [], logging: Optional[bool] = False, remove_after: Optional[Union[timedelta, datetime]] = None)#
The GUILD object represents a server to which messages will be sent.
Changed in version v2.1:
Added
created_at
attributeAdded
remove_after
parameter
- Parameters:
snowflake (Union[int, discord.Guild]) – Discord’s snowflake ID of the guild or discord.Guild object.
messages (Optional[List[Union[TextMESSAGE, VoiceMESSAGE]]]) – Optional list of TextMESSAGE/VoiceMESSAGE objects.
logging (Optional[bool]) – Optional variable dictating whatever to log sent messages inside this guild.
remove_after (Optional[Union[timedelta, datetime]]) –
Deletes the guild after:
timedelta - the specified time difference
datetime - specific date & time
- async initialize(parent: Any) None #
This function initializes the API related objects and then tries to initialize the MESSAGE objects.
Note
This should NOT be manually called, it is called automatically after adding the message.
- Raises:
ValueError – Raised when the guild_id wasn’t found.
Other – Raised from .add_message(message_object) method.
- async update(init_options={}, **kwargs)#
Used for changing the initialization parameters, the object was initialized with.
New in version v2.0.
Warning
Upon updating, the internal state of objects get’s reset, meaning you basically have a brand new created object. It also resets the message objects.
- Parameters:
**kwargs (Any) – Custom number of keyword parameters which you want to update, these can be anything that is available during the object creation.
- Raises:
TypeError – Invalid keyword argument was passed.
Other – Raised from .initialize() method.
- async add_message(message: BaseMESSAGE)#
Adds a message to the message list.
Warning
To use this method, the guild must already be added to the framework’s shilling list (or initialized).
- Parameters:
message (BaseMESSAGE) – Message object to add.
- Raises:
TypeError – Raised when the message is not of type the guild allows.
Other – Raised from message.initialize() method.
- property apiobject: Object#
New in version v2.4.
Returns the Discord API wrapper’s object of self.
- property created_at: datetime#
New in version v2.1.
Returns the datetime of when the object has been created.
- property deleted: bool#
Indicates the status of deletion.
- Returns:
True – The object is no longer in the framework and should no longer be used.
False – Object is in the framework in normal operation.
- generate_log_context() Dict[str, Union[str, int]] #
Generates a dictionary of the guild’s context, which is then used for logging.
- property messages: List[BaseMESSAGE]#
Returns all the (initialized) message objects inside the object.
New in version v2.0.
- remove_message(message: BaseMESSAGE)#
Removes a message from the message list.
- Parameters:
message (BaseMESSAGE) – Message object to remove.
- Raises:
TypeError – Raised when the message is not of type the guild allows.
ValueError – Raised when the message is not present in the list.
USER#
- class daf.guild.USER(snowflake: Union[int, User], messages: Optional[List[DirectMESSAGE]] = [], logging: Optional[bool] = False, remove_after: Optional[Union[timedelta, datetime]] = None)#
The USER object represents a user to whom messages will be sent.
Changed in version v2.1:
Added
created_at
attributeAdded
remove_after
parameter
- Parameters:
snowflake (Union[int, discord.User]) – Discord’s snowflake ID of the user or discord.User object.
messages (Optional[List[DirectMESSAGE]]) – Optional list of DirectMESSAGE objects.
logging (Optional[bool]) – Optional variable dictating whatever to log sent messages inside this guild.
remove_after (Optional[Union[timedelta, datetime]]) –
Deletes the user after:
timedelta - the specified time difference
datetime - specific date & time
- async initialize(parent: Any)#
This function initializes the API related objects and then tries to initialize the MESSAGE objects.
- Raises:
ValueError – Raised when the DM could not be created.
Other – Raised from .add_message(message_object) method.
- async update(init_options={}, **kwargs)#
New in version v2.0.
Used for changing the initialization parameters, the object was initialized with.
Warning
Upon updating, the internal state of objects get’s reset, meaning you basically have a brand new created object. It also resets the message objects.
- Parameters:
**kwargs (Any) – Custom number of keyword parameters which you want to update, these can be anything that is available during the object creation.
- Raises:
TypeError – Invalid keyword argument was passed.
Other – Raised from .initialize() method.
- async add_message(message: BaseMESSAGE)#
Adds a message to the message list.
Warning
To use this method, the guild must already be added to the framework’s shilling list (or initialized).
- Parameters:
message (BaseMESSAGE) – Message object to add.
- Raises:
TypeError – Raised when the message is not of type the guild allows.
Other – Raised from message.initialize() method.
- property apiobject: Object#
New in version v2.4.
Returns the Discord API wrapper’s object of self.
- property created_at: datetime#
New in version v2.1.
Returns the datetime of when the object has been created.
- property deleted: bool#
Indicates the status of deletion.
- Returns:
True – The object is no longer in the framework and should no longer be used.
False – Object is in the framework in normal operation.
- generate_log_context() Dict[str, Union[str, int]] #
Generates a dictionary of the guild’s context, which is then used for logging.
- property messages: List[BaseMESSAGE]#
Returns all the (initialized) message objects inside the object.
New in version v2.0.
- remove_message(message: BaseMESSAGE)#
Removes a message from the message list.
- Parameters:
message (BaseMESSAGE) – Message object to remove.
- Raises:
TypeError – Raised when the message is not of type the guild allows.
ValueError – Raised when the message is not present in the list.