Skip to content

Commit e87d0a0

Browse files
authored
Merge pull request #46 from NullDev/feat/loser-role
Feat/loser role
2 parents 1cd5895 + 553402a commit e87d0a0

File tree

14 files changed

+271
-13
lines changed

14 files changed

+271
-13
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Alternatively you can host the bot yourself. Instructions [below ⏬](#wrench-se
6161
- Optionally, set a cooldown for new server members (`/cooldown`) (Default: 60 minutes)
6262
- Optionally, set a timeout increment factor (`/timeout-increment`) (Default: Disabled)
6363
- Optionally, enable cheat mode (`/cheat-mode`) (Default: Disabled)
64+
- Optionally, set a loser role (`/set-loser-role`) (Default: None)
6465
- [x] Easy to self-host
6566
- No external database needed
6667
- Easy configuration system

locales/English_en.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,13 @@
8080
"global_top_best": "Server \"%s\" is on place #%s in the global leaderboard (%s servers) with its best count (%s)!",
8181
"new_best": "New highscore!",
8282
"help_preamble": "You can visit <https://arithmetica.xyz/wiki> to see, what expressions and syntax is possible. To check, if an expression is a valid count, you can use `/calc` to see if the result is correct.\nSupport Server: <https://discord.gg/hgFyq43dug>",
83-
"admin_help_preamble": "Setup: Set the counting channel with `/set-channel`, then alternatively configure options with `/set-language`, `/toggle-arithmetic`, `/set-timeout`, `/cooldown` and `/timeout-increment`.\nSupport Server: <https://discord.gg/hgFyq43dug>\nWiki: <https://arithmetica.xyz/wiki>",
83+
"admin_help_preamble": "Setup: Set the counting channel with `/set-channel`, then alternatively configure options with `/set-language`, `/toggle-arithmetic`, `/set-timeout`, `/cooldown`, `/set-loser-role` and `/timeout-increment`.\nSupport Server: <https://discord.gg/hgFyq43dug>\nWiki: <https://arithmetica.xyz/wiki>",
8484
"pin_highscore": "Highscore pinning has been %s!",
8585
"rounding": "Rounding has been %s!",
8686
"channel_create": "I can't find the channel `%s`. Do you want me to create it?",
87-
"no_banns": "There are no banned users at the moment."
87+
"no_banns": "There are no banned users at the moment.",
88+
"set_loser_role": "Loser role has been set to %s with a duration of %sh!",
89+
"unset_loser_role": "Loser role has been unset!",
90+
"add_loser_role": "You have been given the %s role for %sh!"
8891
}
8992
}

locales/French_fr.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,13 @@
8080
"global_top_best": "Le serveur \"%s\" est à la place #%s dans le classement mondial (%s serveurs) avec son meilleur compte (%s)!",
8181
"new_best": "Nouveau record !",
8282
"help_preamble": "Vous pouvez visiter <https://arithmetica.xyz/wiki> pour voir quelles expressions et syntaxes sont possibles. Pour vérifier si une expression est un compte valide, vous pouvez utiliser `/calc` pour voir si le résultat est correct.\nSupport Server: <https://discord.gg/hgFyq43dug>",
83-
"admin_help_preamble": "Configuration: Définissez le canal de comptage avec `/set-channel`, puis configurez éventuellement les options avec `/set-language`, `/toggle-arithmetic`, `/set-timeout`, `/cooldown` et `/timeout-increment`.\nSupport Server: <https://discord.gg/hgFyq43dug>\nWiki: <https://arithmetica.xyz/wiki>",
83+
"admin_help_preamble": "Configuration: Définissez le canal de comptage avec `/set-channel`, puis configurez éventuellement les options avec `/set-language`, `/toggle-arithmetic`, `/set-timeout`, `/cooldown`, `/set-loser-role` et `/timeout-increment`.\nSupport Server: <https://discord.gg/hgFyq43dug>\nWiki: <https://arithmetica.xyz/wiki>",
8484
"pin_highscore": "épingler le highscore a été %s!",
8585
"rounding": "L'arrondi a été %s!",
8686
"channel_create": "Je ne trouve pas le salon `%s`. Voulez-vous que je le crée ?",
87-
"no_banns": "Il n'y a pas d'utilisateurs bannis pour le moment."
87+
"no_banns": "Il n'y a pas d'utilisateurs bannis pour le moment.",
88+
"set_loser_role": "Le rôle de perdant a été défini sur %s pour une durée de %s heures !",
89+
"unset_loser_role": "Le rôle de perdant a été supprimé !",
90+
"add_loser_role": "Vous avez reçu le rôle %s pour %s heures !"
8891
}
8992
}

