Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
takejohn committed May 9, 2024
1 parent 9a830e6 commit 0b77fd4
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 25 deletions.
39 changes: 38 additions & 1 deletion language/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@
"result": "結果:",
"notPlayableError": "えー実行したくないなぁー...だってVCに君が居ないんだもん...",
"playerTrack": "${title} (${duration})",
"noTracksPlayed": "再生されている曲がありません!"
"noTracksPlayed": "再生されている曲がありません!",
"useCommandInGuild": "このコマンドはサーバー内で使用してください!",
"noPermission": "権限がありません!"
},
"defaultValues": {
"graphLabel": "value"
Expand Down Expand Up @@ -570,6 +572,40 @@
"playerPaused": "音楽を一時停止しました!",
"pauseFailed": "一時停止できませんでした"
},
"perm": {
"name": "perm",
"description": "権限の設定",
"subcommands": {
"set": {
"name": "set",
"description": "値の更新"
},
"get": {
"name": "get",
"description": "値の取得"
},
"remove": {
"name": "remove",
"description": "値の削除"
}
},
"options": {
"permission": {
"name": "permission",
"description": "権限名"
},
"group": {
"name": "group",
"description": "対象のロールまたはユーザー"
}
},
"noSuchPermission": ["権限名: ${0}", "その名前の権限はありません!"],
"permissionInformation": "権限情報",
"permissionName": "権限名",
"permissionGroup": "ロール/メンバー",
"permissionSet": "権限を追加しました!",
"permissionRemoved": "権限を削除しました"
},
"pieChart": {
"name": "piechart",
"description": "円グラフを生成します。",
Expand Down Expand Up @@ -701,6 +737,7 @@
"emptyMessage": "メッセージが設定されていません"
}
},
"replyCustomizePermission": "自動応答の設定",
"notInGuildError": "このコマンドはサーバー内でのみ使用できます!",
"permissionError": "このコマンドを使用する権限がありません!"
},
Expand Down
42 changes: 41 additions & 1 deletion language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@
"result": "Result:",
"notPlayableError": "Join the VC to execute the command!",
"playerTrack": "${title} (${duration})",
"noTracksPlayed": "There are no tracks played!"
"noTracksPlayed": "There are no tracks played!",
"useCommandInGuild": "Use this command in a server!",
"noPermission": "You have not permission to do it!"
},
"defaultValues": {
"graphLabel": "value"
Expand Down Expand Up @@ -539,6 +541,43 @@
"playerPaused": "Paused the player!",
"pauseFailed": "Failed to pause the player"
},
"perm": {
"name": "perm",
"description": "Permission configuration",
"subcommands": {
"set": {
"name": "set",
"description": "Updates a value"
},
"get": {
"name": "get",
"description": "Gets a value"
},
"remove": {
"name": "remove",
"description": "Removes a value"
}
},
"options": {
"permission": {
"name": "permission",
"description": "Permission name"
},
"group": {
"name": "group",
"description": "Target role or user"
}
},
"noSuchPermission": [
"Permission name: ${0}",
"There is not such permission!"
],
"permissionInformation": "Permission info",
"permissionName": "Permission name",
"permissionGroup": "Roles/Members",
"permissionSet": "Added a permission!",
"permissionRemoved": "Removed a permission"
},
"pieChart": {
"name": "piechart",
"description": "Generates a pie chart.",
Expand Down Expand Up @@ -670,6 +709,7 @@
"emptyMessage": "メッセージが設定されていません"
}
},
"replyCustomizePermission": "customizations of automatic replies",
"notInGuildError": "This commands must be used in a server!",
"permissionError": "You have not permission to use this command!"
},
Expand Down
39 changes: 38 additions & 1 deletion language/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@
"result": "結果:",
"notPlayableError": "えー実行したくないなぁー…だってVCに君が居ないんだもん…",
"playerTrack": "${title} (${duration})",
"noTracksPlayed": "再生されている曲がありません!"
"noTracksPlayed": "再生されている曲がありません!",
"useCommandInGuild": "このコマンドはサーバー内で使用してください!",
"noPermission": "権限がありません!"
},
"defaultValues": {
"graphLabel": "value"
Expand Down Expand Up @@ -539,6 +541,40 @@
"playerPaused": "音楽を一時停止しました!",
"pauseFailed": "一時停止できませんでした"
},
"perm": {
"name": "perm",
"description": "権限の設定",
"subcommands": {
"set": {
"name": "set",
"description": "値の更新"
},
"get": {
"name": "get",
"description": "値の取得"
},
"remove": {
"name": "remove",
"description": "値の削除"
}
},
"options": {
"permission": {
"name": "permission",
"description": "権限名"
},
"group": {
"name": "group",
"description": "対象のロールまたはユーザー"
}
},
"noSuchPermission": ["権限名: ${0}", "その名前の権限はありません!"],
"permissionInformation": "権限情報",
"permissionName": "権限名",
"permissionGroup": "ロール/メンバー",
"permissionSet": "権限を追加しました!",
"permissionRemoved": "権限を削除しました"
},
"pieChart": {
"name": "piechart",
"description": "円グラフを生成します。",
Expand Down Expand Up @@ -670,6 +706,7 @@
"emptyMessage": "メッセージが設定されていません"
}
},
"replyCustomizePermission": "自動応答の設定",
"notInGuildError": "このコマンドはサーバー内でのみ使用できます!",
"permissionError": "このコマンドを使用する権限がありません!"
},
Expand Down
5 changes: 4 additions & 1 deletion packages/misc/commands/reply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { LANG, Config, Command, Pager } from 'core';
import { ClientMessageHandler, ReplyPattern } from '../util/messages';
import { feature as perms } from 'perms';

