Create a configuration variable#
🤝 Help us building this project!
This part of the documentation is still under construction. If you want to help us, you can contribute to the project on GitHub or come on our Discord server.
In the config/options.json file, define your configuration variable like this:
{
"foo": {
"default": "bar",
"type": "text",
"command": "foo"
}
}
Note: the type can be either:
text
int
float
channels
categories
Note: by convention, the name of the configuration variable and the name of the associated command are the same.
Just write a commande that will edit this config:
@commands.command(name="foo") # tell to discord.py that the next function is a discord command
async def foo(self, ctx: MyContext, *, bar):
await ctx.send(await self.bot.sconfig.edit_config(self, ctx.guild.id, "foo", bar)) # It will edit the config and send a confirmation message
In the __init__ function of you main plugin class, link your
bot.get_command("config").add_command(self.foo) # tell to discord.py that the command we defined is actually a sub-command of the "config" command