Common Usage Cases
Core Setup Guide#
We are going to learn how to start using library and combine it with currently used code.
We are going to use discord.js package.
Setup#
Here is the very simple discord bot setup we're going to use.
- TypeScript
- JavaScript
Creating Client#
Now that we have a basic setup we can create our GatewayClient to start interacting with dclist
- TypeScript
- JavaScript
Voter-Only Commands#
You may have some voter-only features. You can do that easily using official sdk.
There is as veeery simple example for using #isUserVoted method of GatewayClient.
- TypeScript
- JavaScript
Subscribe to Events#
Dclist using a bit different system to handle real time events. Instead of creating an express just for new vote event, directly connecting to server using websockets.
That means you don't have to set up any other settings to use events.
Here is a veeery simple vote logger code just to give an idea.
Demanding Events#
First you need to tell server about which events you want to receive. Then server will start sending events in real time to you.
- TypeScript
- JavaScript
Handling Events#
When a real time event received, GatewayClient will emit an event named same as received event's type.
- TypeScript
- JavaScript
AutoPoster Usage#
You need to send some report to the site so we can display your bot's guild, user, etc. count and track your growth rate for you.
You can achive that with few lines of change. There is an example for sharded and standalone bots.
Stand-Alone Bot Setup#
- TypeScript
- JavaScript
Multi-Sharded Bot Setup#
Shard Manager File#
- TypeScript
- JavaScript
Shard Client File#
- TypeScript
- JavaScript