Compare commits

...

3 commits

Author SHA1 Message Date
10fa611740
remove translations
All checks were successful
Lint and Format Check / lint-and-format (pull_request) Successful in 10s
2024-09-17 19:40:01 +02:00
db7dd69de6
remove archive related commands 2024-09-17 19:39:11 +02:00
fdc081fd6d
merge dev to main (#168)
All checks were successful
Publish latest version / build (push) Successful in 1m32s
Close #161

Reviewed-on: #168
Co-authored-by: Mylloon <kennel.anri@tutanota.com>
Co-committed-by: Mylloon <kennel.anri@tutanota.com>
2024-09-17 19:33:26 +02:00
6 changed files with 39 additions and 325 deletions

View file

@ -1,139 +0,0 @@
import { SlashCommandBuilder } from "@discordjs/builders";
import {
ChannelType,
Client,
Colors,
CommandInteraction,
EmbedBuilder,
NonThreadGuildBasedChannel,
} from "discord.js";
import "../../modules/string";
import { getLocale, getLocalizations } from "../../utils/locales";
import { getFilename } from "../../utils/misc";
export default {
scope: () => ["807244911350906920"],
data: (client: Client) => {
const filename = getFilename(__filename);
return (
new SlashCommandBuilder()
.setName(filename.toLowerCase())
.setDescription(client.locales.get(client.config.default_lang)!.get(`c_${filename}_desc`)!)
.setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true))
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`))
// Command option
.addStringOption((option) =>
option
.setName(
client.locales.get(client.config.default_lang)!.get(`c_${filename}_opt1_name`)!,
)
.setDescription(
client.locales.get(client.config.default_lang)!.get(`c_${filename}_opt1_desc`)!,
)
.setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true))
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`)),
)
);
},
interaction: async (interaction: CommandInteraction, client: Client) => {
const loc = getLocale(client, interaction.locale);
const desiredCat = interaction.options.get(
client.locales
.get(client.config.default_lang)!
.get(`c_${getFilename(__filename)}_opt1_name`)!,
)?.value as string;
// If a category isn't specified
if (!desiredCat) {
// Sends a list of commands sorted into categories
return interaction.reply({
embeds: [
new EmbedBuilder()
.setColor(Colors.Blurple)
.setTitle(loc.get("c_archive1"))
.setDescription(loc.get("c_archive2")),
],
});
}
// If a category is specified
const cleanCat = ["L1", "L2", "L3", "M1", "M2"];
const channel = cleanCat.includes(desiredCat);
if (!channel) {
// Category doesn't exist or is not included
return interaction.reply({
content: `${loc.get("c_archive3")} \`${desiredCat}\``,
ephemeral: true,
});
}
const allChannel = interaction.guild?.channels.fetch();
allChannel?.then(async (channelGuild) => {
// Retrieve category to archive
const catToArchive = channelGuild
.filter((chan) => chan?.type == ChannelType.GuildCategory)
.filter((chan) => chan?.name == desiredCat);
// Create/Retrieve the archive category
const catArchivedName = "archive - " + desiredCat;
const catArchivedMap = channelGuild
.filter((chan) => chan?.type == ChannelType.GuildCategory)
.filter((chan) => chan?.name == catArchivedName);
let catArchived: NonThreadGuildBasedChannel | null | undefined;
if (catArchivedMap.size > 0) {
catArchived = catArchivedMap.at(0);
} else {
catArchived = await interaction.guild?.channels.create({
name: catArchivedName,
type: ChannelType.GuildCategory,
});
}
const allChannelDesired = channelGuild
.filter((chan) => chan?.type == 0)
.filter((chan) => chan?.parentId == catToArchive.map((cat) => cat?.id)[0]);
// If no channels in the source category
if (allChannelDesired.size == 0) {
return interaction.reply({
embeds: [
new EmbedBuilder()
.setColor(Colors.Blurple)
.setTitle(loc.get("c_archive6"))
.setDescription(loc.get("c_archive7")),
],
});
}
// Move channels to the archived categoryx
allChannelDesired.forEach((elem) => elem?.setParent(catArchived?.id as string));
return interaction.reply({
embeds: [
new EmbedBuilder()
.setColor(Colors.Blurple)
.setTitle(
loc.get("c_archive4") +
" `" +
catToArchive.map((cat) => cat?.name) +
"` " +
loc.get("c_archive5") +
" `" +
catArchivedName +
"`",
)
.setDescription(
allChannelDesired
.map((cgD) => cgD?.name)
.toString()
.replaceAll(",", "\n"),
),
],
});
});
},
};