perms.registerPermission('replyCustomize', '自動応答の設定');
perms.registerPermission(
'replyCustomize',
LANG.commands.reply.replyCustomizePermission,
);

module.exports = {
data: new SlashCommandBuilder()
Expand Down
56 changes: 35 additions & 21 deletions packages/perms/commands/perm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CompoundCommandBuilder } from 'core';
import { CompoundCommandBuilder, LANG, strFormat } from 'core';
import { feature as db } from 'db';
import {
APIEmbed,
Expand All @@ -8,7 +8,10 @@ import {
} from 'discord.js';
import { Permission, PermissionManager } from '../PermissionManager';

const builder = new CompoundCommandBuilder('perm', '権限の設定');
const builder = new CompoundCommandBuilder(
LANG.commands.perm.name,
LANG.commands.perm.description,
);

const choices: ApplicationCommandOptionChoiceData<string>[] = [];

Expand All @@ -18,7 +21,7 @@ export function addChoice(choice: ApplicationCommandOptionChoiceData<string>) {

async function informNotInGuild(interaction: ChatInputCommandInteraction) {
await interaction.reply({
content: 'このコマンドはサーバー内で使用してください!',
content: LANG.common.message.useCommandInGuild,
ephemeral: true,
});
return;
Expand All @@ -29,7 +32,7 @@ async function checkMemberIsAdministrator(
): Promise<boolean> {
if (!interaction.member.permissions.has(PermissionFlagsBits.Administrator)) {
await interaction.reply({
content: '権限がありません!',
content: LANG.common.message.noPermission,
ephemeral: true,
});
return false;
Expand All @@ -45,7 +48,9 @@ async function getPermissionOrInformNotFound(
const result = await permissions.get(interaction.guild, permissionName);
if (result == null) {
await interaction.reply(
`権限名: ${permissionName}\nその名前の権限はありません!`,
LANG.commands.perm.noSuchPermission
.map((s) => strFormat(s, [permissionName]))
.join('\n'),
);
}
return result;
Expand All @@ -54,33 +59,36 @@ async function getPermissionOrInformNotFound(
function permissionToEmbed(permission: Permission): APIEmbed {
return {
color: 0x88ff44,
title: '権限情報',
title: LANG.commands.perm.permissionInformation,
fields: [
{
name: '権限名',
name: LANG.commands.perm.permissionName,
value: permission.name,
},
{
name: 'ロール/メンバー',
name: LANG.commands.perm.permissionGroup,
value: permission.group.join(', '),
},
],
};
}

builder
.subcommand('set', '値の更新')
.subcommand(
LANG.commands.perm.subcommands.set.name,
LANG.commands.perm.subcommands.set.description,
)
.addStringOption({
name: 'permission',
description: '権限名',
name: LANG.commands.perm.options.permission.name,
description: LANG.commands.perm.options.permission.description,
required: true,
async autocomplete(interaction) {
await interaction.respond(choices);
},
})
.addMentionableOption({
name: 'group',
description: '対象のロールまたはユーザー',
name: LANG.commands.perm.options.group.name,
description: LANG.commands.perm.options.group.description,
required: true,
})
.build(async (interaction, permissionName, group) => {
Expand All @@ -99,16 +107,19 @@ builder
group,
);
await interaction.reply({
content: '権限を追加しました!',
content: LANG.commands.perm.permissionSet,
embeds: [permissionToEmbed(permission)],
});
});

builder
.subcommand('get', '値の取得')
.subcommand(
LANG.commands.perm.subcommands.get.name,
LANG.commands.perm.subcommands.get.description,
)
.addStringOption({
name: 'permission',
description: '権限名',
name: LANG.commands.perm.options.permission.name,
description: LANG.commands.perm.options.permission.description,
required: true,
async autocomplete(interaction) {
await interaction.respond(choices);
Expand All @@ -132,10 +143,13 @@ builder
});

builder
.subcommand('remove', '値の削除')
.subcommand(
LANG.commands.perm.subcommands.remove.name,
LANG.commands.perm.subcommands.remove.description,
)
.addStringOption({
name: 'permission',
description: '権限名',
name: LANG.commands.perm.options.permission.name,
description: LANG.commands.perm.options.permission.description,
required: true,
async autocomplete(interaction) {
await interaction.respond(choices);
Expand All @@ -153,7 +167,7 @@ builder
if (permission != null) {
await permission.remove();
await interaction.reply({
content: '権限を削除しました',
content: LANG.commands.perm.permissionRemoved,
embeds: [permissionToEmbed(permission)],
});
}
Expand Down

0 comments on commit 0b77fd4

Please sign in to comment.