From 8766a10469d468bd479a4a9b7fe9b3a44607795b Mon Sep 17 00:00:00 2001 From: "Jonny_Bro (Nikita)" Date: Wed, 14 Feb 2024 21:16:13 +0500 Subject: [PATCH] remove userId from config --- base/Client.js | 20 +++++++++++++------- config.sample.js | 27 ++++++++++++++------------- dashboard/dashboard.js | 4 ++-- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/base/Client.js b/base/Client.js index 86a23d47..bc00de9b 100644 --- a/base/Client.js +++ b/base/Client.js @@ -137,8 +137,8 @@ class JaBaClient extends Client { } try { - if (this.config.production) await rest.put(Routes.applicationCommands(this.config.userId), { body: commands }); - else await rest.put(Routes.applicationGuildCommands(this.config.userId, this.config.support.id), { body: commands }); + if (this.config.production) await rest.put(Routes.applicationCommands(this.user.id), { body: commands }); + else await rest.put(Routes.applicationGuildCommands(this.user.id, this.config.support.id), { body: commands }); this.logger.log("Successfully registered application commands."); } catch (err) { @@ -177,17 +177,23 @@ class JaBaClient extends Client { .setThumbnail(data.thumbnail || null) .addFields(data.fields || []) .setImage(data.image || null) - .setURL(data.url || null) - .setColor(data.color || this.config.embed.color) - .setFooter(data.footer || this.config.embed.footer); + .setURL(data.url || null); + + if (data.color) embed.setColor(data.color); + else if (data.color === null) embed.setColor(null); + else embed.setColor(this.config.embed.color); + + if (data.footer) embed.setFooter(data.footer); + else if (data.footer === null) embed.setFooter(null); + else embed.setFooter(this.config.embed.footer); if (data.timestamp) embed.setTimestamp(data.timestamp); else if (data.timestamp === null) embed.setTimestamp(null); else embed.setTimestamp(); - if (typeof data.author === "string") embed.setAuthor({ name: data.author, iconURL: this.user.avatarURL() }); + if (!data.author || data.author === null) embed.setAuthor(null); + else if (typeof data.author === "string") embed.setAuthor({ name: data.author, iconURL: this.user.avatarURL() }); else if (typeof data.author === "object" && (data.author.iconURL !== null || data.author.iconURL !== undefined)) embed.setAuthor({ name: data.author.name, iconURL: this.user.avatarURL() }); - else if (!data.author || data.author === null) embed.setAuthor(null); else embed.setAuthor(data.author); return embed; diff --git a/config.sample.js b/config.sample.js index b2f85dd4..c2b5e509 100644 --- a/config.sample.js +++ b/config.sample.js @@ -1,38 +1,39 @@ module.exports = { /* The token of your Discord Bot */ token: "XXXXXXXXXXXXXXXXXXXXXXXXXXXX", - /* ID of Bot's user */ - userId: "123456789098765432", + /* The URL of the MongoDB database */ + mongoDB: "mongodb://127.0.0.1:27017/discordbot", /* Set to true for production */ /* If set to false, commands only will be registered on the support.id server */ production: true, - /* For the support server */ + /* Support server */ support: { id: "123456789098765432", // The ID of the support server - logs: "123456789098765432", // And the ID of the logs channel of your server (when bot joins or leaves a guild) - invite: "https://discord.gg/discord", // Invite link to your support server + logs: "123456789098765432", // The channel's ID for logs on the support server (when bot joins or leaves a guild) + invite: "https://discord.gg/discord", // Invite link to the support server }, /* Dashboard configuration */ dashboard: { enabled: false, // Whether the dashboard is enabled or not - maintanceKey: "letmein", // Your maintance key + maintanceKey: "letmein", // Maintance key port: 80, // Dashboard port domain: "http://localhost", // The base URL of the dashboard without / at the end secret: "XXXXXXXXXXXXXXXXXXXXXXXXXXXX", // Your Bot's Client Secret logs: "123456789098765432", // The channel ID for logs }, - mongoDB: "mongodb://127.0.0.1:27017/discordbot", // The URL of the MongoDB database - /* For the embeds */ + /* Embeds defaults */ embed: { - color: "#00FF00", // The default color for the embeds + color: "#00FF00", // Color footer: { - text: "My Discord Bot | v" + require("./package.json").version, - }, // And the default footer for the embeds + text: "My Discord Bot | v" + require("./package.json").version, // Footer text + }, }, /* Bot's owner informations */ owner: { id: "123456789098765432", // The ID of the bot's owner }, - /* The API keys that are required for certain commands */ - apiKeys: {}, + /* Add your own API keys here */ + apiKeys: { + + }, }; diff --git a/dashboard/dashboard.js b/dashboard/dashboard.js index d6a87a92..5307672b 100644 --- a/dashboard/dashboard.js +++ b/dashboard/dashboard.js @@ -45,7 +45,7 @@ module.exports.load = async client => { const Dashboard = new DBD.Dashboard({ port: client.config.dashboard.port, client: { - id: client.config.userId, + id: client.user.id, secret: client.config.dashboard.secret, }, cookiesSecret: client.config.dashboard.secret, @@ -55,7 +55,7 @@ module.exports.load = async client => { ownerIDs: [client.config.owner.id], requiredPermissions: PermissionsBitField.Flags.ViewChannel, invite: { - clientId: client.config.userId, + clientId: client.user.id, scopes: ["bot", "applications.commands"], permissions: "8", redirectUri: `${client.config.dashboard.domain}`,