Initial upload of the project in its first usable version

This commit is contained in:
Matias Espinoza
2023-03-13 05:41:45 -03:00
commit 46c766fd38
21 changed files with 3045 additions and 0 deletions

View File

@ -0,0 +1,25 @@
import {
CommandInteraction, Client, TextChannel, ChannelType, ApplicationCommandType,
} from 'discord.js';
import { Command } from '@/bot/models/command';
export const ClearCommand: Command = {
name: 'clear',
description: 'Delete your interactions with the Chat bot',
type: ApplicationCommandType.ChatInput,
execute: async (client: Client, interaction: CommandInteraction) => {
const channel = client.channels.cache.get(interaction.channelId) as TextChannel;
const messages = await channel.messages.fetch({ limit: 100 });
const consistentMessages = messages
.filter((x) => x.interaction?.user.id === interaction.user.id);
if (channel.type === ChannelType.GuildText) {
await channel.bulkDelete(consistentMessages);
} else {
await messages.forEach((message) => {
if (message.author.id !== client.user?.id) return;
message.delete();
});
}
},
};