From 3d54faba4494fa83d7a1c1b75d3a7cdf858ceaaa Mon Sep 17 00:00:00 2001 From: Louis Licari Date: Thu, 23 Dec 2021 10:09:53 +0100 Subject: [PATCH 01/20] Create Procfile --- Procfile | 1 + 1 file changed, 1 insertion(+) create mode 100644 Procfile diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..29e5b4e --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +worker: npm run start \ No newline at end of file From d36a9b64e7da4f5a913cb507f1faeb68b1fdd3fb Mon Sep 17 00:00:00 2001 From: RASTIQ <62338646+AQRRastiq@users.noreply.github.com> Date: Thu, 23 Dec 2021 10:17:06 +0100 Subject: [PATCH 02/20] Create heroku.yml --- .github/workflows/heroku.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/heroku.yml diff --git a/.github/workflows/heroku.yml b/.github/workflows/heroku.yml new file mode 100644 index 0000000..5edf3fb --- /dev/null +++ b/.github/workflows/heroku.yml @@ -0,0 +1,32 @@ +name: Heroku CI + +on: + workflow_dispatch + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [16.10.0] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v2 + - name: Heroku Action + # You may pin to the exact commit or the version. + # uses: CDNievas/heroku-action@c9cf9c85571e67583e44ec92c0d1113f66b0e838 + uses: CDNievas/heroku-action@v1.0 + with: + # Used for authentication. You can find it in your heroku homepage account settings + heroku_api_key: ${{ secrets.HEROKU_APIKEY }} + # Email from Heroku Account + heroku_email: ${{ secrets.HEROKU_EMAIL }} + # The appname to use for deploying/updating + heroku_app_name: 'astralbot-prod' + # Contents of the Procfile to save and deploy + procfile: 'Procfile' + # Path to an localized env file + env_file: '.env' From 682970603bbcada34947cee0e07cbb5c33a1eeaa Mon Sep 17 00:00:00 2001 From: RASTIQ <62338646+AQRRastiq@users.noreply.github.com> Date: Thu, 23 Dec 2021 10:19:33 +0100 Subject: [PATCH 03/20] Update heroku.yml --- .github/workflows/heroku.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/heroku.yml b/.github/workflows/heroku.yml index 5edf3fb..aed7afe 100644 --- a/.github/workflows/heroku.yml +++ b/.github/workflows/heroku.yml @@ -1,7 +1,8 @@ name: Heroku CI on: - workflow_dispatch + push: + branches: [prod] jobs: build: From f99f696cc6abe88bda6a94f4d61402280f7dc32d Mon Sep 17 00:00:00 2001 From: RASTIQ <62338646+AQRRastiq@users.noreply.github.com> Date: Thu, 23 Dec 2021 10:20:20 +0100 Subject: [PATCH 04/20] Update heroku.yml --- .github/workflows/heroku.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/heroku.yml b/.github/workflows/heroku.yml index aed7afe..5689bf2 100644 --- a/.github/workflows/heroku.yml +++ b/.github/workflows/heroku.yml @@ -29,5 +29,3 @@ jobs: heroku_app_name: 'astralbot-prod' # Contents of the Procfile to save and deploy procfile: 'Procfile' - # Path to an localized env file - env_file: '.env' From bde42842c013cfcc993230d90c52ad73f3fa36da Mon Sep 17 00:00:00 2001 From: RASTIQ <62338646+AQRRastiq@users.noreply.github.com> Date: Thu, 23 Dec 2021 10:23:42 +0100 Subject: [PATCH 05/20] Update heroku.yml --- .github/workflows/heroku.yml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/heroku.yml b/.github/workflows/heroku.yml index 5689bf2..01f3dab 100644 --- a/.github/workflows/heroku.yml +++ b/.github/workflows/heroku.yml @@ -16,16 +16,8 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Heroku Action - # You may pin to the exact commit or the version. - # uses: CDNievas/heroku-action@c9cf9c85571e67583e44ec92c0d1113f66b0e838 - uses: CDNievas/heroku-action@v1.0 + - uses: akhileshns/heroku-deploy@v3.12.12 # This is the action with: - # Used for authentication. You can find it in your heroku homepage account settings - heroku_api_key: ${{ secrets.HEROKU_APIKEY }} - # Email from Heroku Account - heroku_email: ${{ secrets.HEROKU_EMAIL }} - # The appname to use for deploying/updating - heroku_app_name: 'astralbot-prod' - # Contents of the Procfile to save and deploy - procfile: 'Procfile' + heroku_api_key: ${{secrets.HEROKU_APIKEY}} + heroku_app_name: "astralbot-prod" #Must be unique in Heroku + heroku_email: ${{secrets.HEROKU_EMAIL}} From efc7fa8bef717d8c11a7cc7522ea2cd7f23bdcd7 Mon Sep 17 00:00:00 2001 From: Louis Licari Date: Thu, 23 Dec 2021 11:07:12 +0100 Subject: [PATCH 06/20] updated config for production --- res/config.json | 40 +++++++++++++++++---------------- src/events/interactionCreate.js | 2 +- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/res/config.json b/res/config.json index 25f2920..ca8a7c4 100644 --- a/res/config.json +++ b/res/config.json @@ -1,35 +1,37 @@ { - "suggestionChannelId": "906186926208479273", - "verifChannelId": "906141002505535539", - "rolePannelChannelId": "906274132679860244", - "ticketChannelId": "911555243127472148", - "mainGuildId": "906119156334743582", - "welcomeChannelId": "906925355061895168", - "countingChannelId": "906842382048329778", - "ticketCategoryId": "911956726192963635", - "subCounterChannelId": "916452122017558588", - "viewsCounterChannelId": "916452429057388544", + "suggestionChannelId": "884520586527797249", + "verifChannelId": "923510741666000896", + "rolePannelChannelId": "853324293391122442", + "ticketChannelId": "900415812890943488", + "mainGuildId": "852223829840625744", + "welcomeChannelId": "903577017969180672", + "countingChannelId": "923515883173838849", + "ticketCategoryId": "923515285259038760", + "subCounterChannelId": "923509342454575134", + "viewsCounterChannelId": "923509400646320148", "astralYoutubeChannelId": "UCCJmvsUsf0Pnst0IzbARSBg", "logs": { - "messagesChannelId": "909860870216093698", - "modChannelId": "909860895918809129", - "vocalChannelId": "909860912389845012", - "joinsChannelId": "909860923123044412", - "ticketsChannelId": "909860958753669201", - "botChannelId": "909860969398829116" + "messagesChannelId": "852937143675519008", + "modChannelId": "852937143675519008", + "vocalChannelId": "852937143675519008", + "joinsChannelId": "852937143675519008", + "ticketsChannelId": "852937143675519008", + "botChannelId": "852937143675519008" }, "mods": { "roles": [ - "914460676167200778" + "853176148853653514", + "853334305149550623" ], "user": [] }, "admins": { "roles": [ - "906124337415864360" + "867865612189696053", + "852224358381518850" ], "user": [] }, "geniusApiKey": "RsPVeuHKQoBZL8mwINo5Rh0FX1ixwmTM4KjeF4PlWeEzmKDUHvGEOPv6vjjpiSK8", - "version": "1.0.0-beta1" + "version": "1.0.0" } \ No newline at end of file diff --git a/src/events/interactionCreate.js b/src/events/interactionCreate.js index 312a274..3a323f6 100644 --- a/src/events/interactionCreate.js +++ b/src/events/interactionCreate.js @@ -200,7 +200,7 @@ module.exports = { }); } } else if (interaction.customId === "selectsetup_validation") { - await interaction.member.roles.add("906149050510876674"); + await interaction.member.roles.add("852939971820388357"); await interaction.deferUpdate(); } else if ( interaction.customId === "upvote" || From 115722c6dd4a9956738831b857a533d56fbac058 Mon Sep 17 00:00:00 2001 From: Louis Licari Date: Thu, 23 Dec 2021 11:32:50 +0100 Subject: [PATCH 07/20] fixed heroku node version --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 753ef75..7e5fb4f 100644 --- a/package.json +++ b/package.json @@ -46,5 +46,8 @@ "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", "prettier": "^2.5.1" + }, + "engines": { + "node": "16.10.0" } } From 9c2ad9995a84248de64071953665df4164e83765 Mon Sep 17 00:00:00 2001 From: Louis Licari Date: Thu, 23 Dec 2021 11:50:49 +0100 Subject: [PATCH 08/20] Update config.json --- res/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/config.json b/res/config.json index ca8a7c4..3412fea 100644 --- a/res/config.json +++ b/res/config.json @@ -5,7 +5,7 @@ "ticketChannelId": "900415812890943488", "mainGuildId": "852223829840625744", "welcomeChannelId": "903577017969180672", - "countingChannelId": "923515883173838849", + "countingChannelId": "917051294164848671", "ticketCategoryId": "923515285259038760", "subCounterChannelId": "923509342454575134", "viewsCounterChannelId": "923509400646320148", From cba9c385eeaf994b9644040103f884cf3c54fb0e Mon Sep 17 00:00:00 2001 From: Louis Licari Date: Thu, 23 Dec 2021 11:58:15 +0100 Subject: [PATCH 09/20] make so @everyone cannot see the tickets --- src/functions/createTicket.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/functions/createTicket.js b/src/functions/createTicket.js index 0660d55..358c194 100644 --- a/src/functions/createTicket.js +++ b/src/functions/createTicket.js @@ -24,6 +24,14 @@ module.exports = async function (interaction) { Permissions.FLAGS.READ_MESSAGE_HISTORY, ], }, + { + id: interaction.guild.roles.everyone, + deny: [ + Permissions.FLAGS.SEND_MESSAGES, + Permissions.FLAGS.VIEW_CHANNEL, + Permissions.FLAGS.READ_MESSAGE_HISTORY, + ], + } ], } ); From 1951b0014b6f6f6651748952e96f159793b99965 Mon Sep 17 00:00:00 2001 From: Louis Licari Date: Thu, 23 Dec 2021 12:09:49 +0100 Subject: [PATCH 10/20] Update config.json --- res/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/config.json b/res/config.json index 3412fea..16c5d32 100644 --- a/res/config.json +++ b/res/config.json @@ -5,7 +5,7 @@ "ticketChannelId": "900415812890943488", "mainGuildId": "852223829840625744", "welcomeChannelId": "903577017969180672", - "countingChannelId": "917051294164848671", + "countingChannelId": "923531360780558336", "ticketCategoryId": "923515285259038760", "subCounterChannelId": "923509342454575134", "viewsCounterChannelId": "923509400646320148", From ef1d038d7cfe68990af13e6e671f29923cb91b65 Mon Sep 17 00:00:00 2001 From: Louis Licari Date: Thu, 23 Dec 2021 12:32:07 +0100 Subject: [PATCH 11/20] Update config.json --- res/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/config.json b/res/config.json index 16c5d32..995a19a 100644 --- a/res/config.json +++ b/res/config.json @@ -5,7 +5,7 @@ "ticketChannelId": "900415812890943488", "mainGuildId": "852223829840625744", "welcomeChannelId": "903577017969180672", - "countingChannelId": "923531360780558336", + "countingChannelId": "923532929664167946", "ticketCategoryId": "923515285259038760", "subCounterChannelId": "923509342454575134", "viewsCounterChannelId": "923509400646320148", From 732176d815e93c313d55c249957c7ced5cb8307d Mon Sep 17 00:00:00 2001 From: Louis Licari Date: Thu, 23 Dec 2021 13:35:52 +0100 Subject: [PATCH 12/20] Update config.json --- res/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/config.json b/res/config.json index 995a19a..1d0aef7 100644 --- a/res/config.json +++ b/res/config.json @@ -1,5 +1,5 @@ { - "suggestionChannelId": "884520586527797249", + "suggestionChannelId": "923554380798623804", "verifChannelId": "923510741666000896", "rolePannelChannelId": "853324293391122442", "ticketChannelId": "900415812890943488", From dbdb458ab8737a59f70a9b77698e07695c6b90ee Mon Sep 17 00:00:00 2001 From: Louis Licari Date: Thu, 23 Dec 2021 15:09:57 +0100 Subject: [PATCH 13/20] Update index.js --- src/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 3d1f83f..c060a2e 100644 --- a/src/index.js +++ b/src/index.js @@ -19,8 +19,7 @@ const client = new Client({ Intents.FLAGS.GUILD_BANS, Intents.FLAGS.DIRECT_MESSAGES, Intents.FLAGS.GUILD_VOICE_STATES, - ], - partials: ["CHANNEL", "MESSAGE"], + ] }); client.config = config; client.musicconfig = musicconfig; From 5ab3fe780562ae3277236bde7b23302f3cea2432 Mon Sep 17 00:00:00 2001 From: Louis Licari Date: Thu, 23 Dec 2021 19:38:57 +0100 Subject: [PATCH 14/20] Create voiceStateUpdate.js --- src/events/voiceStateUpdate.js | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/events/voiceStateUpdate.js diff --git a/src/events/voiceStateUpdate.js b/src/events/voiceStateUpdate.js new file mode 100644 index 0000000..3c1a304 --- /dev/null +++ b/src/events/voiceStateUpdate.js @@ -0,0 +1,60 @@ +const {MessageEmbed} = require("discord.js"); +module.exports = { + name: "voiceStateUpdate", + async execute(client, old, new_) { + if (new_.member.user.bot) return + + const logsChannel = await ( + await client.guilds.fetch(client.config.mainGuildId)).channels.fetch(client.config.logs.vocalChannelId) + + if (!old.channel && new_.channel) { + await logsChannel.send({ + embeds: [ + new MessageEmbed({ + author: { + name: "Un membre a rejoint un salon vocal" + }, + fields: [ + { + name: "Utilisateur :", + value: `${new_.member.user.tag} (${new_.member.user.id})`, + inline: true + }, + { + name: "Salon :", + value: `<#${new_.channelId}> (${new_.channelId})`, + inline: true + } + ], + timestamp: Date.now(), + color: "#0099ff" + }) + ] + }) + } else if (old.channel && !new_.channel) { + await logsChannel.send({ + embeds: [ + new MessageEmbed({ + author: { + name: "Un membre a quitté un salon vocal" + }, + fields: [ + { + name: "Utilisateur :", + value: `${new_.member.user.tag} (${new_.member.user.id})`, + inline: true + }, + { + name: "Salon :", + value: `<#${old.channelId}> (${old.channelId})`, + inline: true + } + ], + timestamp: Date.now(), + color: "#ff1500" + }) + ] + }) + } + } +} \ No newline at end of file From d1a760ce5704188e9f5954594096b3885fe56da8 Mon Sep 17 00:00:00 2001 From: Louis Licari Date: Thu, 23 Dec 2021 19:50:08 +0100 Subject: [PATCH 15/20] Update music-config.js --- res/music-config.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/res/music-config.js b/res/music-config.js index e2ca8cd..19680ea 100644 --- a/res/music-config.js +++ b/res/music-config.js @@ -1,6 +1,8 @@ module.exports = { opt: { maxVol: 100, + leaveOnEmpty: true, + leaveOnEmptyCooldown: 1000, loopMessage: false, discordPlayer: { ytdlOptions: { From 8dcfdef15c0b07f0e5703bd21a8c472e1db2e40a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o-21?= Date: Sun, 26 Dec 2021 22:00:06 +0100 Subject: [PATCH 16/20] change version to 1.0.1 --- package.json | 2 +- res/config.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 44a13fa..6cd62fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "astralbot", - "version": "1.0.0", + "version": "1.0.1", "description": "", "main": "src/index.js", "scripts": { diff --git a/res/config.json b/res/config.json index 1d0aef7..aab0b27 100644 --- a/res/config.json +++ b/res/config.json @@ -33,5 +33,5 @@ "user": [] }, "geniusApiKey": "RsPVeuHKQoBZL8mwINo5Rh0FX1ixwmTM4KjeF4PlWeEzmKDUHvGEOPv6vjjpiSK8", - "version": "1.0.0" + "version": "1.0.1" } \ No newline at end of file From ce71cebe8e07014a7e2a6e2155c13c15ab20888c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o-21?= Date: Sun, 26 Dec 2021 21:41:00 +0100 Subject: [PATCH 17/20] add the possibility to use math expressions in counting --- package.json | 1 + src/events/messageCreate.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6cd62fd..fff1085 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "googleapis": "^92.0.0", "hypixel": "^1.0.3", "jimp": "^0.3.11", + "math-expression-evaluator": "^1.3.8", "mongodb": "^4.1.4", "ms": "^2.1.3", "node-cron": "^3.0.0", diff --git a/src/events/messageCreate.js b/src/events/messageCreate.js index 1bc3b88..92fecd2 100644 --- a/src/events/messageCreate.js +++ b/src/events/messageCreate.js @@ -1,4 +1,5 @@ const sendSuggestion = require("../functions/sendSuggestion"); +const mexp = require("math-expression-evaluator"); module.exports = { name: "messageCreate", @@ -15,12 +16,17 @@ module.exports = { `${message.guild.id}`, "currentNumber" ); - if (isNaN(message.content)) return message.delete(); + if (!message.content) return message.delete(); const authorid = await client.countdb.get( `${message.guild.id}`, "author" ); - const proposedNumber = parseInt(message.content); + let proposedNumber; + try { + proposedNumber = mexp.eval(message.content); + } catch (e) { + return message.delete(); + } if (message.author.id === authorid) return message.delete(); if (proposedNumber - 1 !== currentNumber) return message.delete(); await client.countdb.set( From 4a539f8c96ab8a0608627f41caa40908ed3aac87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o-21?= Date: Sun, 26 Dec 2021 21:47:54 +0100 Subject: [PATCH 18/20] eslint and prettier fixes --- src/commands/avatar.js | 26 +++-- src/commands/hypixel.js | 86 +++++++++----- src/commands/mcskin.js | 43 ++++--- src/events/messageDeleteBulk.js | 12 +- src/functions/createTicket.js | 63 +++++----- src/functions/sendHypixelBedwarsImage.js | 127 ++++++++++++-------- src/functions/sendHypixelGlobalImage.js | 127 +++++++++++--------- src/functions/sendHypixelSkywarsImage.js | 142 ++++++++++++++--------- src/functions/timestampToDate.js | 10 +- src/index.js | 12 +- 10 files changed, 386 insertions(+), 262 deletions(-) diff --git a/src/commands/avatar.js b/src/commands/avatar.js index e7522dd..1adb348 100644 --- a/src/commands/avatar.js +++ b/src/commands/avatar.js @@ -1,12 +1,20 @@ -const { SlashCommandBuilder } = require('@discordjs/builders'); +const { SlashCommandBuilder } = require("@discordjs/builders"); module.exports = { - data: new SlashCommandBuilder() - .setName('avatar') - .setDescription('Avoir l\'avatar de quelqu\'un ou de soi-même.') - .addUserOption(option => option.setName('utilisateur').setDescription('Utilisateur dont l\'avatar doit être montré')), - async execute(client, interaction) { - const user = interaction.options.getUser('utilisateur') || interaction.user; - return interaction.reply(`Voici l'[avatar](${user.displayAvatarURL({dynamic: true})}) de ${user}.`); - }, + data: new SlashCommandBuilder() + .setName("avatar") + .setDescription("Avoir l'avatar de quelqu'un ou de soi-même.") + .addUserOption(option => + option + .setName("utilisateur") + .setDescription("Utilisateur dont l'avatar doit être montré") + ), + async execute(client, interaction) { + const user = interaction.options.getUser("utilisateur") || interaction.user; + return await interaction.reply( + `Voici l'[avatar](${user.displayAvatarURL({ + dynamic: true, + })}) de ${user}.` + ); + }, }; diff --git a/src/commands/hypixel.js b/src/commands/hypixel.js index fdaf147..a7d5b98 100644 --- a/src/commands/hypixel.js +++ b/src/commands/hypixel.js @@ -1,39 +1,61 @@ -const { SlashCommandBuilder } = require('@discordjs/builders'); -const Hypixel = require('hypixel'); +const { SlashCommandBuilder } = require("@discordjs/builders"); +const Hypixel = require("hypixel"); const hypixelclient = new Hypixel({ key: process.env.HYPIXEL_API_KEY }); -const sendHypixelGlobalImage = require('../functions/sendHypixelGlobalImage'); -const sendHypixelBedwarsImage = require('../functions/sendHypixelBedwarsImage'); -const sendHypixelSkywarsImage = require('../functions/sendHypixelSkywarsImage'); +const sendHypixelGlobalImage = require("../functions/sendHypixelGlobalImage"); +const sendHypixelBedwarsImage = require("../functions/sendHypixelBedwarsImage"); +const sendHypixelSkywarsImage = require("../functions/sendHypixelSkywarsImage"); module.exports = { - data: new SlashCommandBuilder() - .setName('hypixel') - .setDescription('Avoir des informations de l\'API Hypixel.') - .addSubcommand(command => command.setName('stats').setDescription('Avoir les stats de quelqu\'un dans un jeu').addStringOption(option => option.setName('utilisateur').setDescription('L\'utilisateur dont les stats sont recherchées').setRequired(true)).addStringOption(option => option.setName('jeu').setDescription('Le jeu sur lequel doivent être les stats (laisser vide pour les stats globales)').addChoice('Bedwars', 'bedwars').addChoice('Skywars', 'skywars'))), - async execute(client, interaction) { - if (interaction.options.getSubcommand() === "stats") { + data: new SlashCommandBuilder() + .setName("hypixel") + .setDescription("Avoir des informations de l'API Hypixel.") + .addSubcommand(command => + command + .setName("stats") + .setDescription("Avoir les stats de quelqu'un dans un jeu") + .addStringOption(option => + option + .setName("utilisateur") + .setDescription("L'utilisateur dont les stats sont recherchées") + .setRequired(true) + ) + .addStringOption(option => + option + .setName("jeu") + .setDescription( + "Le jeu sur lequel doivent être les stats (laisser vide pour les stats globales)" + ) + .addChoice("Bedwars", "bedwars") + .addChoice("Skywars", "skywars") + ) + ), + execute(client, interaction) { + if (interaction.options.getSubcommand() === "stats") { + try { + const user = interaction.options.getString("utilisateur"); - try { - user = interaction.options.getString('utilisateur') - - hypixelclient.getPlayerByUsername(user, (err, player) => { - if (err) { - return interaction.reply({content: "Une erreur est survenue. Veuillez vérifier que vous avez bien entré un nom d'utilisateur et non un UUID. Si vous rencontrez encore des problèmes, attendez une minute et réessayez.", ephemeral: true}); - } + hypixelclient.getPlayerByUsername(user, async (err, player) => { + if (err) { + return await interaction.reply({ + content: + "Une erreur est survenue. Veuillez vérifier que vous avez bien entré un nom d'utilisateur et non un UUID. Si vous rencontrez encore des problèmes, attendez une minute et réessayez.", + ephemeral: true, + }); + } - interaction.reply({content: "Envoi du panel...", ephemeral: true}); + interaction.reply({ content: "Envoi du panel...", ephemeral: true }); - if (interaction.options.getString('jeu') === null) { - sendHypixelGlobalImage(interaction, player, user) - }else if (interaction.options.getString('jeu') === "bedwars") { - sendHypixelBedwarsImage(interaction, player, user) - }else if (interaction.options.getString('jeu') === "skywars") { - sendHypixelSkywarsImage(interaction, player, user) - } - }); - }catch (e){ - console.error(e) - } - } - }, + if (interaction.options.getString("jeu") === null) { + await sendHypixelGlobalImage(interaction, player, user); + } else if (interaction.options.getString("jeu") === "bedwars") { + await sendHypixelBedwarsImage(interaction, player, user); + } else if (interaction.options.getString("jeu") === "skywars") { + await sendHypixelSkywarsImage(interaction, player, user); + } + }); + } catch (e) { + client.logger.error(`hypixel command : ${e}`); + } + } + }, }; diff --git a/src/commands/mcskin.js b/src/commands/mcskin.js index 73fb692..aa954be 100644 --- a/src/commands/mcskin.js +++ b/src/commands/mcskin.js @@ -1,18 +1,33 @@ -const { SlashCommandBuilder } = require('@discordjs/builders'); -const fetch = require('node-fetch'); +const { SlashCommandBuilder } = require("@discordjs/builders"); +const fetch = require("node-fetch"); module.exports = { - data: new SlashCommandBuilder() - .setName('mcskin') - .setDescription('Avoir le skin Minecraft de quelqu\'un.') - .addStringOption(option => option.setName('utilisateur').setDescription('Nom d\'utilisateur dont l\'avatar doit être montré (Pas l\'UUID hein)').setRequired(true)), - async execute(client, interaction) { - const user = interaction.options.getString('utilisateur'); - const data = await fetch(`https://api.mojang.com/users/profiles/minecraft/${user}`) - .then(data => data.json()) - if (data.error) return interaction.reply({content: "Une erreur est survenue. Veuillez vérifier que vous avez bien entré un nom d'utilisateur et non un UUID.", ephemeral: true}); - const uuid = data.id; + data: new SlashCommandBuilder() + .setName("mcskin") + .setDescription("Avoir le skin Minecraft de quelqu'un.") + .addStringOption(option => + option + .setName("utilisateur") + .setDescription( + "Nom d'utilisateur dont l'avatar doit être montré (Pas l'UUID hein)" + ) + .setRequired(true) + ), + async execute(client, interaction) { + const user = interaction.options.getString("utilisateur"); + const data = await fetch( + `https://api.mojang.com/users/profiles/minecraft/${user}` + ).then(data => data.json()); + if (data.error) + return interaction.reply({ + content: + "Une erreur est survenue. Veuillez vérifier que vous avez bien entré un nom d'utilisateur et non un UUID.", + ephemeral: true, + }); + const uuid = data.id; - return interaction.reply(`Voici le [skin](https://visage.surgeplay.com/full/512/${uuid}) de ${user}. Si vous voulez mettre son skin, le lien est [ici](https://crafatar.com/skins/${uuid})`); - }, + return interaction.reply( + `Voici le [skin](https://visage.surgeplay.com/full/512/${uuid}) de ${user}. Si vous voulez mettre son skin, le lien est [ici](https://crafatar.com/skins/${uuid})` + ); + }, }; diff --git a/src/events/messageDeleteBulk.js b/src/events/messageDeleteBulk.js index cd1ab59..5b8bd69 100644 --- a/src/events/messageDeleteBulk.js +++ b/src/events/messageDeleteBulk.js @@ -6,9 +6,11 @@ module.exports = { .setAuthor(`${messages.size} messages supprimés en masse`) .addField("Salon :", `<#${messages.first().channel.id}>`) .setColor("#0099ff") - .setTimestamp(Date.now()) + .setTimestamp(Date.now()); - const channel = await client.channels.fetch(client.config.logs.modChannelId) - await channel.send({ embeds: [embed] }) - } -} \ No newline at end of file + const channel = await client.channels.fetch( + client.config.logs.modChannelId + ); + await channel.send({ embeds: [embed] }); + }, +}; diff --git a/src/functions/createTicket.js b/src/functions/createTicket.js index 358c194..78a4e30 100644 --- a/src/functions/createTicket.js +++ b/src/functions/createTicket.js @@ -68,34 +68,37 @@ module.exports = async function (interaction) { ], }; - const message = await ticketChannel.send(messageData) - await message.pin() - const msg = await ticketChannel.send({ content: `<@${interaction.user.id}>`}) - await msg.delete() + const message = await ticketChannel.send(messageData); + await message.pin(); + const msg = await ticketChannel.send({ + content: `<@${interaction.user.id}>`, + }); + await msg.delete(); - const logsChannel = await ( - await client.guilds.fetch(client.config.mainGuildId)).channels.fetch(client.config.logs.ticketsChannelId) - await logsChannel.send({ - embeds: [ - new MessageEmbed({ - author: { - name: "Nouveau ticket créé" - }, - fields: [ - { - name: "Utilisateur :", - value: `${interaction.user.tag} (${interaction.user.id})`, - inline: true - }, - { - name: "Ticket :", - value: `<#${ticketChannel.id}> (${ticketChannel.name})`, - inline: true - } - ], - timestamp: Date.now(), - color: "#0099ff" - }) - ] - }) -} + const logsChannel = await ( + await client.guilds.fetch(client.config.mainGuildId) + ).channels.fetch(client.config.logs.ticketsChannelId); + await logsChannel.send({ + embeds: [ + new MessageEmbed({ + author: { + name: "Nouveau ticket créé", + }, + fields: [ + { + name: "Utilisateur :", + value: `${interaction.user.tag} (${interaction.user.id})`, + inline: true, + }, + { + name: "Ticket :", + value: `<#${ticketChannel.id}> (${ticketChannel.name})`, + inline: true, + }, + ], + timestamp: Date.now(), + color: "#0099ff", + }), + ], + }); +}; diff --git a/src/functions/sendHypixelBedwarsImage.js b/src/functions/sendHypixelBedwarsImage.js index 4aa8179..fea460d 100644 --- a/src/functions/sendHypixelBedwarsImage.js +++ b/src/functions/sendHypixelBedwarsImage.js @@ -1,51 +1,76 @@ -const Jimp = require('jimp'); -const path = require('path'); -const {MessageAttachment, MessageEmbed} = require("discord.js"); -const timestampToDate = require('../functions/timestampToDate'); -const fetch = require('node-fetch'); - -module.exports = sendWelcomeImage = async function(interaction, player, username) { - - try { - const uuid = await fetch(`https://api.mojang.com/users/profiles/minecraft/${username}`) - .then(data => data.json()) - .then(player => player.id); - const canvas = new Jimp(500, 150); - const avatar = await Jimp.read(`https://visage.surgeplay.com/bust/512/${uuid}`); - - const Quantify_50_white = await Jimp.loadFont(path.join(__dirname, '../../res/fonts/Quantify_50_white.fnt')); - const Quantify_20_white = await Jimp.loadFont(path.join(__dirname, '../../res/fonts/Quantify_20_white.fnt')); - const mask = await Jimp.read('https://raw.githubusercontent.com/CoderDixs/DraftBot/master/images/avatarMask.png'); - - avatar.resize(136, Jimp.AUTO); - mask.resize(136, Jimp.AUTO); - avatar.mask(mask, 0, 0); - - canvas.blit(avatar, 5, 5); - - if (player.achievements.bedwars_level) { - canvas.print(Quantify_50_white, 158, 20, `Niveau ${player.achievements.bedwars_level}`); - } - if (player.stats.Bedwars.kills_bedwars) { - canvas.print(Quantify_20_white, 158, 77, `Total de ${player.stats.Bedwars.kills_bedwars} kills`); - } - if (player.stats.Bedwars.deaths_bedwars) { - canvas.print(Quantify_20_white, 158, 105, `Total de ${player.stats.Bedwars.deaths_bedwars} morts`); - } - - const buffer = await canvas.getBufferAsync(Jimp.MIME_PNG); - const attachment = new MessageAttachment(buffer, 'joinimg.png'); - - const embed = new MessageEmbed() - .setTitle(`Stats de ${player.displayname}`) - .setDescription(`Voici les stats Hypixel de ${player.displayname} en Bedwars`) - .setImage("attachment://joinimg.png") - .setColor("#0099ff") - .setFooter("AstralHypixel") - - await interaction.followUp({ embeds: [embed], files: [attachment]}) - } catch (error) { - return console.log('HypixelGlobalImage => ',error); - } - -} \ No newline at end of file +const Jimp = require("jimp"); +const path = require("path"); +const { MessageAttachment, MessageEmbed } = require("discord.js"); +const fetch = require("node-fetch"); + +module.exports = async function (interaction, player, username) { + try { + const uuid = await fetch( + `https://api.mojang.com/users/profiles/minecraft/${username}` + ) + .then(data => data.json()) + .then(player => player.id); + const canvas = new Jimp(500, 150); + const avatar = await Jimp.read( + `https://visage.surgeplay.com/bust/512/${uuid}` + ); + + const Quantify_50_white = await Jimp.loadFont( + path.join(__dirname, "../../res/fonts/Quantify_50_white.fnt") + ); + const Quantify_20_white = await Jimp.loadFont( + path.join(__dirname, "../../res/fonts/Quantify_20_white.fnt") + ); + const mask = await Jimp.read( + "https://raw.githubusercontent.com/CoderDixs/DraftBot/master/images/avatarMask.png" + ); + + avatar.resize(136, Jimp.AUTO); + mask.resize(136, Jimp.AUTO); + avatar.mask(mask, 0, 0); + + canvas.blit(avatar, 5, 5); + + if (player.achievements.bedwars_level) { + canvas.print( + Quantify_50_white, + 158, + 20, + `Niveau ${player.achievements.bedwars_level}` + ); + } + if (player.stats.Bedwars.kills_bedwars) { + canvas.print( + Quantify_20_white, + 158, + 77, + `Total de ${player.stats.Bedwars.kills_bedwars} kills` + ); + } + if (player.stats.Bedwars.deaths_bedwars) { + canvas.print( + Quantify_20_white, + 158, + 105, + `Total de ${player.stats.Bedwars.deaths_bedwars} morts` + ); + } + + const buffer = await canvas.getBufferAsync(Jimp.MIME_PNG); + const attachment = new MessageAttachment(buffer, "joinimg.png"); + + const embed = new MessageEmbed() + .setTitle(`Stats de ${player.displayname}`) + .setDescription( + `Voici les stats Hypixel de ${player.displayname} en Bedwars` + ) + .setImage("attachment://joinimg.png") + .setColor("#0099ff") + .setFooter("AstralHypixel"); + + await interaction.followUp({ embeds: [embed], files: [attachment] }); + } catch (error) { + // eslint-disable-next-line no-console + return console.log("HypixelGlobalImage => ", error); + } +}; diff --git a/src/functions/sendHypixelGlobalImage.js b/src/functions/sendHypixelGlobalImage.js index 89f2630..64379c9 100644 --- a/src/functions/sendHypixelGlobalImage.js +++ b/src/functions/sendHypixelGlobalImage.js @@ -1,69 +1,88 @@ -const Jimp = require('jimp'); -const path = require('path'); -const {MessageAttachment, MessageEmbed} = require("discord.js"); -const timestampToDate = require('../functions/timestampToDate'); -const fetch = require('node-fetch'); +const Jimp = require("jimp"); +const path = require("path"); +const { MessageAttachment, MessageEmbed } = require("discord.js"); +const timestampToDate = require("../functions/timestampToDate"); +const fetch = require("node-fetch"); -module.exports = sendWelcomeImage = async function(interaction, player, username) { +module.exports = async function (interaction, player, username) { + try { + const uuid = await fetch( + `https://api.mojang.com/users/profiles/minecraft/${username}` + ) + .then(data => data.json()) + .then(player => player.id); + const canvas = new Jimp(500, 150); + const avatar = await Jimp.read( + `https://visage.surgeplay.com/bust/512/${uuid}` + ); - try { - const uuid = await fetch(`https://api.mojang.com/users/profiles/minecraft/${username}`) - .then(data => data.json()) - .then(player => player.id); - const canvas = new Jimp(500, 150); - const avatar = await Jimp.read(`https://visage.surgeplay.com/bust/512/${uuid}`); - - const Quantify_50_white = await Jimp.loadFont(path.join(__dirname, '../../res/fonts/Quantify_50_white.fnt')); - const Quantify_20_white = await Jimp.loadFont(path.join(__dirname, '../../res/fonts/Quantify_20_white.fnt')); - const mask = await Jimp.read('https://raw.githubusercontent.com/CoderDixs/DraftBot/master/images/avatarMask.png'); - - avatar.resize(136, Jimp.AUTO); - mask.resize(136, Jimp.AUTO); - avatar.mask(mask, 0, 0); - - canvas.blit(avatar, 5, 5); - - canvas.print(Quantify_50_white, 158, 20, await getRank(player)); - canvas.print(Quantify_20_white, 158, 70, 'Première connexion :'); - canvas.print(Quantify_20_white, 158, 87, await timestampToDate(player.firstLogin)); - if (player.lastLogin) { - canvas.print(Quantify_20_white, 158, 105, 'Dernière connexion :'); - canvas.print(Quantify_20_white, 158, 122, await timestampToDate(player.lastLogin)); - } - - const buffer = await canvas.getBufferAsync(Jimp.MIME_PNG); - const attachment = new MessageAttachment(buffer, 'joinimg.png'); - - const embed = new MessageEmbed() - .setTitle(`Stats de ${player.displayname}`) - .setDescription(`Voici les stats Hypixel de ${player.displayname}`) - .setImage("attachment://joinimg.png") - .setColor("#0099ff") - .setFooter("AstralHypixel") - - await interaction.followUp({ embeds: [embed], files: [attachment]}) - } catch (error) { - return console.log('HypixelGlobalImage => ',error); - } + const Quantify_50_white = await Jimp.loadFont( + path.join(__dirname, "../../res/fonts/Quantify_50_white.fnt") + ); + const Quantify_20_white = await Jimp.loadFont( + path.join(__dirname, "../../res/fonts/Quantify_20_white.fnt") + ); + const mask = await Jimp.read( + "https://raw.githubusercontent.com/CoderDixs/DraftBot/master/images/avatarMask.png" + ); -} + avatar.resize(136, Jimp.AUTO); + mask.resize(136, Jimp.AUTO); + avatar.mask(mask, 0, 0); + + canvas.blit(avatar, 5, 5); + + canvas.print(Quantify_50_white, 158, 20, await getRank(player)); + canvas.print(Quantify_20_white, 158, 70, "Première connexion :"); + canvas.print( + Quantify_20_white, + 158, + 87, + await timestampToDate(player.firstLogin) + ); + if (player.lastLogin) { + canvas.print(Quantify_20_white, 158, 105, "Dernière connexion :"); + canvas.print( + Quantify_20_white, + 158, + 122, + await timestampToDate(player.lastLogin) + ); + } + + const buffer = await canvas.getBufferAsync(Jimp.MIME_PNG); + const attachment = new MessageAttachment(buffer, "joinimg.png"); -async function getRank(player) { + const embed = new MessageEmbed() + .setTitle(`Stats de ${player.displayname}`) + .setDescription(`Voici les stats Hypixel de ${player.displayname}`) + .setImage("attachment://joinimg.png") + .setColor("#0099ff") + .setFooter("AstralHypixel"); + + await interaction.followUp({ embeds: [embed], files: [attachment] }); + } catch (error) { + // eslint-disable-next-line no-console + return console.log("HypixelGlobalImage => ", error); + } +}; + +function getRank(player) { if (player.rank === "YOUTUBER") { - return "Grade: YT" + return "Grade: YT"; } - if (!player.newPackageRank) return "Pas de grade" + if (!player.newPackageRank) return "Pas de grade"; - if (player.newPackageRank === "VIP_PLUS") return "Grade: VIP+" + if (player.newPackageRank === "VIP_PLUS") return "Grade: VIP+"; if (player.newPackageRank === "MVP_PLUS") { if (player.monthlyPackageRank === "SUPERSTAR") { - return "Grade: MVP++" - }else{ - return "Grade: MVP+" + return "Grade: MVP++"; + } else { + return "Grade: MVP+"; } } return player.newPackageRank; -} \ No newline at end of file +} diff --git a/src/functions/sendHypixelSkywarsImage.js b/src/functions/sendHypixelSkywarsImage.js index a217ad9..c7b5b45 100644 --- a/src/functions/sendHypixelSkywarsImage.js +++ b/src/functions/sendHypixelSkywarsImage.js @@ -1,64 +1,96 @@ -const Jimp = require('jimp'); -const path = require('path'); -const {MessageAttachment, MessageEmbed} = require("discord.js"); -const timestampToDate = require('../functions/timestampToDate'); -const fetch = require('node-fetch'); +const Jimp = require("jimp"); +const path = require("path"); +const { MessageAttachment, MessageEmbed } = require("discord.js"); +const fetch = require("node-fetch"); -module.exports = sendWelcomeImage = async function(interaction, player, username) { +module.exports = async function (interaction, player, username) { + try { + const uuid = await fetch( + `https://api.mojang.com/users/profiles/minecraft/${username}` + ) + .then(data => data.json()) + .then(player => player.id); + const canvas = new Jimp(500, 150); + const avatar = await Jimp.read( + `https://visage.surgeplay.com/bust/512/${uuid}` + ); - try { - const uuid = await fetch(`https://api.mojang.com/users/profiles/minecraft/${username}`) - .then(data => data.json()) - .then(player => player.id); - const canvas = new Jimp(500, 150); - const avatar = await Jimp.read(`https://visage.surgeplay.com/bust/512/${uuid}`); - - const Quantify_50_white = await Jimp.loadFont(path.join(__dirname, '../../res/fonts/Quantify_50_white.fnt')); - const Quantify_20_white = await Jimp.loadFont(path.join(__dirname, '../../res/fonts/Quantify_20_white.fnt')); - const mask = await Jimp.read('https://raw.githubusercontent.com/CoderDixs/DraftBot/master/images/avatarMask.png'); - - avatar.resize(136, Jimp.AUTO); - mask.resize(136, Jimp.AUTO); - avatar.mask(mask, 0, 0); - - canvas.blit(avatar, 5, 5); - - if (player.stats.SkyWars.skywars_experience) { - canvas.print(Quantify_50_white, 158, 20, `Niveau ${await Math.trunc(await xpToLevel(player.stats.SkyWars.skywars_experience))}`); - } - if (player.achievements.skywars_wins_solo) { - canvas.print(Quantify_20_white, 158, 77, `Total de ${player.achievements.skywars_wins_solo + player.achievements.skywars_wins_team} wins`); - } - if (player.stats.SkyWars.losses_solo) { - canvas.print(Quantify_20_white, 158, 105, `Total de ${player.stats.SkyWars.losses_solo + player.stats.SkyWars.losses_team} parties perdues`); - } - - const buffer = await canvas.getBufferAsync(Jimp.MIME_PNG); - const attachment = new MessageAttachment(buffer, 'joinimg.png'); - - const embed = new MessageEmbed() - .setTitle(`Stats de ${player.displayname}`) - .setDescription(`Voici les stats Hypixel de ${player.displayname} en Bedwars`) - .setImage("attachment://joinimg.png") - .setColor("#0099ff") - .setFooter("AstralHypixel") - - await interaction.followUp({ embeds: [embed], files: [attachment]}) - } catch (error) { - return console.log('HypixelGlobalImage => ',error); - } + const Quantify_50_white = await Jimp.loadFont( + path.join(__dirname, "../../res/fonts/Quantify_50_white.fnt") + ); + const Quantify_20_white = await Jimp.loadFont( + path.join(__dirname, "../../res/fonts/Quantify_20_white.fnt") + ); + const mask = await Jimp.read( + "https://raw.githubusercontent.com/CoderDixs/DraftBot/master/images/avatarMask.png" + ); -} + avatar.resize(136, Jimp.AUTO); + mask.resize(136, Jimp.AUTO); + avatar.mask(mask, 0, 0); + + canvas.blit(avatar, 5, 5); + + if (player.stats.SkyWars.skywars_experience) { + canvas.print( + Quantify_50_white, + 158, + 20, + `Niveau ${Math.trunc( + await xpToLevel(player.stats.SkyWars.skywars_experience) + )}` + ); + } + if (player.achievements.skywars_wins_solo) { + canvas.print( + Quantify_20_white, + 158, + 77, + `Total de ${ + player.achievements.skywars_wins_solo + + player.achievements.skywars_wins_team + } wins` + ); + } + if (player.stats.SkyWars.losses_solo) { + canvas.print( + Quantify_20_white, + 158, + 105, + `Total de ${ + player.stats.SkyWars.losses_solo + player.stats.SkyWars.losses_team + } parties perdues` + ); + } + + const buffer = await canvas.getBufferAsync(Jimp.MIME_PNG); + const attachment = new MessageAttachment(buffer, "joinimg.png"); + + const embed = new MessageEmbed() + .setTitle(`Stats de ${player.displayname}`) + .setDescription( + `Voici les stats Hypixel de ${player.displayname} en Bedwars` + ) + .setImage("attachment://joinimg.png") + .setColor("#0099ff") + .setFooter("AstralHypixel"); -async function xpToLevel(xp) { - let xps = [0, 20, 70, 150, 250, 500, 1000, 2000, 3500, 6000, 10000, 15000]; - if(xp >= 15000) { + await interaction.followUp({ embeds: [embed], files: [attachment] }); + } catch (error) { + // eslint-disable-next-line no-console + return console.log("HypixelGlobalImage => ", error); + } +}; + +function xpToLevel(xp) { + const xps = [0, 20, 70, 150, 250, 500, 1000, 2000, 3500, 6000, 10000, 15000]; + if (xp >= 15000) { return (xp - 15000) / 10000 + 12; } else { - for(i = 0; i < xps.length; i++) { - if(xp < xps[i]) { - return i + (xp - xps[i-1]) / (xps[i] - xps[i-1]); + for (let i = 0; i < xps.length; i++) { + if (xp < xps[i]) { + return i + (xp - xps[i - 1]) / (xps[i] - xps[i - 1]); } } } -} \ No newline at end of file +} diff --git a/src/functions/timestampToDate.js b/src/functions/timestampToDate.js index d8518a5..0033cf9 100644 --- a/src/functions/timestampToDate.js +++ b/src/functions/timestampToDate.js @@ -1,7 +1,5 @@ -module.exports = timestampToDate = function(timestamp) { - var date = new Date(timestamp); +module.exports = function (timestamp) { + const date = new Date(timestamp); - var fulldate = date.toLocaleDateString("fr-FR") - - return fulldate; -} \ No newline at end of file + return date.toLocaleDateString("fr-FR"); +}; diff --git a/src/index.js b/src/index.js index c060a2e..ba0e7b6 100644 --- a/src/index.js +++ b/src/index.js @@ -1,11 +1,11 @@ -const fs = require('fs'); -const { Client, Collection, Intents } = require('discord.js'); +const fs = require("fs"); +const { Client, Collection, Intents } = require("discord.js"); const { MongoClient } = require("mongodb"); const { Player } = require("discord-player"); const quickmongo = require("quickmongo"); -const config = require('../res/config.json') -const musicconfig = require('../res/music-config'); -const winston = require("winston") +const config = require("../res/config.json"); +const musicconfig = require("../res/music-config"); +const winston = require("winston"); require("dotenv").config(); @@ -19,7 +19,7 @@ const client = new Client({ Intents.FLAGS.GUILD_BANS, Intents.FLAGS.DIRECT_MESSAGES, Intents.FLAGS.GUILD_VOICE_STATES, - ] + ], }); client.config = config; client.musicconfig = musicconfig; From 16d9e5da958130950e3d0b31411c51bf4e937df7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o-21?= Date: Sun, 26 Dec 2021 21:59:20 +0100 Subject: [PATCH 19/20] pin important counting messages --- src/events/messageCreate.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/events/messageCreate.js b/src/events/messageCreate.js index 92fecd2..aa70ab4 100644 --- a/src/events/messageCreate.js +++ b/src/events/messageCreate.js @@ -12,11 +12,12 @@ module.exports = { } if (message.channel.id === client.config.countingChannelId) { + if (!message.content) return message.delete(); + const currentNumber = await client.countdb.get( `${message.guild.id}`, "currentNumber" ); - if (!message.content) return message.delete(); const authorid = await client.countdb.get( `${message.guild.id}`, "author" @@ -29,6 +30,10 @@ module.exports = { } if (message.author.id === authorid) return message.delete(); if (proposedNumber - 1 !== currentNumber) return message.delete(); + + if (proposedNumber % 1000 === 0 || proposedNumber === 500) + await message.pin(); + await client.countdb.set( `${message.guild.id}`, proposedNumber, From d12b8debb01ef1039aaf52974d8d013e9d8b714f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o-21?= Date: Mon, 27 Dec 2021 14:54:11 +0100 Subject: [PATCH 20/20] add new status --- src/events/ready.js | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/events/ready.js b/src/events/ready.js index 6027221..96d497c 100644 --- a/src/events/ready.js +++ b/src/events/ready.js @@ -17,14 +17,15 @@ module.exports = { await channel.send({ embeds: [embed] }); const activities = [ - "s'abonner à Astral", + "s'abonner à Astral 🔔", `${ (await client.guilds.fetch(client.config.mainGuildId)).memberCount } membres ! 🎉`, "RASTIQ & Léo-21", + `Version ${client.config.version} 🚀`, ]; - const activprefix = ["PLAYING", "WATCHING", "WATCHING"]; + const activprefix = ["PLAYING", "WATCHING", "WATCHING", "PLAYING"]; // Repeat every 20 minutes cron.schedule("*/20 * * * *", async () => { @@ -38,22 +39,13 @@ module.exports = { }); }; - setPresence(0); - setTimeout(function () { - setPresence(1); - setTimeout(function () { - setPresence(2); - }, 10000); - }, 10000); + let presenceCount = 0; + setPresence(presenceCount); setInterval(() => { - setPresence(0); - setTimeout(function () { - setPresence(1); - setTimeout(function () { - setPresence(2); - }, 10000); - }, 10000); - }, 30000); + presenceCount++; + if (presenceCount >= activities.length) presenceCount = 0; + setPresence(presenceCount); + }, 15000); }, };