2023-11-30 21:17:29 +01:00
|
|
|
import { client } from './bot';
|
2022-10-21 17:22:01 +00:00
|
|
|
import config from './config';
|
|
|
|
|
import * as customMessages from './model/messages';
|
2023-11-30 21:17:29 +01:00
|
|
|
import { Message, TextBasedChannel } from 'discord.js';
|
2022-10-21 17:22:01 +00:00
|
|
|
|
|
|
|
|
|
2023-11-30 21:17:29 +01:00
|
|
|
export default async function handleMessage(message: Message) {
|
2022-10-21 17:22:01 +00:00
|
|
|
if (!message.content.toLowerCase().startsWith(config.prefix))
|
2023-11-30 21:17:29 +01:00
|
|
|
return false;
|
2022-10-21 17:22:01 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}]
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-10-21 17:22:01 +00:00
|
|
|
}
|