-
Notifications
You must be signed in to change notification settings - Fork 0
Command Basics
Commands are stored inside the WC instance and they're a lot simpler to set up compared to Discord.JS and have a variety of features like cooldowns, arguments, aliases, etc
Prefix commands have a pretty basic setup only requiring a name to be created although they have optional aliases and cooldowns.
In this example let's make a prefix command called "ping" then tell it what to do when it's run
Let's say that you made your prefix "!" if someone were to say "!ping" in chat the bot would reply with "pong!"
wc.command("ping", async (ctx) => {
ctx.reply("pong!");
});
Now let's compare that to Discord.JS prefix commands:
// discord.js
client.on("messageCreate", async (ctx) => {
if (!ctx.content.startsWith(prefix) || ctx.content.endsWith(prefix) && ctx.content.startsWith(prefix)) return;
if (ctx.content.split(" ")[0].toLowerCase() == `${prefix}ping`) {
ctx.reply("pong!");
}
});
(If you ever need it the way to access commands is through wc.commandList)
When a command is run it returns ctx (message context) and cmd (command info)
- ctx is the context of the command's message/interaction including things like the author, guild, channel, etc
- cmd is the command's info such as name, aliases, arguments, cooldown, etc
Arguments are an array of things given after the command
For this example let's make a !say command, if the message is "!say arguments are a thing!" you can use that in your command like this:
wc.command("say", async (ctx, cmd) => {
console.log(cmd.args[0]); // "arguments"
console.log(cmd.args[1]); // "are"
console.log(cmd.args[cmd.args.length-1]); // "thing!"
ctx.channel.send(cmd.args.join(" ")); // sends "arguments are a thing!"
});
Aliases are alternate names for the commands
For this example let's make an avatar command with the aliases as ["av"] when someone says "!av" in chat it should run the command
wc.command( {name: "avatar", aliases: ["av"]}, async (ctx, cmd) => {
// if there is no argument it defaults to the message author
let user = await wc.fetchUser(cmd.args[0]);
return ctx.reply(wc.user.avatar(user));
});
Cooldowns are the time that it takes for a user to use a command again mostly used for reducing spamming
Let's take the last command and add a 1 second cooldown
wc.command( {name: "avatar", aliases: ["av"], cooldown: "1s"}, async (ctx, cmd) => {
if (cmd.onCooldown) return wc.reply("Command is on cooldown!", {deleteAfter: "1s"});
// if there is no argument it defaults to the message author
let user = await wc.fetchUser(cmd.args[0]);
return ctx.reply(wc.user.avatar(user));
});
for more info on things like time you can check out the page on time here
For a look at some examples check out the examples folder
If anything with the mod is updated you can look to the releases for info on it
For a look into the development check out the index.js file
This mod is not associated with the creators of Discord, Discord.JS, or Discord.PY this was created out of love for Discord bot development because I wanted to make things easier for people. I do not condone harassment of the original developers and or anyone else involved in the creation of them.
I am not responsible for anything made with this mod and be sure to follow Discord's terms of service and their community guildlines while developing.
Basics
wc.command()
wc.slashCommand()
wc.commandList
wc.slashCommandList
Basics
wc.event()
wc.eventList
wc.commandAction()
wc.buttonAction()
wc.selectionAction()
wc.rowAction()
wc.fetchMessage()
wc.fetchReply()
wc.fetchUser()
wc.fetchGuildUser()
wc.fetchChannel()
wc.fetchGuildChannel()
wc.fetchRole()
wc.fetchGuildRole()
wc.fetchGuild()
wc.parseEmoji()
wc.parseSticker()