mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-14 03:09:59 +00:00
Add support command
This commit is contained in:
+2
-2
@@ -1,4 +1,4 @@
|
||||
import { CommandInteraction, Interaction, Message } from 'discord.js';
|
||||
import { CommandInteraction, Message } from 'discord.js';
|
||||
import { I18n } from 'i18n';
|
||||
|
||||
import DiscordProvider from '../providers/Discord';
|
||||
@@ -24,7 +24,7 @@ const EMBEDS = {
|
||||
fields: [
|
||||
{
|
||||
name: `☕ ${locale.__('help.general')}`,
|
||||
value: `help, ping, invite, userinfo, stats`,
|
||||
value: `help, ping, invite, userinfo, stats, support`,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import { Message, CommandInteraction } from 'discord.js';
|
||||
import { I18n } from 'i18n';
|
||||
|
||||
import Environment from '../providers/Environment';
|
||||
import DiscordProvider from '../providers/Discord';
|
||||
import Locale from '../services/Locale';
|
||||
|
||||
import DiscordModule, { HybridInteractionMessage } from '../utils/DiscordModule';
|
||||
import { sendHybridInteractionMessageResponse, makeInfoEmbed } from '../utils/DiscordMessage';
|
||||
|
||||
const EMBEDS = {
|
||||
SUPPORT_INFO: (data: HybridInteractionMessage, locale: I18n) => {
|
||||
const user = data.getUser();
|
||||
let message;
|
||||
if (Environment.get().SUPPORT_URL)
|
||||
message = locale.__('support.info', { BOT_NAME: DiscordProvider.client.user!.username, LINK: Environment.get().SUPPORT_URL});
|
||||
|
||||
return makeInfoEmbed({
|
||||
title: locale.__('support.title'),
|
||||
description: message || locale.__('support.not_available', { BOT_NAME: DiscordProvider.client.user!.username}),
|
||||
user
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default class Support extends DiscordModule {
|
||||
public id: string = 'Discord_Support';
|
||||
public commands = ['support'];
|
||||
public commandInteractionName = 'support';
|
||||
|
||||
async GuildOnModuleCommand(args: any, message: Message) {
|
||||
await this.run(new HybridInteractionMessage(message), args);
|
||||
}
|
||||
|
||||
async GuildModuleCommandInteractionCreate(interaction: CommandInteraction) {
|
||||
await this.run(new HybridInteractionMessage(interaction), interaction.options);
|
||||
}
|
||||
|
||||
async run(data: HybridInteractionMessage, args: any) {
|
||||
const guild = data.getGuild();
|
||||
if (!guild) return;
|
||||
|
||||
const locale = await Locale.getGuildLocale(guild.id);
|
||||
|
||||
await sendHybridInteractionMessageResponse(data, {
|
||||
embeds: [EMBEDS.SUPPORT_INFO(data, locale)]
|
||||
});
|
||||
|
||||
if(Environment.get().SUPPORT_URL)
|
||||
await sendHybridInteractionMessageResponse(data, {
|
||||
content: Environment.get().SUPPORT_URL
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user