Skip to content

Commit

Permalink
Add error handler to examples (#1181)
Browse files Browse the repository at this point in the history
  • Loading branch information
xaxim authored Apr 18, 2021
1 parent 8d3120e commit 5f7769d
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ 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.on("messageCreate", (msg) => { // When a message is created
if(msg.content === "!ping") { // If the message content is "!ping"
bot.createMessage(msg.channel.id, "Pong!");
Expand Down
4 changes: 4 additions & 0 deletions examples/basicCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ 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
Expand Down
4 changes: 4 additions & 0 deletions examples/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ 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.on("messageCreate", (msg) => { // When a message is created
if(msg.content === "!embed") { // If the message content is "!embed"
bot.createMessage(msg.channel.id, {
Expand Down
4 changes: 4 additions & 0 deletions examples/intent.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ 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.on("guildCreate", (guild) => { // When the client joins a new guild
console.log(`New guild: ${guild.name}`);
});
Expand Down
4 changes: 4 additions & 0 deletions examples/pingpong.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ 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.on("messageCreate", (msg) => { // When a message is created
if(msg.content === "!ping") { // If the message content is "!ping"
bot.createMessage(msg.channel.id, "Pong!");
Expand Down
4 changes: 4 additions & 0 deletions examples/playFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ 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.on("messageCreate", (msg) => { // When a message is created
if(msg.content.startsWith(playCommand)) { // If the message content starts with "!play "
if(msg.content.length <= playCommand.length + 1) { // Check if a filename was specified
Expand Down
4 changes: 4 additions & 0 deletions examples/reactionButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ 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.registerCommand("ping", "Pong!", { // Make a ping command
// Responds with "Pong!" when someone says "!ping"
description: "Pong!",
Expand Down

0 comments on commit 5f7769d

Please sign in to comment.