Skip to content

xander_plugin api

Ccode-lang edited this page May 17, 2024 · 1 revision

xander_plugin API

Purpose

The Xander plugin API is defined to help access methods and variables stored in bot.py. Below are some of the defined bindings.

config

Config is a module that holds all Xander configurations. It is written in Python for simplicity and compatibility with Python. (Exact definitions in config.py)

def log(line)

A function that prints line to the terminal with a timestamp and saves the message to log.txt. It returns nothing.

async def modlog(string, message, delete=False)

A function that can be used to create moderator logs in the modlog channel defined in config.py. string is the message that is sent to the modlog channel by the bot. message is the message variable of the moderated message. (message is required because it is used to differentiate servers) When delete is True the message referenced by message is deleted after sending string to the modlog channel.

client

client is the client object of the bot. More information at https://discordpy.readthedocs.io/en/stable/api.html#discord.Client.

help_menu

help_menu is the help menu dictionary. It can be interacted with by plugins to add help entries for them. help_menu_edit which is listed later can be used to add entries to this.

voice_client

The voice client object of the bot if it is connected to a voice channel. Equals None if not connected to a channel. Check https://discordpy.readthedocs.io/en/stable/api.html?highlight=voice%20client#discord.VoiceClient to see how a voice client object works. Only keeps track of one voice client.

def getother(name)

Get the variable associated with a keyword from the bot.py file.

def help_menu_edit(feature_name, info)

Add a help menu entry for the plugin under the name feature_name and with the information provided in info.

async def join_vc(channel)

Join a voice channel passed in channel. This passes the current voice client into voice_client. If connected already this method does nothing. (Does nothing on Guilded)

async def leave_vc()

Leave the currently connected voice channel. Clears voice_client. If not connected this method does nothing. (Does nothing on Guilded)