dashboard v1
This commit is contained in:
1 parent
57d420a9f4
commit
22c33c0f7a
66 files changed
+6100
-465
No files matched your search
@@ -0,0 +1,11 @@
|
||||
|
||||
# SupportBot | Emerald Services
|
||||
# Discord Stats addon | Created by Xiled Emerald
|
||||
|
||||
Guild_ID: "GUILD_ID_HERE"
|
||||
|
||||
StatsCategory: "Server Statistics"
|
||||
|
||||
UserCount_Name: "Total Members:"
|
||||
ChannelCount_Name: "Total Channels:"
|
||||
RoleCount_Name: "Total Roles:"
|
||||
+1
-1
@@ -2,7 +2,7 @@ const Discord = require("discord.js");
|
||||
const fs = require("fs");
|
||||
const yaml = require("js-yaml");
|
||||
const { Command } = require('../Structures/Addon.js'); // Adjust the path as needed
|
||||
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
||||
const supportbot = require("../Structures/ConfigStore").supportbot;
|
||||
|
||||
module.exports = new Command({
|
||||
name: "addon",
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
// SupportBot | Emerald Services
|
||||
// Discord Stats addon | Created by Xiled Emerald
|
||||
|
||||
const fs = require("fs");
|
||||
|
||||
const Discord = require("discord.js");
|
||||
const yaml = require("js-yaml");
|
||||
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
||||
|
||||
// If you need to read something from the main config!
|
||||
const cmdconfig = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
||||
|
||||
// This is for your Addon Configuration
|
||||
const config = yaml.load(fs.readFileSync('./Addons/Configs/discord-stats.yml', 'utf8'));
|
||||
|
||||
const { Command, Event } = require("../Structures/Addon");
|
||||
|
||||
module.exports.commands = [
|
||||
|
||||
new Command({
|
||||
name: "stats",
|
||||
description: "Create the discord statistic channels",
|
||||
options: [],
|
||||
permissions: ["SEND_MESSAGES"],
|
||||
async run(interaction) {
|
||||
const guild = interaction.guild;
|
||||
const statsCategory = guild.channels.cache.find(
|
||||
(category) =>
|
||||
category.name === config.StatsCategory ||
|
||||
category.id === config.StatsCategory
|
||||
);
|
||||
|
||||
if (!statsCategory) {
|
||||
const errorEmbed = new Discord.MessageEmbed()
|
||||
.setTitle("Invalid Category")
|
||||
.setDescription(
|
||||
`${supportbot.InvalidChannel}\n\n**Category Required:** \`${config.StatsCategory}\``
|
||||
)
|
||||
.setColor(supportbot.ErrorColour);
|
||||
|
||||
interaction.reply({
|
||||
embeds: [errorEmbed],
|
||||
ephemeral: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const guildName = guild.name;
|
||||
const userCount = guild.memberCount;
|
||||
const roleCount = guild.roles.cache.size;
|
||||
const channelCount = guild.channels.cache.size;
|
||||
|
||||
try {
|
||||
const guildNameChannel = await guild.channels.create(guildName, {
|
||||
type: "GUILD_VOICE",
|
||||
});
|
||||
|
||||
const userCountChannel = await guild.channels.create(
|
||||
`${config.UserCount_Name} ${userCount}`,
|
||||
{
|
||||
type: "GUILD_VOICE",
|
||||
}
|
||||
);
|
||||
|
||||
const channelCountChannel = await guild.channels.create(
|
||||
`${config.ChannelCount_Name} ${channelCount}`,
|
||||
{
|
||||
type: "GUILD_VOICE",
|
||||
}
|
||||
);
|
||||
|
||||
const roleCountChannel = await guild.channels.create(
|
||||
`${config.RoleCount_Name} ${roleCount}`,
|
||||
{
|
||||
type: "GUILD_VOICE",
|
||||
}
|
||||
);
|
||||
|
||||
guildNameChannel.permissionOverwrites.edit(guild.id, {
|
||||
VIEW_CHANNEL: true,
|
||||
CONNECT: false,
|
||||
});
|
||||
|
||||
userCountChannel.permissionOverwrites.edit(guild.id, {
|
||||
VIEW_CHANNEL: true,
|
||||
CONNECT: false,
|
||||
});
|
||||
|
||||
channelCountChannel.permissionOverwrites.edit(guild.id, {
|
||||
VIEW_CHANNEL: true,
|
||||
CONNECT: false,
|
||||
});
|
||||
|
||||
roleCountChannel.permissionOverwrites.edit(guild.id, {
|
||||
VIEW_CHANNEL: true,
|
||||
CONNECT: false,
|
||||
});
|
||||
|
||||
userCountChannel.setParent(statsCategory.id);
|
||||
roleCountChannel.setParent(statsCategory.id);
|
||||
guildNameChannel.setParent(statsCategory.id);
|
||||
channelCountChannel.setParent(statsCategory.id);
|
||||
|
||||
const successEmbed = new Discord.MessageEmbed()
|
||||
.setDescription(":white_check_mark: **[DISCORD STATS]** Channels created successfully!")
|
||||
.setColor(supportbot.EmbedColour);
|
||||
|
||||
interaction.reply({
|
||||
embeds: [successEmbed],
|
||||
ephemeral: true,
|
||||
});
|
||||
|
||||
setInterval(() => {
|
||||
userCountChannel.setName(
|
||||
`${config.UserCount_Name} ${userCount}`
|
||||
);
|
||||
channelCountChannel.setName(
|
||||
`${config.ChannelCount_Name} ${channelCount}`
|
||||
);
|
||||
roleCountChannel.setName(
|
||||
`${config.RoleCount_Name} ${roleCount}`
|
||||
);
|
||||
}, 30000);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
const errorEmbed = new Discord.MessageEmbed()
|
||||
.setTitle("Error")
|
||||
.setDescription("An error occurred while creating the stats channels.")
|
||||
.setColor(supportbot.ErrorColour);
|
||||
|
||||
interaction.reply({
|
||||
embeds: [errorEmbed],
|
||||
ephemeral: true,
|
||||
});
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
];
|
||||
Reference in new issue
Block a user