I'm working with a friend to add something to an existing Discord bot. There a number of working commands that use discord.js-commando
, so we're tied to using Commando.
The guild we're doing this for has moved some resources from an old site to a new one, and we'd like to remind the guild members who link to the old site that they should use the new site instead:
// User123 says...
Check out https://www.example.com/.
// bot responds:
Hey User123! You should use our new site! https://www.example2.com/
The bot would only trigger if it sees www.example.com
.
Here's the code...
// file: index.js
const bot = new Commando.Client({
commandPrefix: './'
});
bot.registry
.registerGroup('autoresponses', 'AutoResponses')
// other groups
.registerDefaults()
.registerCommandsIn(__dirname + '/commands')
;
and the file I'm working on
// file: commands/autoresponses/messages.js
const discord = require('discord.js');
client.on("message", function(message) {
if (message.author.bot) {
return;
}
if (message.content.includes("www.example.com")) {
var responseString = "Hey " + message.author + "! That's the old site! Please use the new one: https://www.example2.com/";
message.channel.send(responseString);
}
};
Trouble is, this doesn't use Commando, just regular discord.js. Is this even possible with Commando? Or do I need another approach?