Skip to content
Lawrence Chiappelli edited this page Aug 5, 2020 · 3 revisions

Installation Instructions:

If you want install the bot (whether it's for personal use or contributing), follow these instructions. Contributors should read the last snippets of instructions for important information.

Setup - Invite the bot

Here, we will: create the necessary accounts to generate the bot token, copy and paste it on your PC and run the bot. Note: this bot is a private bot. While inviting a private bot in any given server technically works, it will remain offline and functionless until something runs it with a unique bot password (referred to as a token).

You must have the following things ready.

Invite the bot

  1. Go to your Discord Developer account. Create a new bot by clicking New Application.

  2. Give it any name. Click Create. You should now see some general information pertaining to the bot.

  3. On the left-hand side, click OAuth2.

  4. Under Scopes, check off the Bot check box.

  5. Under bot permissions, tick Administrator (should be in the Scopes section).

  6. Copy and paste the generated link into your web browser.

  7. Under Add a bot to a server, select the server that you created. Someone else's server can work, too.

However, if you don't see the server listed, here is why: Only server owners and server members with 'Administrator permissions' can invite bots to servers. You are not the server owner and you don't have admin permissions. In that case you must:

  • Send the invite link to the server owner or someone with admin permissions.
  • Ask the server owner, an admininistor or moderator to give you admin permissions.
  • Create your own server if the above isn't a feasible option.
  1. Click 'Authorize'

You should see the bot listed on the right-hand side. It should be offline. The next step is to run it.

Run the bot

  1. Open PyCharm
  2. Clone the repository into the current project
  3. Edit Configuration -> Script Path -> Select bot.py
  4. Python 3.6 - 3.8 is recommended
  5. Install discord.py package (using pip or project settings). It may be best to install the discord.py version listed in requirements.txt.
  6. Go to your Discord developer account and create the bot.
  7. Copy the bot token.
  8. At the very bottom of the bot.py module, paste the token so it looks like this:
client.run("1234567890aBuNcHoFrAnDoMlEtTeRsToO")
  1. Run the bot

The bot should now be online and running in the server. You may execute !help for further instructions.

However, I strongly recommend completing the following server checklist before executing the more extensive functionality. In the probable case that not every use case was handled for new servers, it may not be clear why the bot could be throwing an exception.

Server Checklist

1 - Channels

Have the following channels created in your server:

  • #landing - used for the authentication panel, that can be sent out by entering !auth
  • #bot-commands - is exclusive to some commands, and may be used for updates or error feedback
  • #game-lab-availability - is used for live/dynamic gaming lab PC usage updates
  • #help-directory - used for the visual contact information cards used as embeds
  • #game-selection- download the necessary emojis under releases to use this
  • #event-subscriptions - used for temporary and/or permanent events- this feature is subject to deprecation

2 - Emojis

Download the custom emojis used by the server here and upload them to your server with the following names:

  • RocketLeague
  • FIFA
  • Hearthstone
  • LeagueofLegends
  • SmashBrothersUltimate
  • Minecraft
  • TeamfightTactics
  • Runeterra
  • ApexLegends
  • Overwatch
  • Valorant
  • CSGO
  • Fortnite

Exact case is required

Optional- the following game channels are used for the @Game Manager contact info panels:

  • #overwatch
  • #valorant
  • #hearthstone
  • #league-of-legends
  • #fifa
  • #rocket-league
  • #fortnite
  • #smash-brothers-ultimate

These are case sensitive. Characters must be exact.

3 - Roles

Create the following roles, any color of your choice:

  • 'Auth-ed` - name it as exactly written. The authentication panel gives out this role to people who react to its checkmark.
  • Game Manager - used for the individual game channels as mentioned above
  • Tuesday Gamenight - at the time of writing this, currently the only supported event
  • FIFA
  • Hearthstone
  • Fortnite
  • Overwatch
  • Rocket League
  • Valorant
  • Smash Brothers Ultimate
  • League of Legends
  • Apex Legends
  • CS:GO
  • Minecraft

You may notice that some of these roles are also missing game channels. This is because only a handful of games are supported by Stockton in an official capacity. Thus, not every game will have a game manager.

4 - API tokens

Regarding the topic of using API tokens, you have 3 options:

  1. Disregard or comment out the functionality that's responsible for processing API data
  2. Create your own developer accounts and use your own generated API tokens
  3. Reach out to me for access to the API tokens

The bot should work okay without API tokens. In the case that something doesn't work as intended, I would recommend adding the following environment variables as instructed in the next section.

5 - Environment variables

Have your environment variables for the following. Whether you input completely arbitrary or valid data is your decision.

PyCharm environment variable setup instructions here.

Discord

  • TOKEN - your bot's token

Google Chrome webscraping

  • GOOGLE_CHROME_BIN - /app/.apt/usr/bin/google-chrome-stable - used for web scraping
  • CHROME_EXE_PATH - /app/.chromedriver/bin/chromedriver - used for web scraping
  • DROPBOX-API-TOKEN - this is the sensitive JSON file used to access the Google Sheets API. If you create your own Google Developer account, you can just put the JSON file in your root directory.
  • DROPBOX-PATH-CREDS - I put the path to my JSON credentials in the root of dropbox folder, as such: /credentials.json

Twitter

Note: If you choose not to work on the Twitter feed, you can enter completely arbitrary numbers for the following:

  • ID-TWITTER-STOCKTON-ESPORTS - you can obtain any Twitter user ID from this website
  • TWITTER-API-KEY - submit an application for access to the Twitter API here
  • TWITTER-API-KEY-SECRET - Submitting an application is super easy- just know your rate limits
  • TWITTER-ACCESS-TOKEN - and be transparent about your intentions.
  • TWITTER-ACCESS-TOKEN-SECRET - Just an additional set of access tokens.

6 - Finally

Type !help for a list of available commands.

Contributor instructions

The Google Sheets config file

This bot queries customizable information used in a Google Sheets document. For access to this document, please contact me or browse the Discord server's #help-directory for more information.

Granted, you can completely omit the use of a config file and hard code your data. But if you'd like to reference my current setup, you're more than welcome to contact me and take a look.

Other

To emphasize: I would recommend using environment variables for your bot's protection. Should your bot token be exposed in plain-text, attackers can maliciously alter your bot. You will want to use Python's os library to safely encrypt your token. Refer to bot.py for the syntax.

For changes that you make, please commit your changes in a separate branch. When you are finished with your code and have fully tested every test case, create a pull request to merge it with the master branch. Since Heroku runs off of the master branch, any final changes you made will be reviewed by me or potentially any future admins.

Lastly, please remember to git ignore your .idea and venv folder. In short, having them can expose the bot token. This is an essential requirement for your changes to be accepted.

I'm available for contact, so please let me know if you have any questions.