locales/German_de.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,13 @@
8080
"global_top_best": "Server \"%s\" ist auf Platz #%s in der globalen Bestenliste (%s Server) mit seiner besten Zählung (%s)!",
8181
"new_best": "Neuer Rekord!",
8282
"help_preamble": "Besuche <https://arithmetica.xyz/wiki>, um zu sehen, welche Ausdrücke und Syntax möglich sind. Um zu überprüfen, ob ein Ausdruck eine gültige Zählung ist, kann `/calc` verwendet werden, um zu sehen, ob das Ergebnis korrekt ist.\nSupport Server: <https://discord.gg/hgFyq43dug>",
83-
"admin_help_preamble": "Einrichtung: Zählchannel mit `/set-channel` einstellen. Danach, optionale Einstellungen mit `/set-language`, `/toggle-arithmetic`, `/set-timeout`, `/cooldown` und `/timeout-increment` konfigurieren.\nSupport Server: <https://discord.gg/hgFyq43dug>\nWiki: <https://arithmetica.xyz/wiki>",
83+
"admin_help_preamble": "Einrichtung: Zählchannel mit `/set-channel` einstellen. Danach, optionale Einstellungen mit `/set-language`, `/toggle-arithmetic`, `/set-timeout`, `/cooldown`, `/set-loser-role` und `/timeout-increment` konfigurieren.\nSupport Server: <https://discord.gg/hgFyq43dug>\nWiki: <https://arithmetica.xyz/wiki>",
8484
"pin_highscore": "Highscore pinning wurde %s!",
8585
"rounding": "Runden wurde %s!",
8686
"channel_create": "Ich kann den Channel `%s` nicht finden. Möchtest du, dass ich ihn erstelle?",
87-
"no_banns": "Es gibt derzeit keine gebannten Benutzer."
87+
"no_banns": "Es gibt derzeit keine gebannten Benutzer.",
88+
"set_loser_role": "Die Verliererrolle wurde auf %s mit einer Dauer von %sh gesetzt!",
89+
"unset_loser_role": "Die Verliererrolle wurde entfernt!",
90+
"add_loser_role": "Du hast die %s Rolle für %sh erhalten!"
8891
}
8992
}

locales/Japanese_ja.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,13 @@
8080
"global_top_best": "サーバー \"%s\" はグローバルリーダーボードで #%s 位です(%s サーバー)、最高のカウントで (%s)!",
8181
"new_best": "新しいハイスコア!",
8282
"help_preamble": "<https://arithmetica.xyz/wiki> を訪れて、どのような表現や構文が可能かを確認できます。表現が有効なカウントであるかどうかを確認するには、`/calc`を使用して結果が正しいかどうかを確認できます。\nSupport Server: <https://discord.gg/hgFyq43dug>",
83-
"admin_help_preamble": "設定:`/set-channel`でカウントチャネルを設定し、次に `/set-language`、`/toggle-arithmetic`、`/set-timeout`、`/cooldown`、`/timeout-increment` でオプションを構成できます。\nSupport Server: <https://discord.gg/hgFyq43dug>\nWiki: <https://arithmetica.xyz/wiki>",
83+
"admin_help_preamble": "設定:`/set-channel`でカウントチャネルを設定し、次に `/set-language`、`/toggle-arithmetic`、`/set-timeout`、`/cooldown`、`/set-loser-role`、`/timeout-increment` でオプションを構成できます。\nSupport Server: <https://discord.gg/hgFyq43dug>\nWiki: <https://arithmetica.xyz/wiki>",
8484
"pin_highscore": "ハイスコアのピン留めが%sされました!",
8585
"rounding": "丸めは%sされました!",
8686
"channel_create": "私はチャンネル`%s`を見つけることができません。作成しますか?",
87-
"no_banns": "現在、禁止されているユーザーはいません。"
87+
"no_banns": "現在、禁止されているユーザーはいません。",
88+
"set_loser_role": "敗者の役割が %s に設定され、期間は %s 時間です!",
89+
"unset_loser_role": "敗者の役割が解除されました!",
90+
"add_loser_role": "あなたは %s の役割を %s 時間持っています!"
8891
}
8992
}

