Skip to content

Commit df34cff

Browse files
committed
add last count command
1 parent 21747ae commit df34cff

File tree

10 files changed

+86
-13
lines changed

10 files changed

+86
-13
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Alternatively you can host the bot yourself. Instructions [below ⏬](#wrench-se
6363
- Optionally, set a timeout increment factor (`/timeout-increment`) (Default: Disabled)
6464
- Optionally, enable cheat mode (`/cheat-mode`) (Default: Disabled)
6565
- Optionally, set a loser role (`/set-loser-role`) (Default: None)
66+
- Optionally, set the last count e.g. if you migrate from another bot (`/set-last-count`) (Default: 0)
6667
- [x] Easy to self-host
6768
- No external database needed
6869
- Easy configuration system

locales/English_en.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,14 @@
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`, `/set-loser-role` 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`, `/set-last-count` 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?",
8787
"no_banns": "There are no banned users at the moment.",
8888
"set_loser_role": "Loser role has been set to %s with a duration of %sh!",
8989
"unset_loser_role": "Loser role has been unset!",
90-
"add_loser_role": "You have been given the %s role for %sh!"
90+
"add_loser_role": "You have been given the %s role for %sh!",
91+
"set_last_count": "Last count has been set to %s!"
9192
}
9293
}

locales/French_fr.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,14 @@
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`, `/set-loser-role` 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`, `/set-last-count` 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 ?",
8787
"no_banns": "Il n'y a pas d'utilisateurs bannis pour le moment.",
8888
"set_loser_role": "Le rôle de perdant a été défini sur %s pour une durée de %s heures !",
8989
"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 !"
90+
"add_loser_role": "Vous avez reçu le rôle %s pour %s heures !",
91+
"set_last_count": "Le dernier compte a été réglé sur %s !"
9192
}
9293
}

locales/German_de.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,14 @@
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`, `/set-loser-role` 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`, `/set-last-count` 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?",
8787
"no_banns": "Es gibt derzeit keine gebannten Benutzer.",
8888
"set_loser_role": "Die Verliererrolle wurde auf %s mit einer Dauer von %sh gesetzt!",
8989
"unset_loser_role": "Die Verliererrolle wurde entfernt!",
90-
"add_loser_role": "Du hast die %s Rolle für %sh erhalten!"
90+
"add_loser_role": "Du hast die %s Rolle für %sh erhalten!",
91+
"set_last_count": "Die letzte Zählung wurde auf %s gesetzt!"
9192
}
9293
}

locales/Japanese_ja.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,14 @@
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`、`/set-loser-role`、`/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`、`/set-last-count`、`/timeout-increment` でオプションを構成できます。\nSupport Server: <https://discord.gg/hgFyq43dug>\nWiki: <https://arithmetica.xyz/wiki>",
8484
"pin_highscore": "ハイスコアのピン留めが%sされました!",
8585
"rounding": "丸めは%sされました!",
8686
"channel_create": "私はチャンネル`%s`を見つけることができません。作成しますか?",
8787
"no_banns": "現在、禁止されているユーザーはいません。",
8888
"set_loser_role": "敗者の役割が %s に設定され、期間は %s 時間です!",
8989
"unset_loser_role": "敗者の役割が解除されました!",
90-
"add_loser_role": "あなたは %s の役割を %s 時間持っています!"
90+
"add_loser_role": "あなたは %s の役割を %s 時間持っています!",
91+
"set_last_count": "最後のカウントは %s に設定されました!"
9192
}
9293
}

locales/Russian_ru.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,14 @@
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`, `/set-loser-role` и `/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`, `/set-last-count` и `/timeout-increment`.\nSupport Server: <https://discord.gg/hgFyq43dug>\nWiki: <https://arithmetica.xyz/wiki>",
8484
"pin_highscore": "Закрепление рекордов было %s!",
8585
"rounding": "Округление было %s!",
8686
"channel_create": "Я не могу найти канал `%s`. Хотите, чтобы я создал его?",
8787
"no_banns": "На данный момент нет заблокированных пользователей.",
8888
"set_loser_role": "Роль неудачника установлена на %s на срок %s часов!",
8989
"unset_loser_role": "Роль неудачника снята!",
90-
"add_loser_role": "Вы получили роль %s на %s часов!"
90+
"add_loser_role": "Вы получили роль %s на %s часов!",
91+
"set_last_count": "Последний подсчет был установлен на %s!"
9192
}
9293
}

locales/Spanish_es-ES.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,14 @@
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`, `/set-loser-role` 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`, `/set-last-count` 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?",
8787
"no_banns": "No hay usuarios prohibidos en este momento.",
8888
"set_loser_role": "¡El rol de perdedor se ha establecido en %s con una duración de %s horas!",
8989
"unset_loser_role": "¡El rol de perdedor se ha eliminado!",
90-
"add_loser_role": "¡Se le ha dado el rol %s por %s horas!"
90+
"add_loser_role": "¡Se le ha dado el rol %s por %s horas!",
91+
"set_last_count": "El último conteo ha sido establecido en %s!"
9192
}
9293
}

locales/commands/translations.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,4 +633,26 @@ export default {
633633
"es-ES": "Deshabilitar el rol de perdedor.",
634634
},
635635
},
636+
set_last_count: {
637+
desc: "Set the last count of the server.",
638+
translations: {
639+
de: "Setze die letzte Zählung des Servers.",
640+
fr: "Définir le dernier compte du serveur.",
641+
ru: "Установить последний счет сервера.",
642+
ja: "サーバーの最後のカウントを設定します。",
643+
"es-ES": "Establecer el último recuento del servidor.",
644+
},
645+
options: {
646+
count: {
647+
desc: "The count to set",
648+
translations: {
649+
de: "Die zu setzende Zählung",
650+
fr: "Le compte à définir",
651+
ru: "Счет для установки",
652+
ja: "設定するカウント",
653+
"es-ES": "El recuento a establecer",
654+
},
655+
},
656+
},
657+
},
636658
};

src/commands/admin/last-count.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default {
2828

2929
return await interaction.reply({
3030
content: String(lastCount),
31-
ephemeral: true,
31+
ephemeral: false,
3232
});
3333
},
3434
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 guildDb = 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.set_last_count.desc)
21+
.setDescriptionLocalizations(translations.set_last_count.translations)
22+
.setDMPermission(false)
23+
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
24+
.addIntegerOption((option) =>
25+
option.setName("count")
26+
.setDescription(translations.set_last_count.options.count.desc)
27+
.setDescriptionLocalizations(translations.set_last_count.options.count.translations)
28+
.setRequired(true)),
29+
30+
/**
31+
* @param {import("discord.js").CommandInteraction} interaction
32+
*/
33+
async execute(interaction){
34+
const cnt = interaction.options.get("count")?.value || 0;
35+
36+
await guildDb.set(`guild-${interaction.guildId}.count`, cnt);
37+
await guildDb.delete(`guild-${interaction.guildId}.lastUser`);
38+
39+
await interaction.reply({
40+
content: await __("replies.set_last_count", cnt)(interaction.guildId),
41+
ephemeral: true,
42+
});
43+
},
44+
};

0 commit comments

Comments
 (0)