diff --git a/commands/slash/info/help.js b/commands/slash/info/help.js index 9bb2253..7806fdf 100644 --- a/commands/slash/info/help.js +++ b/commands/slash/info/help.js @@ -13,100 +13,46 @@ module.exports = { category: "info", disabled: false, args: false, - aliases: ["commands", "cmds"], - description: `Sends you a detailed list of my commands.`, - cooldown: "3", - usage: [``], + description: "Sends you a detailed list of my commands.", + cooldown: 3, }, - async run(client, message, args) { + async run(client, interaction) { try { - const categories = readdirSync(`${__dirname}/../../../commands/slash`); - let embed = new EmbedBuilder() - .setAuthor({ - name: `${client.user.username} - Help Menu`, - }) - .setColor(client.color) - .setDescription( - `>>> My prefix is / Use the menu to view a list of commands based on their category!`, - ) - .setImage(client.banner) - .setThumbnail(client.logo) - .setFooter({ - text: client.footer, - }); - let select = new SelectMenuBuilder() + const categories = readdirSync("./commands/slash"); + const options = categories.map((cat) => ({ + label: cat[0].toUpperCase() + cat.slice(1), + value: cat, + description: `Click to see commands for: ${cat}`, + })); + + const selectMenu = new SelectMenuBuilder() .setCustomId("help-menu") - .setPlaceholder("Click to see my command categories"); - await categories.map((cat) => { - if (cat) { - select.addOptions({ - label: `${cat[0].toUpperCase() + cat.slice(1)}`, - value: `${cat}`, - description: `Click to See Commands for: ${cat}`, - }); - } - }); + .setPlaceholder("Click to see command categories") + .addOptions(options); - let btn = new ButtonBuilder() + const homeButton = new ButtonBuilder() .setCustomId("home") .setLabel("Home") - .setStyle(ButtonStyle.Primary); - let ButtonsRow = new ActionRowBuilder().addComponents(btn); - message - .reply({ - embeds: [embed], - components: [ - { - type: 1, - components: [select], - }, - ButtonsRow, - ], - }) - .then(async (msg) => { - let filter = (i) => i.user.id === message.author.id; - let colector = await msg.createMessageComponentCollector({ - filter: filter, - }); - colector.on("collect", async (i) => { - if (i.isButton()) { - if (i.customId === "home") { - await i.deferUpdate().catch((e) => {}); - msg - .edit({ - embeds: [embed], - }) - .catch((e) => {}); - } - } - if (i.isSelectMenu()) { - a; - if (i.customId === "help-menu") { - await i.deferUpdate().catch((e) => {}); - let [directory] = i.values; - let aa = new EmbedBuilder() - .setTitle(`Commands for: ${directory}`) - .setColor(client.color) - .setDescription( - `${client.commands - .filter((cmd) => cmd.help.category === directory) - .map((cmd) => { - return [`\`/cmd.help.name}\``].join(" "); - }) - .join("\n")}`, - ) - .setFooter({ - text: client.footer, - }); - msg.edit({ - embeds: [aa], - }); - } - } - }); - }); - } catch (e) { - // error logger here + .setStyle(ButtonStyle.PRIMARY); + + const row = new ActionRowBuilder() + .addComponents(selectMenu) + .addComponents(homeButton); + + const embed = new EmbedBuilder() + .setAuthor(`${client.user.username} - Help Menu`) + .setColor("#7289da") + .setDescription( + "My prefix is `/`. Use the menu to view commands based on their category!", + ); + + await interaction.reply({ + embeds: [embed], + components: [row], + ephemeral: true, + }); + } catch (error) { + console.error("Error in help command:", error); } }, }; diff --git a/commands/slash/info/slashinfo.js b/commands/slash/info/slashinfo.js index 879be98..bceb683 100644 --- a/commands/slash/info/slashinfo.js +++ b/commands/slash/info/slashinfo.js @@ -3,7 +3,6 @@ const { EmbedBuilder, ApplicationCommandOptionType } = require("discord.js"); module.exports = { name: "slashinfo", description: "Gives you information of a command.", - cooldown: "3", disabled: false, options: [ { @@ -28,10 +27,6 @@ module.exports = { name: `Permissions:`, value: `${cmd.permissions ? `\`${cmd.permissions.join(", ")}\`` : "`None`"}`, }, - { - name: `Cooldowns:`, - value: `${cmd.cooldown ? `\`${cmd.cooldown} second(s)\`` : "`No Cooldown`"}`, - }, { name: `Disabled:`, value: `${cmd.disabled ? "`Yes`" : "`No`"}`, diff --git a/commands/slash/info/stats.js b/commands/slash/info/stats.js index fc97b30..c762d13 100644 --- a/commands/slash/info/stats.js +++ b/commands/slash/info/stats.js @@ -1,6 +1,7 @@ const { EmbedBuilder, Colors, version } = require("discord.js"); const mongoose = require("mongoose"); const { time } = require("@discordjs/builders"); +const config = require("../../../config/config.js"); module.exports = { name: "stats", @@ -9,12 +10,15 @@ module.exports = { disabled: false, run: async (client, interaction, args) => { const botvalue = (Date.now() / 1000 - client.uptime / 1000).toFixed(0); + const developers = + config.Developers?.map((dev) => `<@!${dev}>`).join(", ") || + "No developers listed"; const aboutUs = new EmbedBuilder() .setTitle("TopicManager - Stats") .addFields( { name: `Developers:`, - value: `Ranveer Soni`, + value: developers, }, { name: `Created On:`, diff --git a/commands/slash/info/team.js b/commands/slash/info/team.js index f0d3c4d..86d9bc1 100644 --- a/commands/slash/info/team.js +++ b/commands/slash/info/team.js @@ -28,7 +28,7 @@ module.exports = { }, { name: `Website Moderators:`, - value: `3`, + value: `2`, }, { name: `Site Developers:`, diff --git a/commands/slash/mod/approve.js b/commands/slash/mod/approve.js deleted file mode 100644 index e69de29..0000000 diff --git a/commands/slash/mod/decline.js b/commands/slash/mod/decline.js deleted file mode 100644 index e69de29..0000000 diff --git a/commands/slash/bot/reportbug.js b/commands/slash/other/reportbug.js similarity index 100% rename from commands/slash/bot/reportbug.js rename to commands/slash/other/reportbug.js diff --git a/commands/slash/Status/status.js b/commands/slash/other/status.js similarity index 100% rename from commands/slash/Status/status.js rename to commands/slash/other/status.js diff --git a/commands/slash/bot/suggest.js b/commands/slash/other/suggest.js similarity index 100% rename from commands/slash/bot/suggest.js rename to commands/slash/other/suggest.js diff --git a/commands/slash/owner/eval.js b/commands/slash/owner/eval.js new file mode 100644 index 0000000..0ef26eb --- /dev/null +++ b/commands/slash/owner/eval.js @@ -0,0 +1,44 @@ +const { MessageEmbed, ApplicationCommandOptionType } = require("discord.js"); + +module.exports = { + name: "eval", + description: "Evaluate JavaScript code.", + disabled: false, + options: [ + { + name: "code", + type: ApplicationCommandOptionType.String, + required: true, + description: "Please provide the JavaScript code to evaluate.", + }, + ], + run: async (client, interaction, args) => { + const code = interaction.options.getString("code"); + + try { + let result = eval(code); + result = result instanceof Promise ? await result : result; + + const evalEmbed = new MessageEmbed() + .setColor(client.color) + .setFooter({ + text: client.footer, + }) + .setTitle("Evaluation Result") + .addField("Input", `\`\`\`js\n${code}\n\`\`\``) + .addField("Output", `\`\`\`js\n${result}\n\`\`\``); + + interaction.reply({ embeds: [evalEmbed] }); + } catch (error) { + const errorEmbed = new MessageEmbed() + .setColor("#FF0000") + .setFooter({ + text: client.footer, + }) + .setTitle("Error Occurred") + .setDescription(`\`\`\`js\n${error}\n\`\`\``); + + interaction.reply({ embeds: [errorEmbed] }); + } + }, +}; diff --git a/commands/slash/partner/allpartners.js b/commands/slash/partner/allpartners.js new file mode 100644 index 0000000..0664b89 --- /dev/null +++ b/commands/slash/partner/allpartners.js @@ -0,0 +1,49 @@ +const { MessageEmbed } = require("discord.js"); +const fetch = require("node-fetch"); +const config = require("../../../config/config.js"); + +module.exports = { + name: "all-partners", + description: "Tells you about all our partners.", + cooldown: "3", + disabled: false, + run: async (client, interaction, args) => { + try { + const response = await fetch(`https://api.topiclist.xyz/partners/@all`); + const partners = await response.json(); + + if (!Array.isArray(partners)) { + throw new Error("Partners data is not in the expected format."); + } + + const partnerEmbed = new MessageEmbed() + .setTitle("Our Partners") + .setColor(client.color) + .setFooter(client.footer); + + partners.forEach((partner) => { + partnerEmbed.addField( + partner.title, + `[${partner.text}](${partner.link})`, + ); + }); + + return interaction.reply({ + embeds: [partnerEmbed], + }); + } catch (error) { + console.error("Error fetching partners:", error); + if ( + error instanceof TypeError && + error.message.startsWith("body used already") + ) { + console.error("Response body already consumed."); + } else { + console.error("API Response:", await response.text()); + } + return interaction.reply( + "Sorry, I couldn't fetch our partners at the moment.", + ); + } + }, +}; diff --git a/config/config.js b/config/config.js index c006c6b..d36854a 100644 --- a/config/config.js +++ b/config/config.js @@ -1,4 +1,4 @@ -module.export = { +module.exports = { client: { id: "925740376948609034", prefix: "/", @@ -6,25 +6,21 @@ module.export = { devtoken: process.env.devtoken, owners: ["787241442770419722", "510065483693817867", "853483818464051200"], }, - admins: [ - "852521383006961687", + Admins: [ "787241442770419722", - "887549958931247137", "899722893603274793", "853483818464051200", "510065483693817867", ], - staff: [ - "852521383006961687", + Developers: ["787241442770419722", "510065483693817867"], + Staff: [ "787241442770419722", - "887549958931247137", "899722893603274793", "853483818464051200", "510065483693817867", ], API: { APIURL: "https://api.topiclist.xyz", - APISECRET: process.env.APISECRET, }, rolesList: { AwaitingVerification: "1008002984791248916", diff --git a/events/messages/messageCreate.js b/events/messages/messageCreate.js index e6054d9..11cd2af 100644 --- a/events/messages/messageCreate.js +++ b/events/messages/messageCreate.js @@ -4,7 +4,7 @@ module.exports.run = async (client, message) => { try { if (message.author.bot) return; if (!message.guild) return; - var prefix = client.config.bot.prefix; + var prefix = client.config.client.prefix; const mention = new RegExp(`^<@!?${client.user.id}>( |)$`); if (message.content.match(mention)) { const embed = new EmbedBuilder() diff --git a/functions/handlers.js b/functions/handlers.js index 706569d..6f5e1cc 100644 --- a/functions/handlers.js +++ b/functions/handlers.js @@ -3,6 +3,7 @@ const fs = require("fs"); /** * LOAD THE CLIENT EVENTS */ + const loadEvents = async function (client) { const eventFolders = fs.readdirSync("./events"); for (const folder of eventFolders) { diff --git a/package.json b/package.json index 08a5a83..aa4b064 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,8 @@ "dependencies": { "@discordjs/builders": "^1.1.0", "@discordjs/rest": "^1.0.1", - "@infinitylist/uptime": "0.1.7-alpha.6", - "discord.js": "^14.12.1", + "@infinitylist/uptime": "^0.1.7-alpha.7", + "discord.js": "^14.14.1", "dotenv": "^16.4.1", "express": "^4.18.2", "fs": "^0.0.1-security", diff --git a/topic.js b/topic.js index 6e45ea6..6e86403 100644 --- a/topic.js +++ b/topic.js @@ -1,6 +1,7 @@ require("dotenv").config(); const express = require("express"); const { Client, Collection, GatewayIntentBits } = require("discord.js"); +const mongoose = require("mongoose"); const client = new Client({ fetchAllMembers: true, @@ -60,8 +61,8 @@ eventHandler.loadSlash(client); } })(); -//client.login(process.env.devtoken); -client.login(process.env.DISCORD_TOKEN); +client.login(process.env.devtoken); +//client.login(process.env.DISCORD_TOKEN); //temp use only xD const app = express(); const port = 3000;