Code Monkey home page Code Monkey logo

stephanakkerman / axie-manager-bot Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 3.0 1.37 MB

The self-hosted Discord bot we are using in the Axie Manager server. It consists of multiple handy features for managing your scholars in Axie Infinity and being able to use it for multiple managers.

Home Page: https://www.instagram.com/axie_manager/

License: MIT License

Python 100.00%
axie-infinity axie crypto cryptocurrency nfts nft discord discord-bot discord-py

axie-manager-bot's Introduction

Axie Manager Bot

Python 3.8 Code style: black MIT License


This is a Discord bot written in Python, with the purpose of helping our guild manage the scholars in our Discord server. The purpose of this bot is that it can be used for guilds with multiple scholars and different managers, who each have their own scholars and wallets.

Important

To run this bot you need to host it yourself, meaning that you should have something that functions as a server. I use my Raspberry PI for this, but there are many other options available for hosting a Discord bot, such as virtual private servers provided by Google, Amazon, Microsoft, and more.

Features

This bot was made with configurability in mind, meaning that every feature listed below can be turned on or off, and be changed easily. If you do not want a feature, just turn it off, all automation and listeners works for your custom roles and channels, so be sure to check out the settings in config_example.yaml and change them to your liking!

Commands

  • !announce: Make announcements, using the bot as message sender. Usage !announce <#channel>, followed by a next <text>.
  • !clear: Clear a number of messages. Usage !clear <number>, or !clear <number> <@user> to clear messages of specific user.
  • !encrypt: Encrypt messages, necessary for encrypting private keys and storing them, using your personal uniquely generated encryption key. Usage !encrypt <message>.
  • !funds: For managers to add their funds account address to the database. Usage !funds <ronin address>.
  • !help: Custom written !help command.
  • !issue: Make a new issue for this bot or any other public GitHub repository. Usage !issue <title> followed by the description and labels. Needs your personal GitHub token to work, so this is disabled by default.
  • !manager: Scholars can request information about their manager using this command. Great if there are multiple managers in one server.
  • !mute / !unmute: Mute and unmute specific users. Usage !mute <@user>, this gives a user the 'mute' role.
  • !mydata: Scholar can request their up to date data, consisting of: in game slp, MMR, rank, payout day, and the number of days untill payout day.
  • !price: Request suggested prices for selling your axie. Usage !price <axie ID>, gives maximum 4 different prices based on different criteria.
  • !scholar: Adds a scholar to the database of scholars. Usage !scholar <scholar_discord_name> <address> <split> <payout_address> <encrypted_key> <[manager]>. See the example below of how the values should look like.
  • !tryout: Start tryouts, divides users with role 'tryout' in specific channels. More about this below.
  • !qr: Scholars can request their QR-code in a dedicated channel. The bot will send them a private message containing their QR-code for login.

Automation

In config_example.yaml this is also called 'Loops', you can customize each channel that these automated messages will get send in.

  • Axie Alert: Automated alerts of axies specified in a Google Spreadsheet. More about this below.
  • Axie Trades: Automated buy, sell and listing alerts of other managers.
  • Clean Channel: The channel specified will get cleaned every x hours, useful if a channel is full with messages often.
  • Instagram: If you have a Instagram account that you want server users to be aware of. This will send every new post in the dedicated channel.
  • Leaderboard: Every 4 hours an updated leaderboard gets posted in the dedicated channel, showing the top performing scholars ranked by MMR.
  • Prices: Every 4 hours the new SLP, AXS, ETH, and Axie floor prices get posted in the dedicated channel.
  • SLP Warning: 1 hour before the daily reset scholars get mentioned if they have not yet completed all quests or are below 800 MMR.

Listeners

This section is about the other type of automation, which is based on events.

  • On Command: If a user uses a bot command it will get shown in the console.
  • On Member Join: If a new user joins the server they will get a specific role, disabled by default.
  • On Member Update:
    • If a user gets the role 'scholar' then the bot will send them a video containing an explanation about how everything works.
    • If a user gets the role 'tryout' then the bot will send them a video containing an explanation about how everything works.
  • On Message: Deletes all messages in specific channel that are not send by the bot (by using the !announcement command).
  • On Raw Reaction Add:
    • If you react using the ๐Ÿ’Ž emoji below an axie alert, you will be the only one able to view this axie.
    • Users get the role 'verified' if the click the โœ… below an announcement.
  • Translate: Automatically translates certain languages to another language based on your preferences. For instance from Tagalog to English, the translated messages will be send to a dedicated channel to remove clutter.

