diff --git a/account.js b/account.js index d21e8337..96a4cb91 100644 --- a/account.js +++ b/account.js @@ -189,6 +189,25 @@ function updateModControls() { }); addModControlsButton(localizedMessages.modSettings.actions.ban.label, () => adminPlayerAction('ban', localizedMessages.modSettings.actions.ban.playerPrompt, getMassagedLabel(localizedMessages.context.admin.ban.success, true), 'ban')); + addModControlsButton(localizedMessages.modSettings.actions.tempBan.label, + () => { + const playerName = prompt(localizedMessages.modSettings.actions.tempBan.playerPrompt); + if (!playerName) + return; + const duration = prompt(localizedMessages.modSettings.actions.tempBan.durationPrompt.replace('{PLAYER}', playerName)); + if (!duration) + return; + apiFetch(`temporaryban?user=${playerName}&duration=${duration}`, true) + .then(response => { + if (!response.ok) { + showToastMessage(getMassagedLabel(localizedMessages.modSettings.actions.tempBan.error, true).replace('{PLAYER}', playerName)); + throw new Error(response.statusText); + } + return response.text(); + }) + .then(_ => showToastMessage(getMassagedLabel(localizedMessages.modSettings.actions.tempBan.success, true).replace('{PLAYER}', playerName).replace('{DURATION}', duration), 'info', true, null, true)) + .catch(err => console.error(err)); + }); addModControlsButton(localizedMessages.modSettings.actions.unban.label, () => adminPlayerAction('unban', localizedMessages.modSettings.actions.unban.playerPrompt, getMassagedLabel(localizedMessages.context.admin.unban.success, true), 'info')); addModControlsButton(localizedMessages.modSettings.actions.mute.label, diff --git a/lang/ar.json b/lang/ar.json index bf24305f..71547885 100644 --- a/lang/ar.json +++ b/lang/ar.json @@ -1081,6 +1081,13 @@ "label": "حظر لاعب", "playerPrompt": "أدخل اسم الحساب المراد حظره" }, + "tempBan": { + "label": "Temporarily ban a Player", + "playerPrompt": "Enter the name of the account to ban", + "durationPrompt": "Enter the duration in minutes to ban {PLAYER} for", + "success": "{PLAYER} has been banned for {DURATION}", + "error": "Failed to ban {PLAYER}" + }, "unban": { "label": "إلغاء حظر لاعب", "playerPrompt": "أدخل اسم الحساب المطلوب إلغاء حظره" @@ -1104,4 +1111,4 @@ } } } -} \ No newline at end of file +} diff --git a/lang/de.json b/lang/de.json index c73eac6b..00a27573 100644 --- a/lang/de.json +++ b/lang/de.json @@ -1081,6 +1081,13 @@ "label": "Ban a Player", "playerPrompt": "Enter the name of the account to ban" }, + "tempBan": { + "label": "Temporarily ban a Player", + "playerPrompt": "Enter the name of the account to ban", + "durationPrompt": "Enter the duration in minutes to ban {PLAYER} for", + "success": "{PLAYER} has been banned for {DURATION}", + "error": "Failed to ban {PLAYER}" + }, "unban": { "label": "Unban a Player", "playerPrompt": "Enter the name of the account to unban" @@ -1104,4 +1111,4 @@ } } } -} \ No newline at end of file +} diff --git a/lang/en.json b/lang/en.json index 2cc0791e..ec6be481 100644 --- a/lang/en.json +++ b/lang/en.json @@ -1081,6 +1081,13 @@ "label": "Ban a Player", "playerPrompt": "Enter the name of the account to ban" }, + "tempBan": { + "label": "Temporarily ban a Player", + "playerPrompt": "Enter the name of the account to ban", + "durationPrompt": "Enter the duration in minutes to ban {PLAYER} for", + "success": "{PLAYER} has been banned for {DURATION}", + "error": "Failed to ban {PLAYER}" + }, "unban": { "label": "Unban a Player", "playerPrompt": "Enter the name of the account to unban" @@ -1104,4 +1111,4 @@ } } } -} \ No newline at end of file +} diff --git a/lang/eo.json b/lang/eo.json index 24e7c11b..bff0a108 100644 --- a/lang/eo.json +++ b/lang/eo.json @@ -1080,6 +1080,13 @@ "label": "Forbari Ludanton", "playerPrompt": "Entajpi la nomon de la konto por forbari" }, + "tempBan": { + "label": "Temporarily ban a Player", + "playerPrompt": "Enter the name of the account to ban", + "durationPrompt": "Enter the duration in minutes to ban {PLAYER} for", + "success": "{PLAYER} has been banned for {DURATION}", + "error": "Failed to ban {PLAYER}" + }, "unban": { "label": "Malforbari Ludanton", "playerPrompt": "Entajpi la nomon de la konto por malforbari" @@ -1103,4 +1110,4 @@ } } } -} \ No newline at end of file +} diff --git a/lang/es.json b/lang/es.json index bb213083..727693b0 100644 --- a/lang/es.json +++ b/lang/es.json @@ -1081,6 +1081,13 @@ "label": "Banear Jugador", "playerPrompt": "Ingrese el nombre de la cuenta a banear" }, + "tempBan": { + "label": "Temporarily ban a Player", + "playerPrompt": "Enter the name of the account to ban", + "durationPrompt": "Enter the duration in minutes to ban {PLAYER} for", + "success": "{PLAYER} has been banned for {DURATION}", + "error": "Failed to ban {PLAYER}" + }, "unban": { "label": "Desbanear Jugador", "playerPrompt": "Ingrese el nombre de la cuenta a desbanear" @@ -1104,4 +1111,4 @@ } } } -} \ No newline at end of file +} diff --git a/lang/fr.json b/lang/fr.json index 3b06ba6d..897d827a 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -1081,6 +1081,13 @@ "label": "Bannir un Joueur", "playerPrompt": "Entrez le nom du compte à bannir" }, + "tempBan": { + "label": "Temporarily ban a Player", + "playerPrompt": "Enter the name of the account to ban", + "durationPrompt": "Enter the duration in minutes to ban {PLAYER} for", + "success": "{PLAYER} has been banned for {DURATION}", + "error": "Failed to ban {PLAYER}" + }, "unban": { "label": "Débannir un Joueur", "playerPrompt": "Entrez le nom du compte à débannir" diff --git a/lang/it.json b/lang/it.json index b44bc1a4..0b0d7be7 100644 --- a/lang/it.json +++ b/lang/it.json @@ -1081,6 +1081,13 @@ "label": "Banna un Giocatore", "playerPrompt": "Inserisci il nome dell'account che vuoi bannare" }, + "tempBan": { + "label": "Temporarily ban a Player", + "playerPrompt": "Enter the name of the account to ban", + "durationPrompt": "Enter the duration in minutes to ban {PLAYER} for", + "success": "{PLAYER} has been banned for {DURATION}", + "error": "Failed to ban {PLAYER}" + }, "unban": { "label": "Unbanna un Giocatore", "playerPrompt": "Inserisci il nome dell'account che vuoi unbannare" @@ -1104,4 +1111,4 @@ } } } -} \ No newline at end of file +} diff --git a/lang/ja.json b/lang/ja.json index 5fd2f642..82664f26 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -1081,6 +1081,13 @@ "label": "プレイヤーのBAN", "playerPrompt": "BANするアカウントの名前を入力してください。" }, + "tempBan": { + "label": "Temporarily ban a Player", + "playerPrompt": "Enter the name of the account to ban", + "durationPrompt": "Enter the duration in minutes to ban {PLAYER} for", + "success": "{PLAYER} has been banned for {DURATION}", + "error": "Failed to ban {PLAYER}" + }, "unban": { "label": "プレイヤーのBAN解除", "playerPrompt": "BAN解除するアカウントの名前を入力してください。" diff --git a/lang/ko.json b/lang/ko.json index 32733afb..e73fd99e 100644 --- a/lang/ko.json +++ b/lang/ko.json @@ -1081,6 +1081,13 @@ "label": "플레이어 차단 설정", "playerPrompt": "차단할 플레이어의 닉네임을 입력해주세요" }, + "tempBan": { + "label": "Temporarily ban a Player", + "playerPrompt": "Enter the name of the account to ban", + "durationPrompt": "Enter the duration in minutes to ban {PLAYER} for", + "success": "{PLAYER} has been banned for {DURATION}", + "error": "Failed to ban {PLAYER}" + }, "unban": { "label": "플레이어 차단 해제", "playerPrompt": "차단 해제할 플레이어의 닉네임을 입력해주세요" @@ -1104,4 +1111,4 @@ } } } -} \ No newline at end of file +} diff --git a/lang/pl.json b/lang/pl.json index 2437ba59..3c7fea6c 100644 --- a/lang/pl.json +++ b/lang/pl.json @@ -1081,6 +1081,13 @@ "label": "Zbanuj gracza", "playerPrompt": "Podaj nazwę gracza do zbanowania" }, + "tempBan": { + "label": "Temporarily ban a Player", + "playerPrompt": "Enter the name of the account to ban", + "durationPrompt": "Enter the duration in minutes to ban {PLAYER} for", + "success": "{PLAYER} has been banned for {DURATION}", + "error": "Failed to ban {PLAYER}" + }, "unban": { "label": "Odbanuj gracza", "playerPrompt": "Podaj nazwę gracza do odbanowania" @@ -1104,4 +1111,4 @@ } } } -} \ No newline at end of file +} diff --git a/lang/pt.json b/lang/pt.json index f9e9362f..dacb60fa 100644 --- a/lang/pt.json +++ b/lang/pt.json @@ -1081,6 +1081,13 @@ "label": "Banir um Jogador", "playerPrompt": "Digite o nome da conta para banir" }, + "tempBan": { + "label": "Temporarily ban a Player", + "playerPrompt": "Enter the name of the account to ban", + "durationPrompt": "Enter the duration in minutes to ban {PLAYER} for", + "success": "{PLAYER} has been banned for {DURATION}", + "error": "Failed to ban {PLAYER}" + }, "unban": { "label": "Desbanir um Jogador", "playerPrompt": "Digite o nome da conta para desbanir" @@ -1104,4 +1111,4 @@ } } } -} \ No newline at end of file +} diff --git a/lang/ro.json b/lang/ro.json index 1013d295..d5f3b8bb 100644 --- a/lang/ro.json +++ b/lang/ro.json @@ -1081,6 +1081,13 @@ "label": "Ban a Player", "playerPrompt": "Enter the name of the account to ban" }, + "tempBan": { + "label": "Temporarily ban a Player", + "playerPrompt": "Enter the name of the account to ban", + "durationPrompt": "Enter the duration in minutes to ban {PLAYER} for", + "success": "{PLAYER} has been banned for {DURATION}", + "error": "Failed to ban {PLAYER}" + }, "unban": { "label": "Unban a Player", "playerPrompt": "Enter the name of the account to unban" @@ -1104,4 +1111,4 @@ } } } -} \ No newline at end of file +} diff --git a/lang/ru.json b/lang/ru.json index 1b7181e3..88fda634 100644 --- a/lang/ru.json +++ b/lang/ru.json @@ -1081,6 +1081,13 @@ "label": "Забанить игрока", "playerPrompt": "Введите имя аккаунта, что необходимо забанить" }, + "tempBan": { + "label": "Temporarily ban a Player", + "playerPrompt": "Enter the name of the account to ban", + "durationPrompt": "Enter the duration in minutes to ban {PLAYER} for", + "success": "{PLAYER} has been banned for {DURATION}", + "error": "Failed to ban {PLAYER}" + }, "unban": { "label": "Разбанить игрока", "playerPrompt": "Введите имя аккаунта, что необходимо разбанить" @@ -1104,4 +1111,4 @@ } } } -} \ No newline at end of file +} diff --git a/lang/tr.json b/lang/tr.json index eed642bc..f4ac1ff3 100644 --- a/lang/tr.json +++ b/lang/tr.json @@ -1081,6 +1081,13 @@ "label": "Bir Kullanıcı Banla", "playerPrompt": "Banlamak için hesabın adını girin" }, + "tempBan": { + "label": "Temporarily ban a Player", + "playerPrompt": "Enter the name of the account to ban", + "durationPrompt": "Enter the duration in minutes to ban {PLAYER} for", + "success": "{PLAYER} has been banned for {DURATION}", + "error": "Failed to ban {PLAYER}" + }, "unban": { "label": "Bir Kullanıcı Banı Kaldır", "playerPrompt": "Ban kaldırmak için hesabın adını girin" @@ -1104,4 +1111,4 @@ } } } -} \ No newline at end of file +} diff --git a/lang/vi.json b/lang/vi.json index 528800a2..4a523669 100644 --- a/lang/vi.json +++ b/lang/vi.json @@ -1081,6 +1081,13 @@ "label": "Ban Người chơi", "playerPrompt": "Nhập tên người chơi để ban" }, + "tempBan": { + "label": "Temporarily ban a Player", + "playerPrompt": "Enter the name of the account to ban", + "durationPrompt": "Enter the duration in minutes to ban {PLAYER} for", + "success": "{PLAYER} has been banned for {DURATION}", + "error": "Failed to ban {PLAYER}" + }, "unban": { "label": "Bỏ ban Người chơi", "playerPrompt": "Nhập tên người chơi để bỏ ban" diff --git a/lang/zh.json b/lang/zh.json index 88f60cfb..ab1084d9 100644 --- a/lang/zh.json +++ b/lang/zh.json @@ -1081,6 +1081,13 @@ "label": "封禁玩家", "playerPrompt": "请输入淘气鬼的用户名" }, + "tempBan": { + "label": "Temporarily ban a Player", + "playerPrompt": "Enter the name of the account to ban", + "durationPrompt": "Enter the duration in minutes to ban {PLAYER} for", + "success": "{PLAYER} has been banned for {DURATION}", + "error": "Failed to ban {PLAYER}" + }, "unban": { "label": "解封玩家", "playerPrompt": "请输入要宽恕的用户名"