So basically we needed a discord bot that fetches the top post of the week from a given subreddit every week.
While we were programming it, we thought why not make it "potent", which resulted in a fully working, multiserver bot.
To get a local copy up and running follow these simple steps.
You should already have installed python and create a discord bot with the token on hand/ready to paste. A MongoDB database is also required.
- Clone the repo
git clone https://github.com/IQisMySenpai/RedditTopOfBot.git
- Create a token file
cd 'Your repo location' touch secret.py nano secret.py
- Put in your:
token, db username, db password, db name, queue collection name, server collection name
Then save and exit.
Example of the content of the secret.py file. Make sure not to add this file to your git, since your token etc. is a secret.
TOKEN = "KSciUF702bY3brOci1E9BG24Yz0KnBS1jc30aQUw" db_username = "bot_user" db_password = r"dZnep2emk6Sin7PMAj2Hfrb27zFvyw" db_name = "TopOfBot" col_queue = "queue" col_servers = "servers"
We are using MongoDB Atlas for hosting the db. If you are hosting it yourself you might need to change the client link in mongo_api.
Heroku is our current host for the bot. You will need to generate a Procfile for controlling the bot.py
For running the bot simply run:
python3 bot.py
Commands for RedditTopOf:
- changePrefix [prefix]
Changes the prefix that is used in front of command.
[prefix] can be any text/character - getImage [subreddit] [topOfTime]
Fetches the top post of the given time span
[subreddit] is the subreddit you want. Can be r/name or just name.
[topOfTime] needs to be one of ('hour', 'day', 'week', 'month', 'year', 'all'). - addInterval [subreddit] [topOfTime] [hours] [startTime]
Fetches the top post of the given time span every given hour
[subreddit] is the subreddit you want. Can be r/name or just name.
[topOfTime] needs to be one of ('hour', 'day', 'week', 'month', 'year', 'all').
[hours] how long the bot waits before sending another post. Minimum is 0.25.
[startTime] (optional) starts the Interval at a given time hh:mm. 24h format; Zero-padded (02:05); 24:00 is invalid. UTC timezone. - listIntervals
Lists all your Intervals - deleteInterval [name]
Deletes a interval of guild
[name] of Interval (or * for all) - help
Prints Commands - option [name] [value] (Admin Only) Set server options. [name] Name of the option [value] Value of the option Options: NSFW [true/false] Show NSFW content changePrefix [text/character] Changes the prefix that is used in front of command
- fuckYou
Insult the bot for a funny reaction - version
Prints Version
Maybe if we are bothered we might integrate timezones, but currently we don't a F, since everything works :D Or we could add Video, Text and Gallery Support.
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Project Link: https://github.com/IQisMySenpai/RedditTopOfBot Developer Server Link: https://discord.gg/UAxANEUfhN
Did 50% of the coding with 'Code with me' in PyCharm