Tryouts

Tryouts are used to select a new scholar from a group of people (with the role 'tryout'). For each account that is available for a new scholar a new tryout group can be made, it is also possible to make less groups and pick the first and second best players. Currently we let every tryout play for 3 hours on the account and after all tryouts are done the best will be picked. This is done by selecting the tryout that had the best winrate. At the moment the API for that is offline, so after a tryout is done they should send screenshots of their match history.

Disclaimer

The code for the !qr command was inspired by ZracheSs | xyZ, check out their repo for the original code.

Dependencies

The required packages to run this code can be found in the requirements.txt file. To run this file, execute the following code block:

$ pip install -r requirements.txt 

Alternatively, you can install the required packages manually like this:

$ pip install <package>

Setup

Making a Discord bot

This part is about creating the Discord bot, setting up the basics, and inviting it to your server. For the first part you can watch this video (watch until 2:20).

Or follow these written instructions:

  • Setup your own Discord bot, following this written tutorial or this
  • Give the bot admin rights and all permissions possible, since this is the easiest way to set it up.
  • Invite the bot to your server.

Then you need to add the custom emojis to the server (can be skipped).

  • Download the custom emoji pictures here.
  • Add them to your server (instructions).

Last you need to fill in the important information in config_example.yaml, so the bot knows which server it should be connected to.

  • Open config_example.yaml
  • Write your bot token behind TOKEN: (line 2)
  • Write your server name behind GUILD_NAME: (line 3)
  • If you changed the custom emoji names, change them in the file too (line 37, 40, 41).

Spreadsheet

This part needs to be done and is a bit technical, so follow the steps carefully. Or follow the instructions from this (starts from 1:58) video

If you prefer written instructions follow the instructions below:

After follow the instructions above, last things you need to do is this:

  • Save your authentication.json file in the same folder as you saved the files for this bot.
  • Open authentication.json and copy the email behind "client_email": auth
  • Open Google Drive and go to the folder that you want the bot to make the spreadsheets in, right click on that folder and press share drive1
  • Share the folder with the client email out of authentication.json drive2

Make the roles, channels, and spreadsheets

Because no one likes to go through the process of making all the new channels, roles, and spreadsheets themselves I have written a script to do it for you. To run it you need to have followed the steps above, so you should have installed the dependencies, made the bot, and gave it access to your preferred Google Drive folder. If you have done all that you can execute the following code:

$ python src/setup.py

This will also rename config_example.yaml to just config.yaml so you do not need to worry about renaming that as well. The result will look like this: setup So as the last step for the setup you need to copy your Fernet key to config.yaml line 107, and after that is done you are ready for deploying the bot.

Scholars

As you might have noticed the bot created a spreadsheet called Scholars. This spreadsheet functions as a database of your scholars. You can fill the values in by using the !scholar <scholar_discord_name> <address> <split> <payout_address> <encrypted_key> <[manager]> command or by adding it manually to the sheet. The picture below shows how the values should look like. scholars

Alerts

As you might have noticed the bot also created a spreadsheet called Axie Alerts. This spreadsheet specifies the Axies that should be alerted in the server, for instance if they have a low price or good genes. Below an example is shown of how you can fill in this spreadsheet. builds

Example of an alert that the bot automatically sends:
alert

How to run

  • Clone the repository and install dependencies as specified above.
  • Follow the steps mentioned in setup.
  • Run $ python src/main.py
  • Copy the private key of the scholar you want to add to the database.
  • Encrypt it by sending a private message to the bot using !encrypt <private_key> and use this in the step below.
  • Add a scholar using the !scholar <scholar_discord_name> <address> <split> <payout_address> <encrypted_key> <[manager]> command.
  • Add your funds address using !funds <ronin_address> so it can track your buys and sells.
  • Give your server users their dedicated roles.
  • See the results.

axie-manager-bot's People

Contributors

dependabot[bot] avatar imgbotapp avatar mergify[bot] avatar stephanakkerman avatar timkoornstra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

axie-manager-bot's Issues

Implement extensive error handling

Add different error messages for different errors. Useful for users but also debugging

  • Send important errors to new bot-errors channel
  • encrypt.py
  • help.py
  • listeners.py
  • manage_server.py
  • miscellaneous.py
  • qr.py
  • leaderboard.py
  • scholar_data.py
  • DMChannel

