-
Notifications
You must be signed in to change notification settings - Fork 418
/
basicCommands.js
59 lines (49 loc) · 2.22 KB
/
basicCommands.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const Eris = require("eris");
// Replace TOKEN with your bot account's token
const bot = new Eris.CommandClient("Bot TOKEN", {}, {
description: "A test bot made with Eris",
owner: "somebody",
prefix: "!"
});
bot.on("ready", () => { // When the bot is ready
console.log("Ready!"); // Log "Ready!"
});
bot.on("error", (err) => {
console.error(err); // or your preferred logger
});
bot.registerCommandAlias("halp", "help"); // Alias !halp to !help
bot.registerCommand("ping", "Pong!", { // Make a ping command
// Responds with "Pong!" when someone says "!ping"
description: "Pong!",
fullDescription: "This command could be used to check if the bot is up. Or entertainment when you're bored."
});
bot.registerCommand("pong", ["Pang!", "Peng!", "Ping!", "Pung!"], { // Make a pong command
// Responds with a random version of "Ping!" when someone says "!pong"
description: "Ping!",
fullDescription: "This command could also be used to check if the bot is up. Or entertainment when you're bored."
});
const echoCommand = bot.registerCommand("echo", (msg, args) => { // Make an echo command
if(args.length === 0) { // If the user just typed "!echo", say "Invalid input"
return "Invalid input";
}
const text = args.join(" "); // Make a string of the text after the command label
return text; // Return the generated string
}, {
description: "Make the bot say something",
fullDescription: "The bot will echo whatever is after the command label.",
usage: "<text>"
});
echoCommand.registerSubcommand("reverse", (msg, args) => { // Make a reverse subcommand under echo
if(args.length === 0) { // If the user just typed "!echo reverse", say "Invalid input"
return "Invalid input";
}
let text = args.join(" "); // Make a string of the text after the command label
text = text.split("").reverse().join(""); // Reverse the string
return text; // Return the generated string
}, {
description: "Make the bot say something in reverse",
fullDescription: "The bot will echo, in reverse, whatever is after the command label.",
usage: "<text>"
});
echoCommand.registerSubcommandAlias("backwards", "reverse"); // Alias "!echo backwards" to "!echo reverse"
bot.connect();