Update Help.ts

This commit is contained in:
2021-09-18 03:51:26 -07:00
parent a5f964cb3d
commit 25d6d72b30
+40 -25
View File
@@ -1,23 +1,17 @@
import { CommandInteraction, Interaction, Message } from "discord.js"; import { CommandInteraction, Interaction, Message } from "discord.js";
import { getEmotes, makeSuccessEmbed, makeProcessingEmbed, sendMessage, sendReply, makeInfoEmbed } from "../utils/DiscordMessage"; import { getEmotes, makeSuccessEmbed, makeProcessingEmbed, sendMessageOrInteractionResponse, sendReply, makeInfoEmbed } from "../utils/DiscordMessage";
import DiscordProvider from "../providers/Discord"; import DiscordProvider from "../providers/Discord";
import Cache from "../providers/Cache";
export default class Help { const EMBEDS = {
INFO: async (data: Message | Interaction) => {
async onCommand(command: string, args: any, message: Message) { let GuildCache = await Cache.getGuild(data.guildId!);
if(command.toLowerCase() !== 'help') return; //if(typeof GuildCache === 'undefined' || typeof GuildCache.prefix === 'undefined') return;
this.sendHelpMessage(false, message);
}
async interactionCreate(interaction: CommandInteraction) { let prefix = GuildCache.prefix || '>';
if(typeof interaction.commandName === 'undefined') return;
if((interaction.commandName).toLowerCase() !== 'help') return;
await this.sendHelpMessage(true, interaction);
}
async sendHelpMessage(isSlashCommand: boolean, data: any) { let _e = makeInfoEmbed({
const embed = makeInfoEmbed({
icon: "💌", icon: "💌",
title: `Help - ${DiscordProvider.client.user?.username}`, title: `Help - ${DiscordProvider.client.user?.username}`,
fields: [ fields: [
@@ -29,25 +23,46 @@ export default class Help {
name: 'Why?', 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)` 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)`
}, },
{
name: 'Prefix',
value: `You can call me using \`\`${prefix}\`\`, <@${DiscordProvider.client.user?.id}> or \`\`/slash command\`\``
},
{ {
name: 'Available commands', name: 'Available commands',
value: '``help``\n``ping``\n``invite``\n``membershipscreening (ms)``\n``...14 commands has been hidden (FLAGS.BETA)``' value: '``help``\n``ping``\n``invite``\n``membershipscreening (ms)``'
} }
], ],
user: isSlashCommand ? data.user : data.author user: (data instanceof Interaction) ? data.user : data.author
}); });
_e.setThumbnail(DiscordProvider.client.user?.avatarURL() || '');
return _e;
}
}
if(isSlashCommand) { export default class Help {
data.reply({ ephemeral: false, embeds: [embed] });
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);
} }
}
async process(data: Interaction | Message, args: any) {
else { const isSlashCommand = data instanceof CommandInteraction && data.isCommand();
let help = await sendReply(data, { const isMessage = data instanceof Message;
embeds: [embed]
});
if(help) let sent = await sendMessageOrInteractionResponse(data, { embeds: [await EMBEDS.INFO(data)] });
help.react("♥");
} if(isMessage)
return (sent as Message).react("♥");
} }
} }