A Discord bot cog for updating and restarting the bot via slash commands. This cog allows developers to pull updates from GitHub, update dependencies, and restart the bot seamlessly.
- GitHub Auto-Update: Pulls the latest code from GitHub.
- Dependency Management: Automatically updates Python dependencies.
- Restart Functionality: Restarts the bot after applying updates.
- Developer-Only Access: Restricts update commands to specified developers.
- Error Handling: Provides detailed error messages for failed updates.
Ensure you have the following installed:
- Python 3.10+
discord.pylibrary- A bot set up with Discord API
- Git installed
-
Clone this repository:
git clone https://github.com/unclemelo/Updater-Cog cd Updater-Cog -
Install dependencies:
python3 -m pip install -r requirements.txt
-
Add the cog to your bot's main file:
import discord from discord.ext import commands bot = commands.Bot(command_prefix="!") async def setup(): await bot.load_extension("updater") bot.run("YOUR_BOT_TOKEN")
-
Replace the following placeholders in
updater.py:- Developer IDs (
devs = {0}) → Add your bot admin Discord IDs. - Update Channel ID (
UPDATE_CHANNEL_ID = 0) → Replace with the Discord channel ID for update logs. - GitHub Repo Link in
notify_updates().
- Developer IDs (
| Command | Description |
|---|---|
/update |
Pulls the latest updates from GitHub, updates dependencies, and restarts the bot (Dev-only). |
- Developer executes
/update. - The bot fetches updates from GitHub.
- Dependencies are updated.
- The bot announces the update in the specified channel.
- If updates are found, the bot restarts.
Contributions are welcome! Feel free to submit pull requests to improve this cog, fix issues, or add new features. You can also create other versions of this updater in different languages, such as updater.js, updater.cs, etc., and submit them to the repository.
This project is licensed under the MIT License.