Introduction
Simple Discord is a simple way to to make Discord bots in Python. This library is still in beta, so I recommend not using this in production yet.
How to Install
To install Simple Discord, you have to have Python pip3 installed on your machine. Run the following command in a Command Prompt or Terminal:
pip3 install simple-discordAnd to update:
pip3 install -U simple-discordA Basic Bot
To keep things simple and easy to use, Simple Discord revolves around the use of parameters. A parameter is something you put in a function's parenthesis that tells the function how to behave. Lets look at an example:
from simple_discord import simple_discord #Import the library
discord_bot = simple_discord.simple_discord_bot()
discord_bot.add_command("!test", "You just created a Discord bot!") #The first two parameters are required. The first one is the message that you send to trigger the response, and the second one is the message the bot will respond with.
discord_bot.add_command("!ping", "Pong!") #You have no limit on the commands you can add to your bot.
discord_bot.set_token("Put your bot's token here") #Put your bot's token in the double quotes.
CAUTION
The "set_token" method has to always come at the end of the file. This is because the "set_token" method will start your bot, and everything after that line will be ignored.
Adding Features to our Bot
In the last section, we created a bot that can only respond to command. Lets add some extra functionality to our bot. Here are all the parameters that simple_discord currently supports:
reaction: Needs the emoji itself copied and pasted into a string. A good website where you can get emojis from is getemojis.com. The paramerter "react_to" is also needed for this to work.Type: string
react_to: Bot will react to either the command that triggered the response, or the bot's response. Type "command" for the bot to react to the message that triggered the bot's reponse, or "response" for the bot to react to the bot's own response.
Type: string
Delete: If set to True, bot will delete the message that triggered the bot's response.
Type: boolean
connect_to_voicechannel: If set to True, bot will join the author's channel they are in. If they are not in one, bot will print an error to the console.
Type: boolean
source_to_play: Plays a source. Put the path/file name that you want the bot to play. Please note that the "connect_to_voicechannel" parameter must be set to True for this to work.
Type: boolean
DM: DMs the person that triggered the response a message.
Type: string
Examples
Now that we have learned all the parameters the this library currently supports, we can do more advanced things with our bot. Lets look at some examples.
Example of a bot that reacts with a
from simple_discord import simple_discord #Import the library
discord_bot = simple_discord.simple_discord_bot() #Make our object to connect to Discord.
discord_bot.add_command("!hi", "Done.", react_to="command", reaction="😁", DM="Thank you for using this bot!")
discord_bot.set_token("Put your bot's token here") #Put your bot's token in the double quotes.
Example of a bot that joins a voice channel and plays music from a file called "audiosource.mp3":
from simple_discord import simple_discord #Import the library
discord_bot = simple_discord.simple_discord_bot() #Make our object to connect to Discord.
discord_bot.add_command("!play", "Playing.", connect_to_voicechannel=True, source_to_play="audiosource.mp3")
discord_bot.set_token("Put your bot's token here") #Put your bot's token in the double quotes.
Bot settings
You can set settings for your bot with the ".config" method. Here are the parameters/settings you can choose from:
show_dms: If set to True, bot will print DMs it gets from people.
Type: boolean
status: Changes the status of the bot. Must be one of the following: "online", "idle", "do not disturb", and "offline".
Type: string
activity: Changes the bot's activity.
Type: string
respond_to_other_bots: If set to False, bot will not respond to other bots.
Type: boolean
Examples
Lets look at examples of how to use settings for your bot:
from simple_discord import simple_discord_bot #Import the library
discord_bot = simple_discord.simple_discord_bot()
discord_bot.add_command("!hi", "Hello!) #Add a command
discord_bot.config(show_dms=True, status="idle", activity="This is a bot made with simple_discord!") #Changing some settings
discord_bot.set_token("Token Here") #Put your token there.
Help and Support
Join our server for help or comments about this library.