2022-06-06 14:59:53 +07:00
|
|
|
|
import { CommandInteraction, Interaction, Message } from 'discord.js';
|
2022-06-07 13:00:16 +07:00
|
|
|
|
import { I18n } from 'i18n';
|
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';
|
2022-06-07 13:00:16 +07:00
|
|
|
|
import Locale from '../services/Locale';
|
|
|
|
|
|
import { Guild as PrismaGuild } from '@prisma/client';
|
2021-09-15 06:05:57 -07:00
|
|
|
|
|
2021-09-18 03:51:26 -07:00
|
|
|
|
const EMBEDS = {
|
2022-06-07 13:00:16 +07:00
|
|
|
|
INFO: async (data: HybridInteractionMessage, locale: I18n, GuildCache: PrismaGuild) => {
|
|
|
|
|
|
let prefix = GuildCache.prefix;
|
|
|
|
|
|
const bot = DiscordProvider.client.user!;
|
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: '💌',
|
2022-06-27 20:28:01 +07:00
|
|
|
|
title: locale.__('help.title', { BOT_NAME: bot.username }),
|
2022-06-07 13:00:16 +07:00
|
|
|
|
description: `\u200b\n🏷️ **${locale.__('help.prefix_title')}**\n${locale.__(
|
|
|
|
|
|
'help.prefix_description',
|
2022-06-27 20:28:01 +07:00
|
|
|
|
{PREFIX: prefix.replaceAll('`', '`'), PREFIX_MENTION: `<@${bot.id}>`}
|
2022-06-07 13:00:16 +07:00
|
|
|
|
)}\n\n💻 **${locale.__('help.available_commands')}**`,
|
2021-09-15 06:05:57 -07:00
|
|
|
|
fields: [
|
|
|
|
|
|
{
|
2022-06-07 13:00:16 +07:00
|
|
|
|
name: `☕ ${locale.__('help.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-06-27 20:28:01 +07:00
|
|
|
|
name: `🎮 ${locale.__('help.games')}`,
|
|
|
|
|
|
value: `osu`,
|
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-06-27 20:28:01 +07:00
|
|
|
|
name: `🎵 ${locale.__('help.music')}`,
|
|
|
|
|
|
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-18 03:51:26 -07:00
|
|
|
|
},
|
2021-09-15 06:05:57 -07:00
|
|
|
|
{
|
2022-06-07 13:00:16 +07:00
|
|
|
|
name: `🔐 ${locale.__('help.admin')}`,
|
2022-01-30 21:50:18 +07:00
|
|
|
|
value: `settings, say, membershipscreening (ms)`,
|
|
|
|
|
|
inline: true
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-06-07 13:00:16 +07:00
|
|
|
|
name: `🔧 ${locale.__('help.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',
|
2022-06-07 13:00:16 +07:00
|
|
|
|
value: `**${locale.__('help.footer')}(https://github.com/YuzuZensai/Yumi)**`,
|
2022-02-02 22:13:27 +07:00
|
|
|
|
inline: false
|
2021-09-15 06:05:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
],
|
2022-06-07 13:00:16 +07:00
|
|
|
|
user: data.getUser()
|
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-07 13:00:16 +07:00
|
|
|
|
const guild = data.getGuild();
|
|
|
|
|
|
const member = data.getMember();
|
|
|
|
|
|
|
|
|
|
|
|
if (!guild || !member) return;
|
|
|
|
|
|
|
|
|
|
|
|
const GuildCache = await Cache.getCachedGuild(guild.id);
|
|
|
|
|
|
if (!GuildCache) return;
|
|
|
|
|
|
|
|
|
|
|
|
const locale = await Locale.getGuildLocale(guild.id);
|
|
|
|
|
|
|
2022-06-06 14:59:53 +07:00
|
|
|
|
const message = await sendHybridInteractionMessageResponse(data, {
|
2022-06-07 13:00:16 +07:00
|
|
|
|
embeds: [await EMBEDS.INFO(data, locale, GuildCache)]
|
2022-06-06 14:59:53 +07:00
|
|
|
|
});
|
2021-09-18 03:51:26 -07:00
|
|
|
|
|
2022-06-07 13:00:16 +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
|
|
|
|
}
|