Testing framework for Discord bots.
Clone the Git repository and run code . to launch Visual Studio Code.
Select "Reopen in Container" when prompted.
- Open a terminal window with
Ctrl+'and run:python -m main <token> - Go to https://discord.com/developers/ and log in.
- Press "New Application" and enter "TestBot"
- Under "Installation" select "Discord Provided Link"
- Give it the "bot" scope and "Administrator" permissions.
- Go to "Bot" and "Privileged Gateway Intents", and grant all privileges.
- Go to the link given in #5 and add the bot to your server.
- Type "start" in any channel.
Tests must be files in: tests/test_*.py
Test functions must be of the form:
async def test_...():
# ...The general format of a test is to send a message to a channel and then check that the response from the bot is as expected.
from testbot import guild, channel, expect, embed
async def test_my_command():
ch = channel('general')
await ch.send('!my_command')
await expect(text('Command Response'))Fetch the current guild.
Fetch the channel with the given name.
Fetch the text channel with the given name.
Fetch the voice channel with the given name.
Check for a message in the given channel with the expected format.
The expectation may be a text or embed.
Expect a normal text message.
await expect(text('hello world'))Expect an embed with the given description and fields.
Each field is a dict with an optional name and value attribute.
await expect(embed('hello', {'name': 'a'}, {'name': 'b', 'value': 'c'}))