Clients¶
get_accounts¶
- daf.core.get_accounts() List[ACCOUNT] ¶
Added in version v2.4.
- Returns:
List of running accounts.
- Return type:
List[client.ACCOUNT]
SeleniumCLIENT¶
- class daf.web.SeleniumCLIENT(username: str, password: str, proxy: str)¶
Added in version v2.5.
Client used to control the Discord web client for things such as logging in, joining guilds, passing “Complete” for guild rules.
This is created in the ACCOUNT object in case
web
parameter inside ACCOUNT is True.- Parameters:
- async initialize() None ¶
Starts the webdriver whenever the framework is started.
- Returns:
True
on success orFalse
on error.- Return type:
- async async_execute(method: Callable, *args)¶
Runs method in executor to force async.
- Parameters:
method (Callable) – Callable to execute in async thread executor.
args – Variadic arguments passed to
method
.
- async random_server_click()¶
Randomly clicks on the servers panel to avoid CAPTCHA triggering.
- async fetch_invite_link(url: str)¶
Fetches the invite link in case it is valid.
- Parameters:
url (str | None) – The url to check or None if error ocurred/invalid link.
- async slow_type(form: WebElement, text: str)¶
Slowly types into a form to prevent detection.
- Parameters:
form (WebElement) – The form to type
text
into.text (str) – The text to type in the
form
.
- async slow_clear(form: WebElement)¶
Slowly deletes the text from an input
- Parameters:
form (WebElement) – The form to delete
text
from.
- async await_url_change()¶
Waits for url to change.
- Raises:
TimeoutError – Waited for too long.
- async await_load()¶
Waits for the Discord spinning logo to disappear, which means that the content has finished loading.
- Raises:
TimeoutError – The page loading timed-out.
- async await_captcha()¶
Waits for CAPTCHA to be completed.
- Raises:
TimeoutError – CAPTCHA was not solved in time.
- async login() str ¶
Logins to Discord using the webdriver and saves the account token to JSON file.
- Returns:
Token belonging to provided username.
- Return type:
- Raises:
TimeoutError – Raised when any of the
await_*
methods timed-out.RuntimeError – Unable to login due to internal exception.
- async hover_click(element: WebElement)¶
Hovers an element and clicks on it.
- Parameters:
element (WebElement) – The element to hover click.
- async join_guild(invite: str) None ¶
Joins the guild thru the browser.
- Parameters:
invite (str) – The invite link/code of the guild to join.
- Raises:
RuntimeError – Internal error ocurred.
RuntimeError – The user is banned from the guild.
TimeoutError – Timed out while waiting for actions to complete.
ACCOUNT¶
- class daf.client.ACCOUNT(token: str | None = None, is_user: bool | None = False, intents: Intents | None = None, proxy: str | None = None, servers: List[GUILD | USER | AutoGUILD] | None = None, username: str | None = None, password: str | None = None, removal_buffer_length: int = 50, responders: List[ResponderBase] = None)¶
Added in version v2.4.
Changed in version v2.5: Added
username
andpassword
parameters. For logging in automaticallyChanged in version v3.0: When servers are added directly through account initialization, they will be removed upon errors and available withing
removed_servers
property.Represents an individual Discord account.
Each ACCOUNT instance runs it’s own shilling task.
- Parameters:
token (str) – The Discord account’s token
is_user (Optional[bool] =False) – Declares that the
token
is a user account token (“self-bot”)intents (Optional[discord.Intents]) –
Discord Intents (settings of events that the client will subscribe to). Defaults to everything enabled except
members
,presence
andmessage_content
, as those are privileged events, which need to be enabled though Discord’s developer settings for each bot.Warning
For invite link tracking to work, it is required to set
members
intents to True. Invites intent is also needed. Enable it by settinginvites
to True inside theintents
parameter ofACCOUNT
.Intent
guilds
is also required for AutoGUILD and AutoCHANNEL, however it is automatically forced to True, as it is not a privileged intent.proxy (Optional[str]=None) –
The proxy to use when connecting to Discord.
Important
It is RECOMMENDED to use a proxy if you are running MULTIPLE accounts. Running multiple accounts from the same IP address, can result in Discord detecting self-bots.
Running multiple bot accounts on the other hand is perfectly fine without a proxy.
servers (Optional[List[guild.GUILD | guild.USER | guild.AutoGUILD]]=[]) – Predefined list of servers (guilds, users, auto-guilds). If initializing a server fails (eg. server doesn’t exist on Discord), it will be removed and added to
daf.client.ACCOUNT.removed_servers
property.username (Optional[str]) – The username to login with.
password (Optional[str]) – The password to login with.
removal_buffer_length (Optional[int]) –
Added in version 3.0.
Maximum number of servers to keep in the removed_servers buffer.
responders (List[responder.ResponderBase]) –
Added in version 3.3.
List of automatic responders. These will automatically respond to certain messages.
- Raises:
ModuleNotFoundError – ‘proxy’ parameter was provided but requirements are not installed.
ValueError – ‘token’ is not allowed if ‘username’ is provided and vice versa.
- property selenium: SeleniumCLIENT¶
Added in version v2.5.
Returns the, bound to account, Selenium client
- property running: bool¶
Is the account still running?
- Returns:
True – The account is logged in and shilling is active.
False – The shilling has ended or not begun.
- 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.
- property servers: List[GUILD | USER | AutoGUILD]¶
Returns all guild like objects inside the account’s s shilling list. This also includes
AutoGUILD
- property removed_servers: List[GUILD | USER | AutoGUILD]¶
Returns a list of servers that were removed from account (last
removal_buffer_length
servers).
- property client: Client¶
Returns the API wrapper client
- property responders¶
Returns the list of automatic message responders
- add_server(server: GUILD | USER | AutoGUILD) Future ¶
Initializes a guild like object and adds it to the internal account shill list.
This is an asynchronous API operation. When returning from this function, the action is not immediately executed.
- Parameters:
server (guild.GUILD | guild.USER | guild.AutoGUILD) – The guild like 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:
ValueError – Invalid
snowflake
(eg. server doesn’t exist).RuntimeError – Could not query Discord.
- remove_server(server: GUILD | USER | AutoGUILD) Future ¶
Removes a guild like object from the shilling list.
This is an asynchronous API operation. When returning from this function, the action is not immediately executed.
Changed in version 3.0: Removal is now asynchronous.
- Parameters:
server (guild.GUILD | guild.USER | guild.AutoGUILD) – The guild like 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
- Raises:
ValueError –
server
is not in the shilling list.
- get_server(snowflake: int | Guild | User | Object) GUILD | USER | None ¶
Retrieves the server based on the snowflake id or discord API object.
- Parameters:
snowflake (Union[int, discord.Guild, discord.User, discord.Object]) – Snowflake ID or Discord API object.
- Returns:
Union[guild.GUILD, guild.USER] – The DAF server object.
None – The object was not found.
- add_responder(resp: ResponderBase) Future ¶
Added in version 3.3.0.
Adds an automatic message responder to the account.
This is an asynchronous API operation. When returning from this function, the action is not immediately executed.
- Parameters:
resp (ResponderBase) – Any inherited class of the
daf.responder.ResponderBase
interface.- 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 account.add_responder()
.- Return type:
Awaitable
- remove_responder(resp: ResponderBase) Future ¶
Added in version 3.3.0.
Removes an automatic message responder from the account.
This is an asynchronous API operation. When returning from this function, the action is not immediately executed.
- Parameters:
resp (ResponderBase) – Any inherited class of the
daf.responder.ResponderBase
interface.- 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 account.remove_responder()
.- Return type:
Awaitable
- update(**kwargs) Future ¶
Updates the object with new parameters and afterwards updates all lower layers (GUILD->MESSAGE->CHANNEL).
This is an asynchronous API operation. When returning from this function, the action is not immediately executed.
Warning
After calling this method the entire object is reset.
- 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:
ValueError – The account is no longer running.
Exception – Other exceptions returned from
daf.client.ACCOUNT
constructor or fromdaf.client.ACCOUNT.initialize()
.
- async initialize()¶
Initializes the API wrapper client layer.
RemoteAccessCLIENT¶
- class daf.remote.RemoteAccessCLIENT(host: str | None = '0.0.0.0', port: int | None = 80, username: str | None = None, password: str | None = None, certificate: str | None = None, private_key: str | None = None, private_key_pwd: str | None = None)¶
Client used for processing remote requests from a GUI located on a different network.
- Parameters:
host (Optional[str]) – The host address. Defaults to
0.0.0.0
(Listens on all network interfaces).port (Optional[int]) – The http port. Defaults to
80
.username (Optional[str]) – The basic authorization username. Defaults to
None
.password (Optional[str]) – The basic authorization password. Defaults to
None
.certificate (Optional[str]) – Path to a certificate file. Used when HTTPS is desired instead of HTTP. (Recommended if username & password)
private_key (Optional[str]) – Path to a private key file that belongs to
certificate
.private_key_pwd (Optional[str]) – The password of
private_key
if it has any.
- Raises:
ValueError – Private key is required with certificate.