djs-test-client
v1.0.3
Published
A discordjs wrapper to simplify testing
Downloads
11
Maintainers
Readme
Disclaimer
This small library was written to simplifiy testing for our bot. I am not familiar with all features of the discord.js API, and the test client currently only provides features needed to test our bot. However I am more than happy to implement any requests. If you want to request a change simply open a ticket describing the feature. If you want to contribute to the project yourself checkout "Contributing".
Installation
npm install discordjs-test-client
Setup
In order to connect the client needs a dicord API token.
You can currently only provide this as an environment variable named DISCORD_CLIENT_TOKEN
.
Description
Bots written in discord.js are often hard to test. To make it easier this testing client creates its own guild for every test suite or instance. It provides a sendMessage
function to send customizable messages in to any provided channel in the guild and react to it.
Usage
Import the TestClient
and create a new instance using the static connect
function.
This creates a new guild for testing purposes.
- Use the
createTextChannel
orcreateVoicehannel
functions to create a newChannel
- Pass the created channel to the
sendMessage
function to send a message in this channel (The message your bot should react to) - Use
getMessages
to get the lastn
messages - Check if your bot reacted to the previously sent message properly
The full functionality can be looked up in the typedoc.
Contributing
You can contribute by creating a forkof this repository. Implement your changes and open a pull request on this repo.