locales/Russian_ru.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,13 @@
8080
"global_top_best": "Сервер \"%s\" находится на #%s месте в мировом рейтинге (%s серверов) со своим лучшим счетом (%s)!",
8181
"new_best": "Новый рекорд!",
8282
"help_preamble": "Вы можете посетить <https://arithmetica.xyz/wiki>, чтобы узнать, какие выражения и синтаксис возможны. Чтобы проверить, является ли выражение допустимым подсчетом, вы можете использовать `/calc`, чтобы увидеть, правильный ли результат.\nSupport Server: <https://discord.gg/hgFyq43dug>",
83-
"admin_help_preamble": "Настройка: Установите канал подсчета с помощью `/set-channel`, затем при необходимости настройте опции с помощью `/set-language`, `/toggle-arithmetic`, `/set-timeout`, `/cooldown` и `/timeout-increment`.\nSupport Server: <https://discord.gg/hgFyq43dug>\nWiki: <https://arithmetica.xyz/wiki>",
83+
"admin_help_preamble": "Настройка: Установите канал подсчета с помощью `/set-channel`, затем при необходимости настройте опции с помощью `/set-language`, `/toggle-arithmetic`, `/set-timeout`, `/cooldown`, `/set-loser-role` и `/timeout-increment`.\nSupport Server: <https://discord.gg/hgFyq43dug>\nWiki: <https://arithmetica.xyz/wiki>",
8484
"pin_highscore": "Закрепление рекордов было %s!",
8585
"rounding": "Округление было %s!",
8686
"channel_create": "Я не могу найти канал `%s`. Хотите, чтобы я создал его?",
87-
"no_banns": "На данный момент нет заблокированных пользователей."
87+
"no_banns": "На данный момент нет заблокированных пользователей.",
88+
"set_loser_role": "Роль неудачника установлена на %s на срок %s часов!",
89+
"unset_loser_role": "Роль неудачника снята!",
90+
"add_loser_role": "Вы получили роль %s на %s часов!"
8891
}
8992
}

locales/Spanish_es-ES.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,13 @@
8080
"global_top_best": "El servidor \"%s\" está en el lugar #%s en la clasificación global (%s servidores) con su mejor conteo (%s)!",
8181
"new_best": "¡Nuevo récord!",
8282
"help_preamble": "Puede visitar <https://arithmetica.xyz/wiki> para ver qué expresiones y sintaxis son posibles. Para verificar si una expresión es un recuento válido, puede usar `/calc` para ver si el resultado es correcto.\nSupport Server: <https://discord.gg/hgFyq43dug>",
83-
"admin_help_preamble": "Configuración: Establezca el canal de conteo con `/set-channel`, luego configure opcionalmente opciones con `/set-language`, `/toggle-arithmetic`, `/set-timeout`, `/cooldown` y `/timeout-increment`.\nSupport Server: <https://discord.gg/hgFyq43dug>\nWiki: <https://arithmetica.xyz/wiki>",
83+
"admin_help_preamble": "Configuración: Establezca el canal de conteo con `/set-channel`, luego configure opcionalmente opciones con `/set-language`, `/toggle-arithmetic`, `/set-timeout`, `/cooldown`, `/set-loser-role` y `/timeout-increment`.\nSupport Server: <https://discord.gg/hgFyq43dug>\nWiki: <https://arithmetica.xyz/wiki>",
8484
"pin_highscore": "¡El pin de la puntuación más alta ha sido %s!",
8585
"rounding": "¡El redondeo ha sido %s!",
8686
"channel_create": "No puedo encontrar el canal `%s`. ¿Quieres que lo cree?",
87-
"no_banns": "No hay usuarios prohibidos en este momento."
87+
"no_banns": "No hay usuarios prohibidos en este momento.",
88+
"set_loser_role": "¡El rol de perdedor se ha establecido en %s con una duración de %s horas!",
89+
"unset_loser_role": "¡El rol de perdedor se ha eliminado!",
90+
"add_loser_role": "¡Se le ha dado el rol %s por %s horas!"
8891
}
8992
}

