This snippet will forward any messages your bot is mentioned in to your account. It will also react and respond to greetings specified in the script. An expanded version of my other snippet.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let message = context.params.event.content;
let sender = context.params.event.author.username;
let substrings = ['hello,*', 'hey,*', 'hi,*']; // Add whatever else you want your bot to react to. The ,* at the end is necessary to make it work with commas.
message = message.replace('<@!${process.env.BOT_ID}>', '');
console.log(`Message = ${message}`);
console.log(`Sent by ${sender}`);
await lib.discord.users['@0.1.5'].dms.create({
recipient_id: process.env.YOUR_UID,
content: `Bot was pinged by ${sender}, the message said: ${message}`,
});
if (new RegExp(substrings.join('|')).test(context.params.event.content)) {
await lib.discord.channels['@0.2.0'].messages.reactions.create({
emoji: `π`, // Change to whatever you want to react with.
message_id: context.params.event.id,
channel_id: context.params.event.channel_id,
});
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: context.params.event.channel_id,
content: `Hello!`, //What your bot responds with.
tts: false,
});
} else {
await lib.discord.channels['@0.2.0'].typing.create({
// It just looks like the bot is doing something incase it can't react.
channel_id: context.params.event.channel_id,
});
}