Skip to content

Commit

Permalink
fx: tower event add discord embed log
Browse files Browse the repository at this point in the history
  • Loading branch information
Kekwel committed Jan 7, 2025
1 parent 31e6762 commit 8ca0afa
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 4 deletions.
11 changes: 11 additions & 0 deletions slash_commands/subcommands/admin/tower/start.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const { GuildConfig } = require("../../../../models");
const { createLogs } = require("../../../../util/envoiMsg");
const { daysDiff } = require("../../../../util/util");

async function start(interaction) {
const guild = await GuildConfig.findOne({
Expand All @@ -22,6 +24,15 @@ async function start(interaction) {
}

await guild.save();

createLogs(
interaction.client,
interaction.guildId,
`🗼 TOWER : Saison ${guild.event.tower.currentSeason} commencée ✅`,
`Événement commecé par ${interaction.member} !`,
"",
"#DC8514",
);
return await interaction.reply({ content: "Événement commencé !" });
}

Expand Down
13 changes: 12 additions & 1 deletion slash_commands/subcommands/admin/tower/stop.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const { GuildConfig } = require("../../../../models");
const { GuildConfig, User } = require("../../../../models");
const { endSeasonForUser } = require("../../tower/valider-jeu");
const { createLogs } = require("../../../../util/envoiMsg");
const { daysDiff } = require("../../../../util/util");

async function stop(interaction) {
const guild = await GuildConfig.findOne({
Expand Down Expand Up @@ -30,6 +32,15 @@ async function stop(interaction) {
"event.tower.startDate": { $exists: true },
});

createLogs(
interaction.client,
interaction.guildId,
`🗼 TOWER : Saison ${season} arrêtée ❌`,
`Événement arrêté par ${interaction.member} !`,
`Durée de ${daysDiff(guild.event.tower.startDate, Date.now())} jours`,
"#DC8514",
);

// Sauvegarder les informations de la saison actuelle pour chaque utilisateur
const endDate = Date.now();
for (const user of users) {
Expand Down
29 changes: 26 additions & 3 deletions slash_commands/subcommands/tower/valider-jeu.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
const { createError, createEmbed } = require("../../../util/envoiMsg");
const {
createError,
createEmbed,
createLogs,
} = require("../../../util/envoiMsg");
const {
HIDDEN_BOSS,
BOSS,
Expand All @@ -18,6 +22,7 @@ const {
} = require("../../../data/event/tower/constants.json");
const { TowerBoss, GuildConfig, User } = require("../../../models");
const { SALON } = require("../../../util/constants");
const { daysDiff } = require("../../../util/util");

// Récupère une private joke aléatoirement
function getRandomPrivateJokes() {
Expand Down Expand Up @@ -218,6 +223,16 @@ const validerJeu = async (interaction, options) => {
userDb.event.tower.completedGames.push(appid); // Ajouter l'appId aux jeux déjà 100%
await userDb.save();

// logs
createLogs(
client,
guildId,
"🗼 TOWER : Nouveau jeu validé",
`${author} vient de valider **${gameName}** (${appid}) !`,
"",
"#DC8514",
);

// Si l'utilisateur n'est pas encore arrivé au boss
if (userDb.event.tower.etage <= MAX_ETAGE) {
// 1er étage franchi (1 jeu complété)
Expand Down Expand Up @@ -425,7 +440,7 @@ ${ASCII_PALIER}`,
message: `${author.user.tag} 100% ${gameName} (${appid}): tue boss caché, fin event, backup les infos ..`,
});
// si boss caché meurt, on arrête TOUT et on backup la saison
await endSeason(season, guild);
await endSeason(client, season, guild);

return interaction.reply({
embeds: [
Expand Down Expand Up @@ -514,11 +529,19 @@ ${ASCII_NOT_100}`,
});
};

async function endSeason(seasonNumber, guild) {
async function endSeason(client, seasonNumber, guild) {
logger.info({
prefix: "TOWER",
message: `fin de la saison ${seasonNumber} ..`,
});
createLogs(
client,
guild.guildId,
`🗼 TOWER : Saison ${seasonNumber} terminée`,
"Événement terminé !",
`en ${daysDiff(guild.event.tower.startDate, Date.now())} jours`,
"#DC8514",
);

// Edite Guild Config
guild.event.tower.started = false;
Expand Down

0 comments on commit 8ca0afa

Please sign in to comment.