config.py API¶
This page assumes you’ve completed Creating a Simple Hello World Module. If not, check the previous pages.
Ok, you made your module, everything’s going well. But (just pretend) your module
doesn’t support multiple servers, and you need to do something specific if that option’s
enabled. That’s where the config.py API comes into play. It’s an API with a single
function: monium.config.get()
, so an example should be enough:
import discord
from monium.config import get
from monium.module import Module
class HelloWorldModule(Module):
id = "helloworld"
name = "Hello World Module"
version = (1, 0, 0)
authors = ["Admicos"]
async def on_ready():
if get("MULTIPLE_SERVER_SUPPORT"):
self.logger.info("Multiple server support enabled.")
for channel in self.client.get_all_channels():
if channel.type == discord.ChannelType.text:
await self.client.send_message(channel, "Hello, world!")