Skip to content

Commit

Permalink
Merge pull request #2 from TopicBotList/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Miya25 authored Mar 22, 2024
2 parents c316d8f + 4a32bee commit 3b752d3
Show file tree
Hide file tree
Showing 16 changed files with 144 additions and 108 deletions.
122 changes: 34 additions & 88 deletions commands/slash/info/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
},
};
5 changes: 0 additions & 5 deletions commands/slash/info/slashinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand All @@ -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`"}`,
Expand Down
6 changes: 5 additions & 1 deletion commands/slash/info/stats.js
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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:`,
Expand Down
2 changes: 1 addition & 1 deletion commands/slash/info/team.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
},
{
name: `Website Moderators:`,
value: `3`,
value: `2`,
},
{
name: `Site Developers:`,
Expand Down
Empty file removed commands/slash/mod/approve.js
Empty file.
Empty file removed commands/slash/mod/decline.js
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
44 changes: 44 additions & 0 deletions commands/slash/owner/eval.js
Original file line number Diff line number Diff line change
@@ -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] });
}
},
};
49 changes: 49 additions & 0 deletions commands/slash/partner/allpartners.js
Original file line number Diff line number Diff line change
@@ -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.",
);
}
},
};
12 changes: 4 additions & 8 deletions config/config.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
module.export = {
module.exports = {
client: {
id: "925740376948609034",
prefix: "/",
token: process.env.DISCORD_TOKEN,
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",
Expand Down
2 changes: 1 addition & 1 deletion events/messages/messageCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions functions/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions topic.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3b752d3

Please sign in to comment.