|
- /* eslint-disable import/prefer-default-export */
- /* eslint-disable @typescript-eslint/no-unsafe-call */
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
- /* eslint-disable @typescript-eslint/no-unsafe-return */
-
- import { ChannelType } from 'discord.js';
- import CLIENT from '../client';
- import * as anime from '../functions/anime';
- import * as meme from '../functions/meme';
- import post from '../commands/post';
- import help from '../commands/help';
-
- CLIENT.on('messageCreate', async (message) => {
- if (!CLIENT.user) {
- return;
- }
-
- if (message.author.id === CLIENT.user.id) {
- // Do not listen to own messages.
- return;
- }
-
- const content = message.content?.replaceAll(/\s\s+/g, ' ').toLowerCase() ?? '';
-
- if (message.channel.type === ChannelType.DM) {
- const [command] = content.split(' ');
-
- if (command === 'save') {
- await anime.queueImage(message);
- }
-
- return;
- }
-
- if (content.startsWith(`<@!${CLIENT.user.id}>`) || content.startsWith(`<@${CLIENT.user.id}>`)) {
- const [, command, ...args] = content.split(' ');
- if (command === 'post') {
- await post(message, ...args);
- return;
- }
-
- if (command === 'help') {
- await help(message);
- return;
- }
-
- return;
- }
-
- await meme.listenForKeywordsAndReply(message);
- await anime.listenForImagesAndReply(message);
- });
|