Client.command() - shysolocup/noscord.js GitHub Wiki
creates slash commands from the client
type: Function
arguments:
- name/data
String/Object
: first argument can either be the name or an object with data - ?description
String
- ?options
Array
- ?nsfw
Boolean
- action
Function
: it'll always grab the last argument as the action
returns:
- context: interaction and info for the command
client.command("test1", "first test command", (ctx) => {
ctx.reply("this is a test command!");
});
client.command({ name: "test2", desc: "second test command"}, (ctx) => {
ctx.reply("this is a test command!");
});
let options = [{ name: "user", desc: "a user", type: "user", required: true }];
client.command("test3", "third test command", options, (ctx) => {
let userId = ctx.args[0].value;
ctx.reply(`Hi <@${userId}>!`);
});
client.command({ name: "test4", desc: "fourth test command", options: options }, (ctx) => {
let userId = ctx.args[0].value;
ctx.reply(`Hi <@${userId}>!`);
});