Auto objects#

AutoCHANNEL#

class daf.message.AutoCHANNEL(include_pattern: BaseLogic | str, exclude_pattern: str | None = None)#

New in version v2.3.

Changed in version v2.10: daf.message.AutoCHANNEL.remove() will now prevent the channel from being added again.

Used for creating instances of automatically managed channels. The objects created with this will automatically add new channels at creation and dynamically while the framework is already running, if they match the patterns.

Listing 13 Usage#
# TextMESSAGE is used here, but works for others too
daf.message.TextMESSAGE(
     ..., # Other parameters
     channels=daf.message.AutoCHANNEL(...)
 )
Parameters:

include_pattern (BaseLogic) – Matching condition, which checks if the name of channels matches defined condition.

property channels: List[TextChannel | Thread | VoiceChannel]#

Return a list of found channels

async initialize(parent, channel_getter: Callable)#

Initializes async parts of the instance. This method should be called by parent.

Changed in version v2.10: Changed the channel channel_type into channel_getter, which is now a function that can be used to get a list of all the correct channels.

Parameters:
  • parent (message.BaseMESSAGE) – The message object this AutoCHANNEL instance is in.

  • channel_type (str) – The channel type to look for when searching for channels

remove(channel: TextChannel | Thread | VoiceChannel)#

Removes channel from cache.

Parameters:

channel (Union[discord.TextChannel, discord.VoiceChannel]) – The channel to remove from cache.

Raises:

KeyError – The channel is not in cache.

async update(init_options=None, **kwargs)#

Updates the object with new initialization parameters.

Parameters:

kwargs (Any) – Any number of keyword arguments that appear in the object initialization.

Raises:

Any – Raised from initialize() method.

AutoGUILD#

class daf.guild.AutoGUILD(include_pattern: BaseLogic | str, exclude_pattern: str | None = None, remove_after: timedelta | datetime | None = None, messages: List[BaseChannelMessage] | None = None, logging: bool | None = False, auto_join: GuildDISCOVERY | None = None, invite_track: List[str] | None = None, removal_buffer_length: int = 50)#

Changed in version v4.0.0:

  • Restored original way AutoGUILD works (as a GUILD generator)

  • Include and exclude patterns now accept a daf.logic.BaseLogic object for more flexible matching. Using strings (text) is deprecated and will be removed.

Represents multiple guilds (servers) based on a text pattern. AutoGUILD generates daf.guild.GUILD objects for each matched pattern.

Parameters:
  • include_pattern (BaseLogic) – Matching condition, which checks if the name of guilds matches defined condition.

  • remove_after (Optional[Union[timedelta, datetime]] = None) – When to remove this object from the shilling list.

  • messages (List[BaseChannelMessage]) – List of messages with channels. This includes TextMESSAGE and VoiceMESSAGE.

  • logging (Optional[bool] = False) – Set to True if you want the guilds generated to log sent messages.

  • auto_join (Optional[web.GuildDISCOVERY] = None) –

    New in version v2.5.

    Optional GuildDISCOVERY object which will automatically discover and join guilds though the browser. This will open a Google Chrome session.

  • invite_track (Optional[List[str]]) – List of invite links (or invite codes) to track.

  • removal_buffer_length (int) – The size of removed messages buffer. A message is added to this buffer when remove_message is called by the user or a message automatically removes itself for any reason. Defaults to 50.

property messages: List[BaseChannelMessage]#

New in version 3.0.

Returns all the (template) message objects.

property guilds: List[GUILD]#

Returns cached GUILD objects.

property remove_after: datetime | None#

Returns the timestamp at which AutoGUILD will be removed or None if it will never be removed.

add_message(message: BaseChannelMessage) Future#

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).

This is an asynchronous API operation. When returning from this function, the action is not immediately executed.

Parameters:

message (BaseChannelMessage) – Message object to add.

Returns:

An awaitable object which can be used to await for execution to finish. To wait for the execution to finish, use await like so: await method_name().

Return type:

Awaitable

Raises:
  • TypeError – Raised when the message is not of type the guild allows.

  • Other – Raised from message.initialize() method.

remove_message(message: BaseChannelMessage) Future#

Remove a message from the advertising list.

This is an asynchronous API operation. When returning from this function, the action is not immediately executed.

Parameters:

message (BaseChannelMessage) – Message object to remove.

Returns:

An awaitable object which can be used to await for execution to finish. To wait for the execution to finish, use await like so: await method_name().

Return type:

Awaitable

update(init_options=None, **kwargs) Future#

Updates the object with new initialization parameters.

This is an asynchronous API operation. When returning from this function, the action is not immediately executed.

Returns:

  • Awaitable – An awaitable object which can be used to await for execution to finish. To wait for the execution to finish, use await like so: await method_name().

  • .. WARNING:: – After calling this method the entire object is reset (this includes it’s GUILD objects in cache).

async initialize(parent: Any, event_ctrl: EventController)#

Initializes the object.