Skip to main content

A Discord bot for Stockton University's Esports Discord Server

Project description

Stockton Esports Bot

Install and Run

Create a directory that you want to run the bot in. It can create files for storage as commands are called. You need to have a .env file inside this directory that contains the discord api key. This is the same file that should hold your twitter api key and twitter api secret as well.

Install the package using pip. This requires using python3.7.x.

pip install stocktonesportsbot

Now use the launch command inside your new directory. The bot will start up.

launch.sh

If you were using AWS or another hosting service and you have already installed the package on the server instance:

nohup launch.sh > nohup.out &

This will run the bot in the background, disconnected from the shell you are using. That means you can close the shell and the bot will continue to run.

Commands

Help

main.py StocktonClient.py Info.py

help

Use the help command by itself to get general knowledge of the other commands in the server.

Usage: /help

You can also enter the name of another command to get a more in depth description for the usage of that specific command.

Usage: /help

Output from the help command is sent directly to the user in a direct message.

Role Moderation

main.py StocktonClient.py Roles.py

accept

Accept is only for when a new user joins the server; it is so they verify that they have read the rules and then it gives them the "auth-ed" role in the server. This grants them access to the rest of the server.

Usage: /accept

This can also be used to gain the auth-ed role at any time, should an accident happen and it gets removed from a user manually.

addrole

Specifically for adding roles to a user, by the user themselves. They should be able to add any role for specific games that exist in the server. They should not be able to add roles such as "Game-manager" or "Moderator". Role names entered as a parameter can now be case insensative.

Usage: addrole

removerole

Removes a role from a user as specified. Similar to addrole, this command can only manipulate game specific roles, not roles such as "auth-ed" or "Moderator". Role names entered as a parameter can now be case insensative.

Usage: /removerole

Game Statistics

main.py StocktonClient.py Stats.py

Notes

All statistic commands can possibly become broken due to a change in the website that we parse the data from. The sites are 3rd party sites and may not always have the most up to date statistics.

The python dictionaries that hold the user ID's use their discord name and the discriminator as an index for the account ID that will be used for the stats.

Ex:

Discord#1234 :

In the future it would be good to allow the get stat functions to use an ID as a parameter as well, rather than solely relying on the fact that a user has to save the ID first before calling the stat command.

setfnid

Allows a user to set and save their Epic Games username in order to get their Fortnite stats later, without entering it again. The username is stored in a python dictionary and saved to a file using pickle. This ID can be found if you search for your stats on Fortbuff and look in the url. It should look something like this:

https://www.fortbuff.com/players/<EPIC ID>?mode=all&platform=all

All this does is simply store that ID in a file for later use, it will not automatically send you your stats after you set your ID.

Usage: /setfnid

setsteamid

Allows a user to set and save their Steam username in order to get their Rocket League stats later, without entering it again. The username is stored in a python dictionary and saved to a file using pickle. This ID can be found in two main places. You can search for your stats on Tracker Network and look in the url, or go to your Steam profile page (browser or desktop client) and look there.

For Tracker Network

https://rocketleague.tracker.network/profile/steam/<STEAM ID>

For Steam

https://steamcommunity.com/id/<STEAM ID>

This ID can be either the name that you set when you created your Steam account OR a string of numbers. The Tracker Network will accept either when the url is built by the bot.

Usage: /setsteamid

fnstats

When called, this returns a list of the user's Fortnite stats. It uses the saved Epic Games ID set by setfnid. The method gets the ID from a pickled python dictionary and then uses that value to build the url on Fortbuff that contains their respective stat page.

Usage: /fnstats

rlstats

When called, this returns a list of the user's Rocket League stats. It uses the saved Steam ID set by setsteamid. The method gets the ID from a pickled python dictionary and then uses that value to build the url on Rocket League Tracker Network that contains their respective stat page.

Usage: /rlstats

champ

This is a command specifically for League of Legends. When passed a champions name, such as Riven or Thresh, it will return general stats for that champion from champion.gg. This includes most frequent and highest win percent starters, runes, finished builds, and max skill order. The idea here is that Discord has a game overlay that can be pulled up in full screen games rather than alt-tabbing to a browser window.

Usage: /champ

Queues

main.py StocktonClient.py Queue.py

Notes

Queues can only be used in a channel named "queues". Only one queue can be active at a time, in the future maybe have a list of queue IDs to support multiple queues at once. This can be done by passing another parameter ID when calling the command and storing the queue by the created ID rather than the embed message ID. Then you could join a queue by /joinq instead.

createq

This physically creates the queue by taking in the size of each team, and how many teams to create. Both parameters must be passed, and be integer values. It returns by creating an embedded message in the "queues" channel. This message will be further updated as people join and leave the queue. It will be deleted if endq is used.

Usage: /createq

endq

Simply ends the current queue by deleting the embedded message and setting StocktonClient.queue to null.

Usage: /endq

joinq

This lets a user join the current queue. It adds them to the list of users, and then updates the embedded queue message to display them in the queue.

Usage: /joinq

leaveq

Allows a user that previously joined the queue to leave it. It removes them from the list of users and updates the embedded queue message.

Usage: /leaveq

getq

This randomizes teams from the players in the current queue and sends a list of each team in the "queues" channel.

Usage: /getq

Metrics

main.py Metrics.py

server_stats

This sends calendar heat maps to the user. The blue heat map represents when users join the discord server. The green heat map represents when the @StocktonEsports twitter account tweets. The heat maps are created using this answer on stack overflow. The discord data is collected by parsing through the members in the server and viewing their joined date. The twitter data is collected using tweepy which is a python wrapper for the Twitter API.

Usage: /server_stats

server_activity

All this does is parse through each text channel in the server and keep a tally of how many times each user sends a message. It prints the list out to console and it's kind of trivial.

Usage: /server_activity

Admin Controls

set_send_link

To see the code for this setting see the Game Statistics section

This sets a setting to send the stats link along with the stats when they get sent to a user. It is only for statistics related to games themselves. This is so that they could easily view the page the stats came from as well as get a more in depth view.

Usage: /set_send_link

kill

main.py

This closes the bots connection with Discord. Essentially just turns it off.

Usage: /kill

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stocktonesportsbot-1.2.tar.gz (28.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page