This repository has been archived by the owner on Feb 9, 2021. It is now read-only.
Releases: ming-suhi/da-slash
Releases · ming-suhi/da-slash
v1.3.6
Release Notes
Edited Client Class
- Removed deleteCommand() method
To delete a command delete it from GuildCommand Class or GlobalCommand Class - Edited postCommands() method
Instead of getting command datas and posting it, this get all commands and calls the command post() function
Command Class Notes
- As a result of the postCommand() method of the Client Class being changed, don't use Command Class in creating commands, instead use GuildCommand Class or GlobalCommand Class
Added Classes
- GlobalCommand extends Command
- GuildCommand extends Command
v1.3.3
Release Notes
Methods Update
- Methods now return promises
Edited Client Class
- commands property removed
access commands through .commands() method - added .commands() method
- edited deleteCommand() method
removed guild constructor - postCommands() method Update
now logs Error instead of string - added .findCommand() method
Edited Interaction Class
- added .author() method
- added .guild() method
- added .channel() method
- added .bot() method
v1.3.2
Release Notes
Removed Client.getCommands() and made property commands
usage
//previous version
const slash = new Slash.Client(client, config);
console.log(slash.getCommands());
//new version
const slash = new Slash.Client(client, config);
console.log(slash.commands);
Changed Client.deleteCommand()
changed constructor guildObject to guildID
usage
//previous version
const slash = new Slash.Client(client, config);
let guild = client.guilds.cache.get(guild_id_here);
slash.deleteCommand(guild, commandID);
//new version
const slash = new Slash.Client(client, config);
slash.deleteCommand(guildID, commandID);
v1.3.1
Release Notes
Added New Class | Interaction
Discord client and Websocket Interaction now found in Interaction Class. Discord client and Websocket Interaction will not be passed down to execute function of Slash.Command, instead the instance of Interaction will be passed down instead. Discord client should be accessed through Interaction.client, and websocket interaction through Interaction.request.
usage
commandThree.js
module.exports = new Slash.Command({
name: 'invisible',
description: 'sends a hello world message visible to user only',
permissions: ["SEND_MESSAGES"],
execute(interaction) { // instead of execute(client, interaction)
interaction.sendEphemeral("Hello World")
}
})
Instead of passing web socket interaction to the method matchCommand, pass down the instance of Interaction.
usage
index.js
// previous version
client.ws.on('INTERACTION_CREATE', async request => {
slash.matchCommand(request);
})
// new version
client.ws.on('INTERACTION_CREATE', async request => {
const interaction = new Slash.Interaction(client, request);
slash.matchCommand(interaction);
})
Slash Interaction
constructor
new Slash.Interaction(discord_client, interaction)
methods
.sendMessage(content) - sends a message
.sendEphemeral(content) - sends an ephemeral(user-visible only) message
.sendEmbed(discord_embed) - sends an embed
usage
commandTwo.js
module.exports = new Slash.Command({
name: 'invisible',
description: 'sends a hello world message visible to user only',
permissions: ["SEND_MESSAGES"],
execute(interaction) {
interaction.sendEphemeral("Hello World")
}
})
v1.2.1
v1.2.0
v1.0.0
Slash Client
constructor
new Slash.Client(discord_client, config);
methods
.getCommands() - Returns a map of commands
.postCommands(discord_client) - Posts/updates all commands
.deleteCommand(discord_client, guild, command_id_here) - Deletes chosen command from a certain guild
.matchCommand(discord_client, interaction) - runs through all commands and executes match
usage
index.js
const config = {
"commands": {
"directory": "/path/to/commands", //path to commands folder
"subcategories": "false" //if commands are divided by folders change to "true"
},
"bot": {
"token": "bot_token_here"
}
}
const Discord = require('discord.js');
const client = new Discord.Client();
const Slash = require('da-slash');
const slash = new Slash.Client(client, config);
client.once('ready', () => {
//updates Commands
slash.postCommands(client);
//deletes Command
let guild = client.guilds.cache.get(guild_id_here);
slash.deleteCommand(client, guild, command_id_here)
})
//emitted when a slash command is detected
client.ws.on('INTERACTION_CREATE', async interaction => {
//finds the appropriate slash command and executes it
slash.matchCommand(client, interaction);
})
client.login(config.bot.token);
Slash Command
constructor
new Slash.Command(data);
data
name - name of command
description - description of command
permissions - required permissions to execute command
options - options for command
execute - function to be executed, will not be executed if permissions are not met and sends an ephemeral message
usage
commandOne.js
module.exports = new Slash.Command({
name: 'hello',
description: 'sends ',
permissions: ["SEND_MESSAGES"],
execute(client, interaction) {
// sends "Hello World!"
client.api.interactions(interaction.id, interaction.token).callback.post({
data: {
type: 4,
data: {
content: "Hello World!"
}
}
});
}
})