-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #256 from Kathund/statsChannels
feat(Stats Channels)
- Loading branch information
Showing
8 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const hypixelRebornAPI = require("../../contracts/API/HypixelRebornAPI.js"); | ||
const { replaceVariables } = require("../../contracts/helperFunctions.js"); | ||
const { SuccessEmbed } = require("../../contracts/embedHandler.js"); | ||
const config = require("../../../config.json"); | ||
|
||
module.exports = { | ||
name: "force-update-channels", | ||
description: "Update the stats Channels", | ||
moderatorOnly: true, | ||
channelsCommand: true, | ||
|
||
execute: async (interaction, hidden = false) => { | ||
const hypixelGuild = await hypixelRebornAPI.getGuild("player", bot.username); | ||
const [channels, roles] = await Promise.all([guild.channels.fetch(), guild.roles.fetch()]); | ||
|
||
config.statsChannels.channels.forEach(async (channelInfo) => { | ||
const channel = await guild.channels.fetch(channelInfo.id); | ||
channel.setName( | ||
replaceVariables(channelInfo.name, { | ||
guildName: hypixelGuild.name, | ||
guildLevel: hypixelGuild.level, | ||
guildXP: hypixelGuild.experience, | ||
guildWeeklyXP: hypixelGuild.totalWeeklyGexp, | ||
guildMembers: hypixelGuild.members.length, | ||
|
||
discordMembers: guild.memberCount, | ||
discordChannels: channels.size, | ||
discordRoles: roles.size, | ||
}), | ||
"Updated Channels", | ||
); | ||
}); | ||
|
||
if (hidden) return | ||
const embed = new SuccessEmbed("The channels have been updated successfully.", { | ||
text: `by @kathund. | /help [command] for more information`, | ||
iconURL: "https://i.imgur.com/uUuZx2E.png", | ||
}); | ||
await interaction.followUp({ embeds: [embed] }); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const updateChannels = require("../commands/forceUpdateChannelsCommand.js"); | ||
const config = require("../../../config.json"); | ||
const cron = require("node-cron"); | ||
|
||
if (config.statsChannels.enabled) { | ||
console.log("Stats channels enabled"); | ||
cron.schedule(`*/${config.verification.autoUpdaterInterval} * * * *`, () => updateChannels.execute(null, true)); | ||
} |