Splite
SPLITE - Discord Bot with Slash Command Handler and Endpoint Handler, supporting AI, Music, Moderation, and more!
Install / Use
/learn @416rehman/SpliteREADME
SPLITE - Multi-Purpose Discord v14 Bot
Now with Slash Commands, Music, Moderation, and more!
New in Splite 5.0: Discord v14 support, YAML configuration, and many bug fixes
Splite is a free to use multipurpose Discord bot. It is designed to be a flexible and easy to use. ⭐ Consider starring the repo on GitHub to help with development! ⭐
<hr/>Features
- Robust and flexible command handler supporting text-based and slash commands, restrict to permission level, VCs, NSFW channels, bot owners, bot managers, and more.
- Endpoint handler to listen to and respond to external web requests (Webhooks).
- Music Module to play music in voice channels from YouTube, SoundCloud, and Spotify.
- Logging features
- Sniping features to see the last deleted or edited message in a channel.
- Daily activity features and rewards (Points are earned through being active, most active user gets a role as reward until anothe winner is chosen the next day)
- Betting and Gambling features - Users can gamble and bet against other users to win or lose their daily points.
- Leaderboards to see the top active users, top moderators, and top points users.
- Fun commands such as ship, mock, whowouldwin, and many many more.
Table of Contents
- Setup
- Cloud Configuration
- Modifying Functionality
- Command Handler
- Endpoint Handler
- TopGG Integration
- Commands
Setup
Prerequisites
- Clone the repo and install the dependencies with
npm install - Add the emojis from
emojis.zipto your server and update the emoji IDs insrc/utils/emoji.jsonto match your server's emoji IDs
Configuration
- Create a copy of the
config.default.yamlcalledconfig.yaml. - Fill the
config.yamlfile or alternatively, provide the corresponding environment variables (Click here for more information). - OPTIONAL: If needed, environment variables can be used instead of a config file.
Starting the Bot
- Run
npm run registerto register all slash commands - Run
node app.jscommand to start the bot
If you wish to run the bot over pm2, use the command pm2 start
Cloud Configuration
Splite's configuration can be set via environment variables. This is useful for cloud deployments such as Heroku, and Repl.it.
Keep the following in mind when using environment variables:
- Prefix the configuration key with
SPLITE_. - Environment variables MUST be in all caps.
- List values are separated by a comma.
- Nested properties are separated by an underscore
Example:
| CONFIG.YAML | ENVIRONMENT VARIABLE | |----------------------------------------|--------------------------------------------| | token: "1234567890" | SPLITE_TOKEN=1234567890 | | owners: ["1234","1234"] | SPLITE_OWNERS=1234,1234 | | apiKeys.topGG.api_mode.token: "q1w2e3" | SPLITE_APIKEYS_TOPGG_API_MODE_TOKEN=q1w2e3 |
For convenience, the bot will output an environment variable equivalent of your config file upon startup.
Docker
To run the bot in Docker, fill the config.yaml config file, and run the following commands:
docker build -t splite .
docker run -d --name splite splite -v ./config.yaml:/home/node/app/config.yaml
You can also use environment variables by setting them in a .env file and running the following commands:
docker build -t splite .
docker run -d --name splite --env-file .env splite
For more information on the environment variables, see Cloud Configuration.
Modifying Functionality
Commands are stored in /src/commands/{category}/ directory<br>
Events are stored in /src/events/ directory<br>
Endpoints are stored in /src/endpoints/ directory<br>
Command Handler
Splite has a powerful command handler that extends the calypso handler, allowing you to serve both classic commands and slash commands from the same command class.<br>
Command Handler Features
- Cooldowns
- Exclusive / Instanced Commands (Only one instance of the command will be run per user, until the done() method is called)
- Aliases
- Categories/Types
- VC Only Commands
- NSFW Only Commands
- User Blacklist (Bot owner can use
blacklist @userto blacklist a user) - Restricted Commands -
Ownertype commands can only be used by the bot owner,Managertype commands can only be used by the bot managers and owners.
Creating Classic and Slash Commands - Code Sample
A command can be implemented using a classic text-based command, a slash command, or both.
In this section you will see how to create a command that can be used both as a classic command and a slash command.
Hybrid (Text and Slash) Command - Shows the avatar of a user
Classic text commands use the run(message, args) method of the Command class. Slash commands use
the interact(interaction, args, author) method of the Command class.
// src/commands/fun/avatar.js
// Avatar Command
const Command = require('../Command.js');
const {EmbedBuilder} = require('discord.js');
const {SlashCommandBuilder} = require('discord.js');
module.exports = class AvatarCommand extends Command {
// Command Info and Staging
constructor(client) {
super(client, {
name: 'avatar',
aliases: ['profilepic', 'pic', 'av'],
usage: 'avatar [user mention/ID]',
description: 'Displays a user\'s avatar (or your own, if no user is mentioned).',
type: client.types.INFO,
examples: ['avatar @split'],
slashCommand: new SlashCommandBuilder()
.addUserOption((option) =>
option.setName('user').setDescription('The user to display the avatar of.')),
});
}
// Text Based Command Listener
async run(message, args) {
const member = await this.getGuildMember(message.guild, args.join(' ')) || message.member;
this.handle(member, message);
}
// Slash Command Listener
async interact(interaction) {
await interaction.deferReply();
const user = interaction.options.getUser('user') || interaction.member;
this.handle(user, interaction);
}
// Core Logic
handle(targetUser, context) {
const embed = new EmbedBuilder()
.setDescription(`[Avatar URL](${this.getAvatarURL(targetUser)})`)
.setTitle(`${this.getUserIdentifier(targetUser)}'s Avatar`)
.setImage(this.getAvatarURL(targetUser));
this.sendReply(context, {embeds: [embed]});
}
};
Command Types
- MISC: This is the default type, and is used for commands that do not fit into any other category.
- INFO: Commands that do not change the state of the data and are used to display information.
- FUN: Commands that are used to entertain people.
- POINTS: Commands that are used to manage user points, gambling, economy, etc.
- SMASHORPASS: Commands that are used by the Smash or Pass system.
- NSFW: Commands that are NSFW (Not Safe For Work). NOTE:These command will only work in NSFW channels.
- MOD: Commands that can be used by server moderators to manage the server.
- MUSIC: Commands that are used by the music system.
- ADMIN: Commands that can be used by server admins to manage the server.
- MANAGER: Commands that can be used by bot managers. NOTE These commands can ONLY be used by bot managers (set in config.yaml).
- OWNER: Commands that can be used by the bot owner. NOTE These commands can ONLY be used by the bot owner (set in config.yaml).
Restrictions
These are the restrictions that can be set for a command.
Restrict command to Voice Channels
To restrict a text command to only be used if a user is in a voice channel, add and set the voiceChannelOnly property
to true.
Example:
voiceChannelOnly: true // Default is false
Restrict command to NSFW channels
To res
