Spot/messageHandler.ts

25 lines
869 B
TypeScript
Raw Permalink Normal View History

2023-11-30 21:17:29 +01:00
import { client } from './bot';
import config from './config';
import * as customMessages from './model/messages';
2023-11-30 21:17:29 +01:00
import { Message, TextBasedChannel } from 'discord.js';
2023-11-30 21:17:29 +01:00
export default async function handleMessage(message: Message) {
if (!message.content.toLowerCase().startsWith(config.prefix))
2023-11-30 21:17:29 +01:00
return false;
let args = message.content.substr(config.prefix.length).trim().split(' ');
const calledCommand = args.shift()!.toLowerCase();
const embed = customMessages.getEmbed(calledCommand);
2023-11-30 21:17:29 +01:00
if (embed != null) {
const channel: TextBasedChannel | null = await client.channels.cache.get(message.channelId) as TextBasedChannel
channel.send({
embeds: [{
color: embed.color,
title: embed.author.name,
description: embed.description
}]
});
}
}