|
| 1 | +const hypixelRebornAPI = require("../../contracts/API/HypixelRebornAPI.js"); |
| 2 | +const { replaceVariables } = require("../../contracts/helperFunctions.js"); |
| 3 | +const { SuccessEmbed } = require("../../contracts/embedHandler.js"); |
| 4 | +const config = require("../../../config.json"); |
| 5 | + |
| 6 | +module.exports = { |
| 7 | + name: "force-update-channels", |
| 8 | + description: "Update the stats Channels", |
| 9 | + moderatorOnly: true, |
| 10 | + channelsCommand: true, |
| 11 | + |
| 12 | + execute: async (interaction, hidden = false) => { |
| 13 | + const hypixelGuild = await hypixelRebornAPI.getGuild("player", bot.username); |
| 14 | + const [channels, roles] = await Promise.all([guild.channels.fetch(), guild.roles.fetch()]); |
| 15 | + |
| 16 | + config.statsChannels.channels.forEach(async (channelInfo) => { |
| 17 | + const channel = await guild.channels.fetch(channelInfo.id); |
| 18 | + channel.setName( |
| 19 | + replaceVariables(channelInfo.name, { |
| 20 | + guildName: hypixelGuild.name, |
| 21 | + guildLevel: hypixelGuild.level, |
| 22 | + guildXP: hypixelGuild.experience, |
| 23 | + guildWeeklyXP: hypixelGuild.totalWeeklyGexp, |
| 24 | + guildMembers: hypixelGuild.members.length, |
| 25 | + |
| 26 | + discordMembers: guild.memberCount, |
| 27 | + discordChannels: channels.size, |
| 28 | + discordRoles: roles.size, |
| 29 | + }), |
| 30 | + "Updated Channels", |
| 31 | + ); |
| 32 | + }); |
| 33 | + |
| 34 | + if (hidden) return |
| 35 | + const embed = new SuccessEmbed("The channels have been updated successfully.", { |
| 36 | + text: `by @kathund. | /help [command] for more information`, |
| 37 | + iconURL: "https://i.imgur.com/uUuZx2E.png", |
| 38 | + }); |
| 39 | + await interaction.followUp({ embeds: [embed] }); |
| 40 | + }, |
| 41 | +}; |
0 commit comments