Files
Yumi/src/discord/Help.ts
T

68 lines
2.7 KiB
TypeScript
Raw Normal View History

2021-09-16 23:55:08 -07:00
import { CommandInteraction, Interaction, Message } from "discord.js";
2021-09-18 03:51:26 -07:00
import { getEmotes, makeSuccessEmbed, makeProcessingEmbed, sendMessageOrInteractionResponse, sendReply, makeInfoEmbed } from "../utils/DiscordMessage";
2021-09-15 06:05:57 -07:00
import DiscordProvider from "../providers/Discord";
2021-09-18 03:51:26 -07:00
import Cache from "../providers/Cache";
2021-09-15 06:05:57 -07:00
2021-09-18 03:51:26 -07:00
const EMBEDS = {
INFO: async (data: Message | Interaction) => {
2021-09-15 06:05:57 -07:00
2021-09-18 03:51:26 -07:00
let GuildCache = await Cache.getGuild(data.guildId!);
//if(typeof GuildCache === 'undefined' || typeof GuildCache.prefix === 'undefined') return;
2021-09-15 06:05:57 -07:00
2021-09-18 03:51:26 -07:00
let prefix = GuildCache.prefix || '>';
2021-09-15 06:05:57 -07:00
2021-09-18 03:51:26 -07:00
let _e = makeInfoEmbed({
2021-09-15 06:05:57 -07:00
icon: "💌",
title: `Help - ${DiscordProvider.client.user?.username}`,
fields: [
{
name: 'Info',
value: `Yumi is currently undergoing complete rewrite, as expected, losing many of her functionality. All of the features will be re-implemented.`
},
{
name: 'Why?',
value: `Yumi was specifically written for use in a only 1 private server, now it's time to extend the border and globalize it (just kidding lol)`
},
2021-09-18 03:51:26 -07:00
{
name: 'Prefix',
value: `You can call me using \`\`${prefix}\`\`, <@${DiscordProvider.client.user?.id}> or \`\`/slash command\`\``
},
2021-09-15 06:05:57 -07:00
{
name: 'Available commands',
2021-09-18 03:51:26 -07:00
value: '``help``\n``ping``\n``invite``\n``membershipscreening (ms)``'
2021-09-15 06:05:57 -07:00
}
],
2021-09-18 03:51:26 -07:00
user: (data instanceof Interaction) ? data.user : data.author
2021-09-15 06:05:57 -07:00
});
2021-09-18 03:51:26 -07:00
_e.setThumbnail(DiscordProvider.client.user?.avatarURL() || '');
return _e;
}
}
2021-09-15 06:05:57 -07:00
2021-09-18 03:51:26 -07:00
export default class Help {
2021-09-15 06:05:57 -07:00
2021-09-18 03:51:26 -07:00
async onCommand(command: string, args: any, message: Message) {
if(command.toLowerCase() !== 'help') return;
await this.process(message, args);
}
async interactionCreate(interaction: CommandInteraction) {
if(interaction.isCommand()) {
if(typeof interaction.commandName === 'undefined') return;
if((interaction.commandName).toLowerCase() !== 'help') return;
await this.process(interaction, interaction.options);
2021-09-15 06:05:57 -07:00
}
}
2021-09-18 03:51:26 -07:00
async process(data: Interaction | Message, args: any) {
const isSlashCommand = data instanceof CommandInteraction && data.isCommand();
const isMessage = data instanceof Message;
let sent = await sendMessageOrInteractionResponse(data, { embeds: [await EMBEDS.INFO(data)] });
if(isMessage)
return (sent as Message).react("♥");
}
2021-09-15 06:05:57 -07:00
}