mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 10:49:20 +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
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import Discord_MembershipScreening from '../discord/MembershipScreening';
|
||||
import Discord_osu from '../discord/osu';
|
||||
import Discord_UserInfo from '../discord/UserInfo';
|
||||
import Discord_Stats from '../discord/Stats';
|
||||
import Discord_Support from '../discord/Support';
|
||||
|
||||
import Discord_MusicPlayer_Play from '../discord/MusicPlayer/Play';
|
||||
import Discord_MusicPlayer_Skip from '../discord/MusicPlayer/Skip';
|
||||
@@ -64,6 +65,7 @@ class Discord {
|
||||
new Discord_InteractionManager(),
|
||||
new Discord_osu(),
|
||||
new Discord_Settings(),
|
||||
new Discord_Support(),
|
||||
|
||||
new Discord_MusicPlayer_Play(),
|
||||
new Discord_MusicPlayer_NowPlaying(),
|
||||
|
||||
@@ -29,6 +29,7 @@ class Environment {
|
||||
const DISCORD_TOKEN = process.env.DISCORD_TOKEN;
|
||||
const DEVELOPER_IDS = process.env.DEVELOPER_IDS;
|
||||
const PRIVATE_BOT = process.env.PRIVATE_BOT;
|
||||
const SUPPORT_URL = process.env.SUPPORT_URL;
|
||||
|
||||
const OSU_API_KEY = process.env.OSU_API_KEY;
|
||||
const YOUTUBE_COOKIE_BASE64 = process.env.YOUTUBE_COOKIE_BASE64;
|
||||
@@ -39,6 +40,7 @@ class Environment {
|
||||
DISCORD_TOKEN,
|
||||
DEVELOPER_IDS,
|
||||
PRIVATE_BOT,
|
||||
SUPPORT_URL,
|
||||
|
||||
OSU_API_KEY,
|
||||
YOUTUBE_COOKIE_BASE64
|
||||
|
||||
Reference in New Issue
Block a user