locales/commands/translations.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,4 +591,46 @@ export default {
591591
"es-ES": "Enumerar todos los usuarios bloqueados.",
592592
},
593593
},
594+
set_loser_role: {
595+
desc: "Set the loser role.",
596+
translations: {
597+
de: "Setze die Verlierer-Rolle.",
598+
fr: "Définir le rôle de perdant.",
599+
ru: "Установить роль проигравшего.",
600+
ja: "敗者の役割を設定します。",
601+
"es-ES": "Establecer el rol de perdedor.",
602+
},
603+
options: {
604+
role: {
605+
desc: "The role to set",
606+
translations: {
607+
de: "Die zu setzende Rolle",
608+
fr: "Le rôle à définir",
609+
ru: "Роль для установки",
610+
ja: "設定する役割",
611+
"es-ES": "El rol a establecer",
612+
},
613+
},
614+
duration: {
615+
desc: "Duration of the role in hours",
616+
translations: {
617+
de: "Dauer der Rolle in Stunden",
618+
fr: "Durée du rôle en heures",
619+
ru: "Продолжительность роли в часах",
620+
ja: "役割の期間",
621+
"es-ES": "Duración del rol en horas",
622+
},
623+
},
624+
},
625+
},
626+
unset_loser_role: {
627+
desc: "Unset the loser role.",
628+
translations: {
629+
de: "Entferne die Verlierer-Rolle.",
630+
fr: "Désactiver le rôle de perdant.",
631+
ru: "Отменить роль проигравшего.",
632+
ja: "敗者の役割を解除します。",
633+
"es-ES": "Deshabilitar el rol de perdedor.",
634+
},
635+
},
594636
};
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import path from "node:path";
2+
import { SlashCommandBuilder, PermissionFlagsBits } from "discord.js";
3+
import { QuickDB } from "quick.db";
4+
import translations from "../../../locales/commands/translations.js";
5+
import defaults from "../../util/defaults.js";
6+
import __ from "../../service/i18n.js";
7+
8+
// ========================= //
9+
// = Copyright (c) NullDev = //
10+
// ========================= //
11+
12+
const db = new QuickDB({
13+
filePath: path.resolve("./data/guild_data.sqlite"),
14+
});
15+
16+
const commandName = import.meta.url.split("/").pop()?.split(".").shift() ?? "";
17+
18+
export default {
19+
data: new SlashCommandBuilder()
20+
.setName(commandName)
21+
.setDescription(translations.set_loser_role.desc)
22+
.setDescriptionLocalizations(translations.set_loser_role.translations)
23+
.setDMPermission(false)
24+
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
25+
.addRoleOption((option) =>
26+
option.setName("role")
27+
.setDescription(translations.set_loser_role.options.role.desc)
28+
.setDescriptionLocalizations(translations.set_loser_role.options.role.translations)
29+
.setRequired(true))
30+
.addIntegerOption((option) =>
31+
option.setName("duration")
32+
.setDescription(translations.set_loser_role.options.duration.desc)
33+
.setDescriptionLocalizations(translations.set_loser_role.options.duration.translations)
34+
.setRequired(true)),
35+
36+
/**
37+
* @param {import("discord.js").CommandInteraction} interaction
38+
*/
39+
async execute(interaction){
40+
const role = interaction.options.get("role")?.value;
41+
const duration = interaction.options.get("duration")?.value || defaults.loser_role_duration;
42+
43+
if (!role || !duration){
44+
return await interaction.reply({
45+
content: await __("errors.invalid_argument")(interaction.guildId),
46+
ephemeral: true,
47+
});
48+
}
49+
50+
await db.set(`guild-${interaction.guildId}.loserRole`, role);
51+
await db.set(`guild-${interaction.guildId}.loserRoleDuration`, duration);
52+
53+
const rolename = (await interaction.guild?.roles.fetch(String(role))?.catch(() => null))?.name;
54+
55+
return await interaction.reply({
56+
content: await __("replies.set_loser_role", rolename, duration)(interaction.guildId),
57+
ephemeral: true,
58+
});
59+
},
60+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import path from "node:path";
2+
import { SlashCommandBuilder, PermissionFlagsBits } from "discord.js";
3+
import { QuickDB } from "quick.db";
4+
import translations from "../../../locales/commands/translations.js";
5+
import __ from "../../service/i18n.js";
6+
7+
// ========================= //
8+
// = Copyright (c) NullDev = //
9+
// ========================= //
10+
11+
const db = new QuickDB({
12+
filePath: path.resolve("./data/guild_data.sqlite"),
13+
});
14+
15+
const commandName = import.meta.url.split("/").pop()?.split(".").shift() ?? "";
16+
17+
export default {
18+
data: new SlashCommandBuilder()
19+
.setName(commandName)
20+
.setDescription(translations.unset_loser_role.desc)
21+
.setDescriptionLocalizations(translations.unset_loser_role.translations)
22+
.setDMPermission(false)
23+
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
24+
25+
/**
26+
* @param {import("discord.js").CommandInteraction} interaction
27+
*/
28+
async execute(interaction){
29+
await db.delete(`guild-${interaction.guildId}.loserRole`);
30+
await db.delete(`guild-${interaction.guildId}.loserRoleDuration`);
31+
32+
return await interaction.reply({
33+
content: await __("replies.unset_loser_role")(interaction.guildId),
34+
ephemeral: true,
35+
});
36+
},
37+
};

0 commit comments

Comments
 (0)