Fix random error messages in alert.py

  • Traceback (most recent call last):
    File "/home/pi/src/cogs/after/alert.py", line 203, in new_listings
    search, build["R1 deviation"], build["R2 deviation"]
    File "/home/pi/src/alerts/genes.py", line 26, in get_genes
    genes = pd.DataFrame(response)
    File "/home/pi/venv/lib/python3.7/site-packages/pandas/core/frame.py", line 614, in init
    mgr = dict_to_mgr(data, index, columns, dtype=dtype, copy=copy, typ=manager)
    File "/home/pi/venv/lib/python3.7/site-packages/pandas/core/internals/construction.py", line 465, in dict_to_mgr
    arrays, data_names, index, columns, dtype=dtype, typ=typ, consolidate=copy
    File "/home/pi/venv/lib/python3.7/site-packages/pandas/core/internals/construction.py", line 119, in arrays_to_mgr
    index = _extract_index(arrays)
    File "/home/pi/venv/lib/python3.7/site-packages/pandas/core/internals/construction.py", line 635, in _extract_index
    raise ValueError("All arrays must be of the same length")
    ValueError: All arrays must be of the same length

  • 'NoneType' object is not subscriptable
    Traceback (most recent call last):
    File "/home/pi/src/cogs/after/alert.py", line 314, in old_listings
    build,
    File "/home/pi/src/cogs/after/alert.py", line 90, in send_alert
    if "auction_info" in row.index
    TypeError: 'NoneType' object is not subscriptable

  • 'float' object is not subscriptable
    Traceback (most recent call last):
    File "C:\Users\Tim\Documents\GitHub Public Repos\Axie_Manager_Bot\src\cogs\after\alert.py", line 310, in old_listings
    await get_genes(
    File "C:\Users\Tim\Documents\GitHub Public Repos\Axie_Manager_Bot\src\alerts\genes.py", line 30, in get_genes
    genes[part] = genes["traits"].apply(lambda x: x[part])
    File "D:\Anaconda3\lib\site-packages\pandas\core\series.py", line 4357, in apply
    return SeriesApply(self, func, convert_dtype, args, kwargs).apply()
    File "D:\Anaconda3\lib\site-packages\pandas\core\apply.py", line 1043, in apply
    return self.apply_standard()
    File "D:\Anaconda3\lib\site-packages\pandas\core\apply.py", line 1098, in apply_standard
    mapped = lib.map_infer(
    File "pandas_libs\lib.pyx", line 2859, in pandas._libs.lib.map_infer
    File "C:\Users\Tim\Documents\GitHub Public Repos\Axie_Manager_Bot\src\alerts\genes.py", line 30, in
    genes[part] = genes["traits"].apply(lambda x: x[part])
    TypeError: 'float' object is not subscriptable

Bug for new listings where 'traits' is not in API response

Traceback (most recent call last):
File "/home/pi/src/cogs/after/alert.py", line 243, in new_listings
search, build["R1 deviation"], build["R2 deviation"]
File "/home/pi/src/alerts/genes.py", line 43, in get_genes
genes[part] = genes["traits"].apply(lambda x: x[part])
File "/home/pi/venv/lib/python3.7/site-packages/pandas/core/frame.py", line 3024, in getitem
indexer = self.columns.get_loc(key)
File "/home/pi/venv/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 3082, in get_loc
raise KeyError(key) from err
KeyError: 'traits'

Verification

Provide automatic verification using a button and embed message

Update the file structure

Change files such that main.py is much cleaner. Functions should be in their respective .py files.

Optimize get_genes() calling

Does not need to happen if the axie has already been seen, in new listings dismiss axie ids that have already been seen

Implement our own !clear

  • !clear <amount> clears a certain amount of messages
  • !clear <amount> [user] clears a certain amount of messages from a user
  • should only be allowed to be run by managers

Add scholar as command

usage !scholar <new scholar> <split> <manager>

  • Create spreadsheet with overview of all scholars
  • Ask for confirmation
  • Add verified user as new scholar
  • Add manager name as role to scholar
  • Send message to manager(s) that they are now managing the new scholar
  • Send message to scholar that they are now scholar of manager x
  • Automatically add user to spreadsheet with filled in info
  • #45
  • Error handling

Example:
img

Change docstrings to better represent commands

Format the command docstrings such that we have a better description of what the command does and the usage.

E.g.

""" General description of command

    [More in-depth description]
    <parameter one>: does x
    [parameter two]: can be used to enhance y
"""

Implement our own !mute

  • !mute <user> gives a user the "mute" role
  • !unmute <user> takes the "mute" role away
  • Command is only allowed to be used by managers

Upgrade announcements

  • Add timestamp
  • Remove all messages except for confirmation template and command call

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.