-
Notifications
You must be signed in to change notification settings - Fork 0
Modification
The bot is open source. This means that you can edit, and modify the Python code to do what you want with it. We are totally fine with this - but please note we will not help you in our help server on Discord, if your problem appears to be directly caused by your changes.
As a small guide, we've written some information below about modifying the bot. The bot uses the libraries youtube-dl
and discord.py
to download and stream media, as well as interact with Discord.
General notes:
- The class
MusicBot
is a subclass of discord.Client so you should useself
when using discord.Client functions inside the class inbot.py
- Most functions are a coroutine, so you should insert the
await
keyword before using it
The following utility functions can be used in the MusicBot
class (bot.py
), which handle and deal with exceptions properly.
-
safe_send_message (in substitute of discord.py's
send_message
) -
safe_edit_message (in substitute of discord.py's
edit_message
) -
safe_print (in substitute of
print
- handles Unicode issues)
Our command framework is easy enough to work with. To create a new command, define a new asynchronous function that starts with the cmd_
prefix. It accepts the following arguments (which will be passed by the event on_message
):
-
message
- The Message that triggered the command -
channel
- The Channel that the command was triggered in -
author
- The Member that triggered the command -
server
- The Server that the command was triggered in -
player
- The MusicPlayer (seeMusicBot/player.py
) associated with the server (if available) -
permissions
- The Permissions that the user has -
user_mentions
- A list of all Members mentioned in the message -
channel_mentions
- A list of all Channels mentioned in the message -
voice_channel
- The voice Channel the bot is in on the server (if available) -
leftover_args
- A list of the arguments given with the command that aren't required arguments
Notes about commands:
- Docstrings are used when using
!help command
or when a user doesn't use the command correctly (e.g missing arguments)
async def cmd_ping(channel):
"""
Usage:
{command_prefix}ping
Ping command to test latency
"""
await self.safe_send_message(channel, "Pong!")
async def cmd_sendall(args, leftover_args):
"""
Usage:
{command_prefix}sendall <message>
Sends a message to all servers the bot is on
"""
if leftover_args:
args = ' '.join([args, *leftover_args])
for s in self.servers:
await self.safe_send_message(s, args)
If you have issues with and need help with the discord.py library that is used by MusicBot, you can join the Discord API server by clicking the banner below: