mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 18:59:19 +00:00
Support localization
This commit is contained in:
+14
-8
@@ -1,24 +1,25 @@
|
||||
import { Message, CommandInteraction, Interaction } from 'discord.js';
|
||||
import { I18n } from 'i18n';
|
||||
|
||||
import Environment from '../providers/Environment';
|
||||
import DiscordProvider from '../providers/Discord';
|
||||
import Users from '../services/Users';
|
||||
import Locale from '../services/Locale';
|
||||
|
||||
import DiscordModule, { HybridInteractionMessage } from '../utils/DiscordModule';
|
||||
import { sendHybridInteractionMessageResponse, makeInfoEmbed } from '../utils/DiscordMessage';
|
||||
|
||||
const EMBEDS = {
|
||||
INVITE_INFO: (data: Message | Interaction) => {
|
||||
INVITE_INFO: (data: HybridInteractionMessage, locale: I18n) => {
|
||||
const user = data.getUser();
|
||||
let message;
|
||||
if (Users.isDeveloper(data.member?.user.id!) || !Environment.get().PRIVATE_BOT)
|
||||
message = `[Invite ${DiscordProvider.client.user?.username} to your server!](https://discord.com/api/oauth2/authorize?client_id=${DiscordProvider.client.user?.id}&permissions=0&scope=bot%20applications.commands)`;
|
||||
if (!Environment.get().PRIVATE_BOT || user != null && Users.isDeveloper(user.id))
|
||||
message = locale.__('invite.info', DiscordProvider.client.user!.username, `https://discord.com/api/oauth2/authorize?client_id=${DiscordProvider.client.user?.id}&permissions=0&scope=bot%20applications.commands`);
|
||||
|
||||
return makeInfoEmbed({
|
||||
title: `Invite`,
|
||||
description:
|
||||
message ||
|
||||
`${DiscordProvider.client.user?.username}'s invite is currently private. Only the developers can add me to another server`,
|
||||
user: data instanceof Interaction ? data.user : data.author
|
||||
description: message || locale.__('invite.private', DiscordProvider.client.user!.username),
|
||||
user
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -37,8 +38,13 @@ export default class Invite extends DiscordModule {
|
||||
}
|
||||
|
||||
async run(data: HybridInteractionMessage, args: any) {
|
||||
const guild = data.getGuild();
|
||||
if (!guild) return;
|
||||
|
||||
const locale = await Locale.getGuildLocale(guild.id);
|
||||
|
||||
return await sendHybridInteractionMessageResponse(data, {
|
||||
embeds: [EMBEDS.INVITE_INFO(data.getRaw())]
|
||||
embeds: [EMBEDS.INVITE_INFO(data, locale)]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user