-
Notifications
You must be signed in to change notification settings - Fork 1
Extensions
Extensions provide all functions of the bot that can be used in Discord. Even loading and deactivating extensions is controlled by an extension (which is a special case).
The following commands are available for this:
Command | Argument(s) | Description | Example |
---|---|---|---|
!load |
extension: str |
loads an extension | !load general |
!unload |
extension: str |
unloads an extension | !unload general |
!reload |
extension: str |
reloads an extension | !reload general |
By the way, you can display all loaded and unloaded extensions with '!extensions'. Prerequisite for the listing is that it has been loaded at least once with the !load
command (only the extension management extension is an exception here again).
The name of each extension must be lower case and contain only letters.
Each extension should have a meta file. Meta information is stored in this file. The meta file for a new extension is placed in the directory /extensions/meta/
and is named after the name of the extension. The file extension is .json
.
An example for the extension general
is general.json
:
{
"name": "general",
"description": "Bietet grundlegende Befehle wie den Befehl `!info` und `!hilfe`.",
"author": "Titus Kirch"
}
The extension file is the heart of every event and provides the functions. The extention file for a new extension is placed in the directory /extensions/
and is named after the name of the extension. The file extension is .py
.
Each extension file must contain at least the following:
example.py
import discord
from discord.ext import commands
class Example(commands.Cog, name='Example'):
def __init__(self, bot):
self.bot = bot
####################################
# PLACE YOUR CODE HERE #
####################################
def setup(bot):
bot.add_cog(Example(bot))
Remember to replace the 'Example' (used three times in the example) with the name of the extension (in Capitalized Case).
Everything else can be found here in the developer documentation of discord.py. We recommend the additional entries for commands, extensions and cogs in the documentation.