View file

@ -1,118 +0,0 @@
import { SlashCommandBuilder } from "@discordjs/builders";
import { ChannelType, Client, Colors, CommandInteraction, EmbedBuilder } from "discord.js";
import "../../modules/string";
import { getLocale, getLocalizations } from "../../utils/locales";
import { getFilename } from "../../utils/misc";
export default {
scope: () => ["807244911350906920"],
data: (client: Client) => {
const filename = getFilename(__filename);
return (
new SlashCommandBuilder()
.setName(filename.toLowerCase())
.setDescription(client.locales.get(client.config.default_lang)!.get(`c_${filename}_desc`)!)
.setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true))
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`))
// Command option
.addStringOption((option) =>
option
.setName(
client.locales.get(client.config.default_lang)!.get(`c_${filename}_opt1_name`)!,
)
.setDescription(
client.locales.get(client.config.default_lang)!.get(`c_${filename}_opt1_desc`)!,
)
.setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true))
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`)),
)
);
},
interaction: async (interaction: CommandInteraction, client: Client) => {
const loc = getLocale(client, interaction.locale);
const desired_cat = interaction.options.get(
client.locales
.get(client.config.default_lang)!
.get(`c_${getFilename(__filename)}_opt1_name`)!,
)?.value as string;
// If a category isn't specified
if (!desired_cat) {
// Sends a list of commands sorted into categories
return interaction.reply({
embeds: [
new EmbedBuilder()
.setColor(Colors.Blurple)
.setTitle(loc.get("c_prep1"))
.setDescription(loc.get("c_prep2")),
],
});
}
// If a category is specified
const allowedCategories = ["L1", "L2", "L3", "M1", "M2"];
const channel = allowedCategories.includes(desired_cat);
if (!channel) {
// Category doesn't exist or is not allowed
return interaction.reply({
content: `${loc.get("c_prep3")} \`${desired_cat}\``,
ephemeral: true,
});
}
// Send information about the command
const allChannel = interaction.guild?.channels.fetch();
allChannel?.then((channel_guild) => {
const cat_to_prep = channel_guild
.filter((chan) => chan?.type == ChannelType.GuildCategory)
.filter((chan) => chan?.name == desired_cat);
const cat_to_prep_id = cat_to_prep.map((cat) => cat?.id);
const cat_to_prep_name = cat_to_prep.map((cat) => cat?.name);
// console.log(cat_to_prep);
const all_channel_desired = channel_guild
.filter((chan) => chan?.type == 0)
.filter((chan) => chan?.parentId == cat_to_prep_id[0]);
const all_channel_desired_name = all_channel_desired.map((c_d) => c_d?.name);
let desc = "";
const general = "général";
if (all_channel_desired_name.filter((cdn) => cdn == general).length == 0) {
interaction.guild?.channels.create({
name: general,
type: 0,
parent: cat_to_prep_id[0],
});
desc = general + loc.get("c_prep5") + "\n";
}
const info = "informations";
if (all_channel_desired_name.filter((cdn) => cdn == info).length == 0) {
interaction.guild?.channels.create({
name: info,
type: 0,
parent: cat_to_prep_id[0],
});
desc += "`" + info + "` " + loc.get("c_prep5") + "\n";
}
if (desc == "") {
desc = loc.get("c_prep6");
}
return interaction.reply({
embeds: [
new EmbedBuilder()
.setColor(Colors.Blurple)
.setTitle(loc.get("c_prep4") + cat_to_prep_name)
.setDescription(desc),
],
});
});
},
};

