Files
Yumi/src/discord/Help.ts
T

88 lines
3.3 KiB
TypeScript
Raw Normal View History

2022-06-06 14:59:53 +07:00
import { CommandInteraction, Interaction, Message } from 'discord.js';
2022-03-03 20:56:49 +07:00
2022-06-06 14:59:53 +07:00
import DiscordProvider from '../providers/Discord';
import Cache from '../providers/Cache';
import DiscordModule, { HybridInteractionMessage } from '../utils/DiscordModule';
import { sendHybridInteractionMessageResponse, makeInfoEmbed } from '../utils/DiscordMessage';
2021-09-15 06:05:57 -07:00
2021-09-18 03:51:26 -07:00
const EMBEDS = {
INFO: async (data: Message | Interaction) => {
2022-06-06 20:11:07 +07:00
let GuildCache = await Cache.getCachedGuild(data.guildId!);
2022-01-27 17:59:07 +07:00
// TODO: Better error handling
2022-06-06 14:59:53 +07:00
if (typeof GuildCache === 'undefined') throw new Error('Guild not found');
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({
2022-06-06 14:59:53 +07:00
icon: '💌',
2021-09-15 06:05:57 -07:00
title: `Help - ${DiscordProvider.client.user?.username}`,
2022-06-06 14:59:53 +07:00
description: `\u200b\n📰 **Info**\nYumi is currently undergoing complete rewrite, as expected, losing many of her functionality. All of the features will be re-implemented.\n\n🏷️**Prefix**\nYou can call me using \`\`${prefix.replaceAll(
'`',
'`'
)}\`\`, <@${
DiscordProvider.client.user?.id
}> or \`\`/slash command\`\`\n\n💻 **Available commands**`,
2021-09-15 06:05:57 -07:00
fields: [
{
2022-01-30 21:50:18 +07:00
name: '☕ General',
2022-02-05 01:20:14 +07:00
value: `help, ping, invite, userinfo, stats`,
2022-01-30 21:50:18 +07:00
inline: true
2021-09-15 06:05:57 -07:00
},
{
2022-01-30 21:50:18 +07:00
name: '🎵 Music',
2022-06-06 02:18:41 +07:00
value: `play (p), search, skip, pause, resume, queue (q), nowplaying (np), loop, join, leave (disconnect, dc)`,
2022-01-30 21:50:18 +07:00
inline: true
2021-09-15 06:05:57 -07:00
},
2021-09-18 03:51:26 -07:00
{
2022-01-30 21:50:18 +07:00
name: '🎮 Games',
value: `osu`,
inline: true
2021-09-18 03:51:26 -07:00
},
2021-09-15 06:05:57 -07:00
{
2022-01-30 21:50:18 +07:00
name: '🔐 Admin',
value: `settings, say, membershipscreening (ms)`,
inline: true
},
{
name: '🔧 Developer',
2022-03-03 23:57:03 +07:00
value: 'debug, interactions, serviceannouncement',
2022-01-30 21:50:18 +07:00
inline: true
2022-02-02 22:13:27 +07:00
},
{
name: '\u200b',
value: '**Made with 💖 and [open source](https://github.com/YuzuZensai/Yumi)**',
inline: false
2021-09-15 06:05:57 -07:00
}
],
2022-06-06 14:59:53 +07:00
user: data instanceof Interaction ? data.user : data.author
2021-09-15 06:05:57 -07:00
});
2022-06-06 13:00:38 +07:00
_e.setThumbnail(`${DiscordProvider.client.user?.displayAvatarURL()}?size=4096`);
2021-09-18 03:51:26 -07:00
return _e;
}
2022-06-06 14:59:53 +07:00
};
2021-09-15 06:05:57 -07:00
2022-03-03 20:56:49 +07:00
export default class Help extends DiscordModule {
2022-06-06 14:59:53 +07:00
public id = 'Discord_Help';
public commands = ['help'];
public commandInteractionName = 'help';
2022-03-03 20:56:49 +07:00
async GuildOnModuleCommand(args: any, message: Message) {
await this.run(new HybridInteractionMessage(message), args);
2021-09-18 03:51:26 -07:00
}
2022-06-06 14:59:53 +07:00
async GuildModuleCommandInteractionCreate(interaction: CommandInteraction) {
2022-03-03 20:56:49 +07:00
await this.run(new HybridInteractionMessage(interaction), interaction.options);
2021-09-15 06:05:57 -07:00
}
2021-09-18 03:51:26 -07:00
2022-03-03 20:56:49 +07:00
async run(data: HybridInteractionMessage, args: any) {
2022-06-06 14:59:53 +07:00
const message = await sendHybridInteractionMessageResponse(data, {
embeds: [await EMBEDS.INFO(data.getRaw())]
});
2021-09-18 03:51:26 -07:00
2022-06-06 14:59:53 +07:00
if (message && data.isMessage())
return new HybridInteractionMessage(message).getMessage().react('♥');
2021-09-18 03:51:26 -07:00
}
2022-06-06 14:59:53 +07:00
}