Discord-ExpireBot
Discord-ExpireBot copied to clipboard
Allows to create expiring Roles in Discord
Discord-ExpireBot
This Bot allows you to let roles expire. If you set e.g. the @voted role to 12h, the role will get removed automatically 12h after obtaining. This is individual to all users on the guild. It also saves the obtaining time into a JSON File, so if the Bot gets temporary offline, it can handle this.
Join my Discord Server if you have any question/feedback or just want to talk.
Commands
Command | Function | Permissions Required |
---|---|---|
%help |
Disply Help Embed | |
%expire <role> <time> |
Set Role to Expire | Bot Manager |
%unexpire <role> <time> |
Set Role to not Expire | Bot Manager |
%viewroles |
View Expiring Roles | |
%addperm <role> |
Grant Role Bot Manager perm | Manage Roles |
%delperm <role> |
Revoke Bot Manager perm for Role | Manage Roles |
%viewperms |
View wich Role has Bot Manager perm | |
%ping% |
Display the Bot's latency | |
%stop |
Stop/Shutdown the Bot | Be the Bot's Owner |
Credit
This Bot is based on code not made by me. The Creator of that piece of code wants to stay private, so I can't link them. Go to legacy branch for more information.
Everything I coded afer this was either made by me or is mentioned below.
I'll probably host the bot and make it public so anyone can use it, but I currently can't afford it.
Thanks to DerSeb90 for fixing a Critical Bug!!!
I also want to say thank you to:
Invite
(currently only works on one server so its disabled) https://discord.com/api/oauth2/authorize?client_id=786697105838309426&permissions=268438656&scope=bot
Permissions
List of all Permissions the Bot needs to function properly.
I recommend giving the Bot admin perms, so you can't do something wrong with the perms
Permission | Why its needed |
---|---|
View Channels/Read Messages | To listen to your commands |
Send Messages | To reply to your commands so you know whats happening |
Add Reactions | Sometimes the Bot just reacts to your commands instead of replying |
Manage Roles | To unassign the Role that should expire |
View Audit Log | To know when somebody obtained a specific Role (to know when to remove it again) |
Administrator |
People reported that the Bot sometimes doesn't work properly and that giving it admin perms fixes those problems |
Contributing
Consider giving this Repo a star if you like it and vote for the Bot at top.gg!!!
Write issues and pulls! Test and Report! This helps the project.
Also I don't mind donations ;)
If you have any question or feedback, feel free to Contact me
I'm looking for someone who can create the logo for ExpireBot. Join my Discord and go to #logo-submission
Hosting the Bot
The Bot currently only supports 1 Guild per Bot so you need to host your own copy.
You can Selfhost it ony your PC (I'd recommend to use a Raspberry Pi because its cheap and bc its easier to setup), on a VPS, or any other hosting Service.
Quick summary for experienced people: You can either use the .env file or environment variables to store the secrets (Using dotenv). All dependencies are listed with their PyPI/pip name in requirements.txt)
If you need a tutorial expand the Dropdown tag below
Step-by-Step Tutorial
Prerequisites
You must have an account for Discord [Link]
Creating a bot to get a bot token
- Create an application in the developer portal by clicking here
- Open up your new application and click 'Add Bot' under the Bot settings to create your bot.
- Enable Both Intents
- After creating the bot, click the 'Copy' button under the title Token. Take note of your token as you will need it later. Keep the token secret!!!!
Downloading Repo and configuring it
- Download / Clone the Repo as zip file and unpack it
- Change the values in .env with a text editor of your choice
- discord_token=
(Enter the bot token that you copied from the developer portal)
- guild_id=
(Enter the ID of your Server. Rightclick on your Server on Discord and then click on 'Copy ID')
Setting Up Dependencies and Running the Bot
For Linux (Raspberry Pi)
- Open a Terminal in the Repo's location
- Run
python3 -m pip install -r requirements.txt
in to install dependencies - You're ready to start the Bot! (
python3 ./bot/main.py
or double click main.py in thebot
folder)
For Windows 10
- Install Python if you don't have it
- Recommended options:
Install for all users (as admin)
Add to path
- Recommended options:
- open cmd (as admin) and cd to the repo
- open the unpacked zip file in explorer
- click the bar at the top of explorer
- Copy it (Press
CTRL
+C
) - Press
Windows
+ R and type cmd into the Window that opens - Press
CTRL
+SHIFT
+ENTER
and confirm the popup with yes - enter
cd /D
into the command prompt and pressCTRL + V
or Rightclick -> Paste - Press
ENTER
- Run
pip install -r requirements.txt
to install dependencies - You're ready to start the Bot! (type
py bot\main.py
in the console prompt or simply double-click main.py in thebot
folder)
None of the above
Downloading Repo and installing dependencies
- install python if its not already installed
- install the missing requirements by running
pip install -r requirements.txt
in the repo's folder
Host using repl.it
Note that you won't have 100% uptimehttps://repl.it/talk/learn/Hosting-discordpy-bots-with-replit/11008
Host using Heroku (not recommended)
Check out the original tutorial from https://github.com/audieni/discord-py-heroku/ Note that Heroku doesn't have a persistent storage so you'd have to use some other storage addons. (You can't use the Bot without persistent storage)Prerequisites
You must have an account for Discord [Link], GitHub [Link] , and Heroku [[Link (https://signup.heroku.com/)].
How to fork the repository and set it up to work with Heroku?
- Fork a copy of this repository by clicking the 'Fork' on the upper right-hand.
- Create an application for Heroku by clicking here.
- Under 'Settings', click on 'Reveal Config Vars' and enter the following:
- KEY => discord_token
- VALUE => (Enter the bot token that you copied from the developer portal)
- Click the 'Add' button after entering all of this information. same for the GuildID:
- KEY => guild_id
- VALUE => (Enter the ID of your Server. Rightclick on your Server on Discord and then click on
Copy ID
) - Again, click the 'Add' button after entering all of this information.
- Under 'Deploy', do the following:
- Deployment Method => Connect your GitHub
- App connected to GitHub => Search for the forked repository
- Automatic Deploy => Enable Automatic Deploy (to redeploy after every commit)
- It should look like something like this:
- Under 'Resources', do the following:
- Click on the 'Pencil' icon.
- Switch the worker from off to on.
- Click 'Confirm' to finalize the decision.
- NOTE: You are allocated 550 free Dyno hours, which will not last the entire month. However, if you provide a credit card to verify your identity, you are given an additional 450 hours, which will allow your bot to run indefinitely.
Getting an Invite Link
- Go to your Bot's page at Discord Developers
- Click on "OAuth2" and scroll down to "OAuth2 URL Generator"
- Select the
bot
scope - Select all Required Permissions
- Click on the Copy button next to the Link
- The Invite Link is now in your Clipboard. Now just go to your Browser and paste it in the URL Bar.
First Steps
After inviting the Bot you can start configuring it.
- Go to the Role Settings of your Server and pull the Role of ExpireBot as high as possible. (At least higher than the Role you want to expire)
- Choose wich Role(s) can manage the Bot using the addperm command (e.g.
%addperm @Owner
) - Select the Role(s) you want to expire
FAQ
Read this before writing issues
Q: Where is the invite Link?
A: The Bot currently only works for 1 Server at the time. This will be changed in a future Release. So there is no Invite Link. See Hosting the Bot to get your own invite Link.
Q: The Bot doesn't remove the Roles, but everything else seems to work
A: The Bot is probably lacking Permissions. Check if the Bot's Role has all required Permissions. Also make sure that the Bot's Role is higher than the Role you want to expire.
Q: I cant use the expire command (No Permission)
A: You neeed to configure wich Role(s) can change the Bot's settings using the addperm
command
Q: The Bot crashes and in the Error Message is something like "Privileged Intentes"
A: You forgot to enable two switches on Discord Developers (see Tutorial)
Q: The Bot crashes immediatly after startup
A: Make sure to install all dependencies and to use the lastest Version of Python. Also an invalid Token can crash the Bot. Check the .env File or the Environment Variables. If this doesn't help, check your Internet Connection
Q: The Bot works on my Server, but not on the second one
A: You need to host a seperate Bot for each of your Servers. MultiGuild Support is being worked on.
Q: I like this Project! How can I help?
A: Check Contributing and CONTRIBUTING.md
Q: I need help!
A: Ask in my Discord Server, write an issue or a discussion on GitHub, or contact me directly. Same thin for giving feedback etc.
Copyright
Discord ExpipreBot
Copyright (C) 2021 hxr404
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.