View file

@ -1,10 +1,12 @@
const isDev = process.env.NODE_ENV !== "production";
/** Load the app */
const start_app = () => {
import("./load").then((l) => l.run().catch((error) => console.error(error)));
import("./load").then((l) => l.run(isDev).catch((error) => console.error(error)));
};
// Load .env if not in prod
if (process.env.NODE_ENV !== "production") {
if (isDev) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import("dotenv").then((c) => {

View file

@ -7,13 +7,18 @@ import loadClient, { quit } from "./utils/client";
import { logStart } from "./utils/misc";
/** Run the bot */
export const run = async () => {
export const run = async (isDev: boolean) => {
console.log("Starting Botanique...");
// Client Discord.JS
const client_name = "Client";
await loadClient()
.then(async (client) => {
if (isDev) {
// Attach debugging listeners
client.on("debug", console.log).on("warn", console.warn);
}
// Events Discord.JS and Player
const events_name = "Events";
await loadEvents(client)

View file

@ -1,7 +1,8 @@
{
"e_interacreate_no_command": "Sorry, the command probably no longer exists...",
"e_interacreate_no_modal": "Sorry, the model no longer exists...",
"e_interacreate_no_modal": "Sorry, the template no longer exists...",
"e_interacreate_no_button": "Sorry, the button no longer exists...",
"e_interacreate_no_autocomplete": "Sorry, no autocomplete is available for this command...",
"c_ping_name": "Ping",
"c_ping_desc": "Pong!",
@ -9,36 +10,13 @@
"c_ping2": "Web socket heartbeat",
"c_help_name": "Help",
"c_help_desc": "Informations about commands",
"c_help_desc": "Information about commands",
"c_help_opt1_name": "command",
"c_help_opt1_desc": "Command wanted in depth.",
"c_help1": "List of categories and associated commands",
"c_help2": "`/help <command>` to get more information about a command.",
"c_help3": "Can't find :",
"c_archive_name": "clean",
"c_archive_desc": "Clean category for new year",
"c_archive_opt1_name": "category",
"c_archive_opt1_desc": "Name of the category to be cleaned",
"c_archive1": "List of categories subject to cleaning",
"c_archive2": "`L1`, `L2`, `L3`, `M1`, `M2`",
"c_archive3": "Unable to find/clean the channel:",
"c_archive4": "List of archived channels in the category",
"c_archive5": "to",
"c_archive6": "Cleaning",
"c_archive7": "Category already cleaned",
"c_prep_name": "Preparation",
"c_prep_desc": "Preparation of general channels for the new year",
"c_prep_opt1_name": "year",
"c_prep_opt1_desc": "Name of the year to be prepared",
"c_prep1": "List of categories submitted to the preparation",
"c_prep2": "`L1`, `L2`, `L3`, `M1`, `M2`",
"c_prep3": "Unable to find/clean the channel:",
"c_prep4": "Lists of prepared channels `",
"c_prep5": "created",
"c_prep6": "No preparation required",
"u_time_at": "at",
"c_reminder_name": "reminder",
@ -46,11 +24,11 @@
"c_reminder_sub1_name": "new",
"c_reminder_sub1_desc": "Sets up a reminder",
"c_reminder_sub1_opt1_name": "time",
"c_reminder_sub1_opt1_desc": "Desired time before the reminder, append an @ to activate the mention or a p to send in DM",
"c_reminder_sub1_opt1_desc": "Desired time before the reminder, append an @ to activate the mention or a p to send in a DM",
"c_reminder_sub1_opt2_name": "message",
"c_reminder_sub1_opt2_desc": "Reminder message",
"c_reminder_sub2_name": "list",
"c_reminder_sub2_desc": "Displays the list of reminders of a user",
"c_reminder_sub2_desc": "Displays the list of reminders for a user",
"c_reminder_sub2_opt1_name": "user",
"c_reminder_sub2_opt1_desc": "Displays the list of this user",
"c_reminder_sub2_opt2_name": "page",
@ -61,7 +39,7 @@
"c_reminder_sub3_opt1_desc": "Reminder to be deleted",
"c_reminder1": "A reminder has been set up for in",
"c_reminder2": "The ID entered is not valid.",
"c_reminder3": "Reminder not found, not on the right guild or not belonging to you.",
"c_reminder3": "Reminder not found, not in the right guild, or not belonging to you.",
"c_reminder4": "Unknown user.",
"c_reminder5": "Reminders of",
"c_reminder6": "Page",
@ -81,13 +59,15 @@
"c_play_desc": "Plays a song/playlist, no query displays the now playing song",
"c_play_opt1_name": "query",
"c_play_opt1_desc": "What you want to listen to",
"c_play1": "You're not in any vocal channel.",
"c_play1": "You're not on any vocal channels.",
"c_play2": "You are in the wrong voice channel, I am in",
"c_play3": "Unable to join the voice channel.",
"c_play4": "not found",
"c_play5": "added to the queue",
"c_play6": "The bot is not playing anything right now.",
"c_play7": "Currently playing",
"c_play8": "Asked by",
"c_play9": "No results were found",
"c_stop_name": "stop",
"c_stop_desc": "Stop the music",
@ -134,13 +114,17 @@
"c_lyrics_name": "lyrics",
"c_lyrics_desc": "Displays the lyrics of a song",
"c_lyrics_sub1_name": "normal",
"c_lyrics_sub1_desc": "Lyrics search",
"c_lyrics_sub2_name": "romanized",
"c_lyrics_sub2_desc": "Search for romanized lyrics (e.g., hangul → Latin)",
"c_lyrics_sub3_name": "synced",
"c_lyrics_sub3_desc": "Synchronized lyrics search (updates in live)",
"c_lyrics_opt1_name": "song",
"c_lyrics_opt1_desc": "Wanted song",
"c_lyrics1": "The bot is not playing anything at the moment and no songs are specified.",
"c_lyrics1": "The bot is not playing anything at the moment, and no songs are specified.",
"c_lyrics2": "Unable to find the lyrics for",
"c_lyrics3": "Impossible to find synchronized lyrics for",
"c_lyrics3": "Unable to find synchronized lyrics for",
"c_lyrics4": "It's karaoke time!",
"c_repeat_name": "repeat",
@ -158,5 +142,8 @@
"c_repeat3": "Repeating the queue",
"c_repeat4": "Automatic playback",
"c_repeat5": "Repeating the song",
"c_repeat6": "enabled"
"c_repeat6": "enabled",
"e_trackstart1": "Asked by",
"e_trackstart2": "Duration :"
}

View file

@ -2,7 +2,7 @@
"e_interacreate_no_command": "Désolé, la commande n'existe plus...",
"e_interacreate_no_modal": "Désolé, le modèle n'existe plus...",
"e_interacreate_no_button": "Désolé, le bouton n'existe plus...",
"e_interacreate_no_autocomplete": "Désolé, pas d'autocomplétion existe pour cette commande...",
"e_interacreate_no_autocomplete": "Désolé, pas d'autocomplétion n'existe pour cette commande...",
"c_ping_name": "Ping",
"c_ping_desc": "Pong!",
@ -12,44 +12,21 @@
"c_help_name": "Aide",
"c_help_desc": "Informations sur les commandes",
"c_help_opt1_name": "commande",
"c_help_opt1_desc": "Commande voulu en détail",
"c_help_opt1_desc": "Commande voulue en détail",
"c_help1": "Liste des catégories et des commandes associées",
"c_help2": "`/help <commande>` pour obtenir plus d'informations sur une commande.",
"c_help3": "Impossible de trouver :",
"c_archive_name": "Nettoyer",
"c_archive_desc": "Nettoyage pour le passage à niveau",
"c_archive_opt1_name": "catégorie",
"c_archive_opt1_desc": "Nom de la catégorie à nettoyer",
"c_archive1": "Liste des catégories soumis au nettoyage",
"c_archive2": "`L1`, `L2`, `L3`, `M1`, `M2`",
"c_archive3": "Impossible de trouver/nettoyer le salon :",
"c_archive4": "Liste des salons archivés de la catégorie",
"c_archive5": "vers",
"c_archive6": "Nettoyage",
"c_archive7": "Catégorie déjà nettoyée",
"c_prep_name": "Préparation",
"c_prep_desc": "Préparation des salons généraux pour la nouvelle année",
"c_prep_opt1_name": "année",
"c_prep_opt1_desc": "Nom de l'année à préparer",
"c_prep1": "Liste des catégories soumis à la préparation",
"c_prep2": "`L1`, `L2`, `L3`, `M1`, `M2`",
"c_prep3": "Impossible de trouver/nettoyer le salon :",
"c_prep4": "Listes des Salons préparés `",
"c_prep5": "créé",
"c_prep6": "Pas besoin de préparation",
"u_time_at": "à",
"c_reminder_name": "rappel",
"c_reminder_desc": "Commande relative aux rappels",
"c_reminder_sub1_name": "nouveau",
"c_reminder_sub1_desc": "Met en place un rappel",
"c_reminder_sub1_desc": "Mets en place un rappel",
"c_reminder_sub1_opt1_name": "temps",
"c_reminder_sub1_opt1_desc": "Temps désiré avant le rappel, accolez un @ pour activer la mention ou un p pour envoyer en DM",
"c_reminder_sub1_opt2_name": "message",
"c_reminder_sub1_opt2_desc": "Message du rappel",
"c_reminder_sub1_opt2_desc": "Message de rappel",
"c_reminder_sub2_name": "liste",
"c_reminder_sub2_desc": "Affiche la liste des rappels d'un utilisateur",
"c_reminder_sub2_opt1_name": "utilisateur",
@ -114,7 +91,7 @@
"c_queue_sub3_name": "retire",
"c_queue_sub3_desc": "Retire une chanson de la file d'attente",
"c_queue_sub3_opt1_name": "id",
"c_queue_sub3_opt1_desc": "ID de la chanson a retirer",
"c_queue_sub3_opt1_desc": "ID de la chanson à retirer",
"c_queue1": "File d'attente",
"c_queue2": "La liste est vide.",
"c_queue3": "Liste d'attente mélangée",
@ -140,9 +117,9 @@
"c_lyrics_sub1_name": "normal",
"c_lyrics_sub1_desc": "Recherche de paroles",
"c_lyrics_sub2_name": "romanized",
"c_lyrics_sub2_desc": "Recherche de paroles romanisée (ex: hangul -> latin)",
"c_lyrics_sub2_desc": "Recherche de paroles romanisées (ex: hangul → latin)",
"c_lyrics_sub3_name": "synced",
"c_lyrics_sub3_desc": "Recherche de paroles synchronisée (se met à jour avec la chanson en direct)",
"c_lyrics_sub3_desc": "Recherche de paroles synchronisées (se mettent à jour avec la chanson en direct)",
"c_lyrics_opt1_name": "chanson",
"c_lyrics_opt1_desc": "Chanson recherchée",
"c_lyrics1": "Le bot ne joue rien en ce moment et aucune chanson n'est renseignée.",
@ -161,7 +138,7 @@
"c_repeat_sub4_name": "autoplay",
"c_repeat_sub4_desc": "Active la lecture automatique",
"c_repeat1": "Le bot ne joue rien en ce moment.",
"c_repeat2": "Répétition désactivé",
"c_repeat2": "Répétition désactivée",
"c_repeat3": "Répétition de la file d'attente",
"c_repeat4": "Lecture automatique",
"c_repeat5": "Répétition de la chanson",