mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 18:59:19 +00:00
Update Help.ts
This commit is contained in:
+40
-25
@@ -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() || '');
|
||||||
if(isSlashCommand) {
|
return _e;
|
||||||
data.reply({ ephemeral: false, embeds: [embed] });
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
export default class Help {
|
||||||
let help = await sendReply(data, {
|
|
||||||
embeds: [embed]
|
|
||||||
});
|
|
||||||
|
|
||||||
if(help)
|
async onCommand(command: string, args: any, message: Message) {
|
||||||
help.react("♥");
|
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) {
|
||||||
|
|
||||||
|
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("♥");
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user