Quickstart#

This page contains information to quickly getting started.

The first thing you need is the library installed, see Installation.

Framework control#

Only one function is needed to be called for the framework to start.

The framework can be started using daf.core.run() function (and stopped with the daf.core.shutdown() function).

Note

DAF is built for asynchronous usage and is using the asyncio module to run tasks. run() starts an asyncio event loop and then creates the initialization task that starts all the components.

If you wish to start the framework in a program that already has a running asyncio event loop, you can use the daf.core.initialize() coroutine.

import daf
import asyncio

async def some_program():
    await daf.core.initialize(...) # Starts the framework in an asyncio loop that is already running.

asyncio.run(some_program())

Function run() accepts many parameters but there are 3 which are most important:

  • token

    This is the Discord account access token, it can be obtained the following way:

    1. Visit the Developer Portal

    2. Select your application

    3. Click on the “Bot” tab

    4. Click “Copy token” - if only “reset” exists, click on “reset” and then “Copy token”

    Follow instructions

    import daf
    
    
    daf.run(
        token="JDJSDJAHDSAHBDJABEJHQGEGSAGEJHSGJGEJSHG", # Some account token
    )
    
  • is_user

    Set this to True if the token parameter is from an user account or False if it is from a bot account.

    import daf
    
    
    daf.run(
        token="JDJSDJAHDSAHBDJABEJHQGEGSAGEJHSGJGEJSHG", # Some account token
        is_user=True # Set this to True, if the above token is from an user account.
    )
    
  • server_list

    This parameter accepts a list of GUILD / USER objects and represents the servers to which the framework will shill. The below block shows a sample definition of the server list, which will send text messages. For full parameters see GUILD / USER and daf.message.TextMESSAGE for the TextMESSAGE parameters.

    Note

    Snowflake ID is a unique ID representing resources like guilds and channels. It can be obtained by enabling developer mode, then right clicking on the resource (eg. guild) and last left clicking Copy ID.

    Obtaining snowflake.

    from datetime import timedelta
    import  daf
    
    guilds = [
        daf.GUILD(
            snowflake=123456789,    # ID of server (guild) or a discord.Guild object
            messages=[              # List MESSAGE objects
                daf.TextMESSAGE(
                                  start_period=None,                # If None, messages will be send on a fixed period (end period)
                                  end_period=timedelta(seconds=15), # If start_period is None, it dictates the fixed sending period,
                                                                    # If start period is defined, it dictates the maximum limit of randomized period
                                  data="First message",             # Data you want to sent to the function (Can be of types : str, embed, file, list of types to the left
                                                                    # or function that returns any of above types(or returns None if you don't have any data to send yet), 
                                                                    # where if you pass a function you need to use the daf.FUNCTION decorator on top of it ).
                                  channels=[123456789],             # List of ids of all the channels you want this message to be sent into or discord channel Objects
                                  mode="send",                      # "send" will send a new message every time, "edit" will edit the previous message, "clear-send" will delete
                                                                    # the previous message and then send a new one
                                  start_in=timedelta(seconds=0),    # Delay before shilling start
                                  remove_after=None                 # Remove the message never or after n-times, after specific date or after timedelta
                                  ),
                daf.TextMESSAGE(start_period=5, end_period=timedelta(seconds=10), data="Second Message", channels=[12345], mode="send", start_in=timedelta(seconds=0))  
            ],
            logging=True,           # Generate file log of sent messages (and failed attempts) for this server 
            remove_after=None       # Never stop shilling to this guild
        )
    ]
                                         
    ############################################################################################
    
    daf.run(
            token="DNASNDANDASKJNDAKSJDNASKJDNASKJNSDSAKDNAKLSNDSKAJDN",        
            is_user=False,
            server_list=guilds,
        )
    

After you’ve successfully defined your server list and started the framework with run(), the framework will run on it’s own and there is nothing you need to do from this point forward if basic periodic shilling with text messages is all you desire.