Clients#

get_accounts#

daf.core.get_accounts() List[ACCOUNT]#

New 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)#

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

Note

This is automatically created in ACCOUNT and is also bound to the ACCOUNT instance.

To retrieve it from ACCOUNT, use selenium.

Parameters:
  • username (str) – The Discord username to login with.

  • password (str) – The Discord password to login with.

  • proxy (str) – The proxy url to use when connecting to Chrome.

property token: str#

Returns accounts’s token

update_token_file() str#

Updates the tokens JSON file.

Raises:

OSError – There was an error saving/reading the file.

Returns:

The token.

Return type:

str

async random_sleep(bottom: int, upper: int)#

Sleeps randomly to prevent detection.

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.

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 initialize() None#

Starts the webdriver whenever the framework is started.

Raises:

Any – Raised in login() method.

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:

str

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:

ACCOUNT#

class daf.client.ACCOUNT(token: Optional[str] = None, is_user: Optional[bool] = False, intents: Optional[Intents] = None, proxy: Optional[str] = None, servers: Optional[List[Union[GUILD, USER, AutoGUILD]]] = None, username: Optional[str] = None, password: Optional[str] = None)#

New in version v2.4.

Changed in version v2.5: Added username and password parameters. For logging in automatically

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.default()) – Discord Intents (settings of events that the client will subscribe to)

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

  • username (Optional[str]) – The username to login with.

  • password (Optional[str]) – The password to login with.

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#

New 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#

Returns all guild like objects inside the account’s s shilling list. This also includes AutoGUILD

property client: Client#

Returns the API wrapper client

async initialize()#

Initializes the API wrapper client layer.

Raises:

RuntimeError – Unable to login to Discord.

async add_server(server: Union[GUILD, USER, AutoGUILD])#

Initializes a guild like object and adds it to the internal account shill list.

Parameters:

server (guild.GUILD | guild.USER | guild.AutoGUILD) – The guild like object to add

Raises:

Any – Raised in daf.guild.GUILD.initialize() | daf.guild.USER.initialize() | daf.guild.AutoGUILD.initialize()

remove_server(server: Union[GUILD, USER, AutoGUILD])#

Removes a guild like object from the shilling list.

Parameters:

server (guild.GUILD | guild.USER | guild.AutoGUILD) – The guild like object to remove

Raises:

ValueErrorserver is not in the shilling list.

get_server(snowflake: Union[int, Guild, User, Object]) Optional[Union[GUILD, USER]]#

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.

async update(**kwargs)#

Updates the object with new parameters and afterwards updates all lower layers (GUILD->MESSAGE->CHANNEL).

Warning

After calling this method the entire object is reset.