Add messageCreate event for trigger auto-responses
All checks were successful
Auto Build and Push Docker Image / build (push) Successful in 23s
All checks were successful
Auto Build and Push Docker Image / build (push) Successful in 23s
This commit is contained in:
23
src/events/messageCreate.ts
Normal file
23
src/events/messageCreate.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { Events } from 'discord.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: Events.MessageCreate,
|
||||||
|
async execute(message: any, client: any) {
|
||||||
|
if (message.author.bot) return;
|
||||||
|
if (!message.guildId) return;
|
||||||
|
|
||||||
|
const triggers: any[] = client.DB.all(
|
||||||
|
'SELECT * FROM auto_responses WHERE guild_id = ?',
|
||||||
|
message.guildId
|
||||||
|
);
|
||||||
|
|
||||||
|
const contentLower = message.content.toLowerCase();
|
||||||
|
|
||||||
|
for (const trigger of triggers) {
|
||||||
|
if (contentLower.includes(trigger.trigger_word.toLowerCase())) {
|
||||||
|
await message.channel.send(trigger.response_text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user