From eeaf5c0508815afc82e638a6af444277237d44ce Mon Sep 17 00:00:00 2001 From: EvarinDev Date: Sun, 27 Oct 2024 12:20:35 +0700 Subject: [PATCH 1/2] Refactor config file and structures - Add debug flag to the bot configuration in seyfert.config.js - Update room object in ServiceExecute.ts to include a uuid property - Update shards configuration in Starlight.ts to use the length of the SHARD_LIST array - Add new configuration options for ads in the development and production environments in config.ts - Remove ad.ts file --- seyfert.config.js | 1 + src/client/structures/ServiceExecute.ts | 4 ++-- src/client/structures/Starlight.ts | 3 +-- src/config.ts | 16 ++++++++++++++++ src/lib/ad.ts | 5 ----- 5 files changed, 20 insertions(+), 9 deletions(-) delete mode 100644 src/lib/ad.ts diff --git a/seyfert.config.js b/seyfert.config.js index 0e2739f..de7ad42 100644 --- a/seyfert.config.js +++ b/seyfert.config.js @@ -5,6 +5,7 @@ const c = require("./dist/config.js"); module.exports = config.bot({ token: c.default.TOKEN ?? "", + debug: true, intents: ["Guilds", "GuildVoiceStates"], locations: { base: "src/client", diff --git a/src/client/structures/ServiceExecute.ts b/src/client/structures/ServiceExecute.ts index 6be524a..a2b1b6f 100644 --- a/src/client/structures/ServiceExecute.ts +++ b/src/client/structures/ServiceExecute.ts @@ -136,7 +136,7 @@ export class ServiceLoader { name: guild.name, roomid: "0", lang: $Enums.Lang.en, - room: { id: "0", message: "0" }, + room: { id: "0", message: "0", uuid: "" }, }; await this.client.redis.set(`guild:${this.client.me.id}:${guild.id}`, JSON.stringify(database)); @@ -150,7 +150,7 @@ export class ServiceLoader { name: data.name || '', roomid: data.roomid || "0", lang: data.lang || $Enums.Lang.en, - room: data.room || { id: "0", message: "0" }, + room: data.room || { id: "0", message: "0", uuid: "" }, }; } diff --git a/src/client/structures/Starlight.ts b/src/client/structures/Starlight.ts index 50df4e5..dfe1de1 100644 --- a/src/client/structures/Starlight.ts +++ b/src/client/structures/Starlight.ts @@ -21,8 +21,7 @@ export class Starlight extends Client { super({ shards: { start: getInfo().FIRST_SHARD_ID, - end: getInfo().LAST_SHARD_ID, - total: getInfo().TOTAL_SHARDS + end: getInfo().SHARD_LIST.length, }, commands: { defaults: { diff --git a/src/config.ts b/src/config.ts index 710919c..98e7175 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,10 +1,16 @@ import { NodeOptions } from "sakulink"; import "dotenv/config"; +import { ActionRow, BuilderComponents, Button } from "seyfert"; const config: { [key: string]: IConfig } = { development: { TOKEN: process.env.DEVELOPMENT_TOKEN, REDIS: process.env.DEVELOPMENT_REDIS, + config: { + ads_text: "กำลังมองหาเซิร์ฟเวอร์ Minecraft แนว PvP หรือ SMP อยู่ใช่ไหม?", + ads_image: "https://cdn.faystarnext.studio/RinthongAds.png", + ads_component: new ActionRow().addComponents(new Button().setLabel("Link").setStyle(5).setEmoji("🔗").setURL("https://discord.gg/gsHWw9XyE6")) + }, Lavalink: [ { identifier: "Jirayu.net[0] [recommend]", @@ -20,6 +26,11 @@ const config: { [key: string]: IConfig } = { production: { TOKEN: process.env.PRODUCTION_TOKEN, REDIS: process.env.PRODUCTION_REDIS, + config: { + ads_text: "กำลังมองหาเซิร์ฟเวอร์ Minecraft แนว PvP หรือ SMP อยู่ใช่ไหม?", + ads_image: "https://cdn.faystarnext.studio/RinthongAds.png", + ads_component: new ActionRow().addComponents(new Button().setLabel("Link").setStyle(5).setEmoji("🔗").setURL("https://discord.gg/gsHWw9XyE6")) + }, Lavalink: [ { identifier: "Jirayu.net[1]", @@ -40,4 +51,9 @@ interface IConfig { REDIS?: string; DSA?: string; TOKEN: string; + config: { + ads_text: string; + ads_image: string; + ads_component: ActionRow; + }; } diff --git a/src/lib/ad.ts b/src/lib/ad.ts deleted file mode 100644 index aad4b3e..0000000 --- a/src/lib/ad.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { ActionRow, Button } from "seyfert"; - -export const ads_text = "กำลังมองหาเซิร์ฟเวอร์ Minecraft แนว PvP หรือ SMP อยู่ใช่ไหม?"; -export const ads_image = "https://cdn.faystarnext.studio/RinthongAds.png"; -export const ads_component = new ActionRow().addComponents(new Button().setLabel("Link").setStyle(5).setEmoji("🔗").setURL("https://discord.gg/gsHWw9XyE6")); From 0ebccbf7b4aca0785dc5a7e3bdfd4b46c3736d76 Mon Sep 17 00:00:00 2001 From: EvarinDev Date: Sun, 27 Oct 2024 12:22:24 +0700 Subject: [PATCH 2/2] Refactor ad configuration in LoopCommand and MusicPlay --- src/client/service/commands/LoopCommand.ts | 20 ++++++++++---------- src/client/service/commands/MusicPlay.ts | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/client/service/commands/LoopCommand.ts b/src/client/service/commands/LoopCommand.ts index fdeb306..3b36902 100644 --- a/src/client/service/commands/LoopCommand.ts +++ b/src/client/service/commands/LoopCommand.ts @@ -2,7 +2,7 @@ import { ServiceExecute } from "@/client/structures/ServiceExecute"; import { IDatabase } from "@/client/interfaces/IDatabase"; import { CommandContext, Embed, UsingClient } from "seyfert"; import { LoopCommandOptions } from "@/client/commands/music/loop"; -import { ads_component, ads_image, ads_text } from "@/lib/ad"; +import config from "@/config"; const LoopCommand: ServiceExecute = { name: "LoopCommand", @@ -34,16 +34,16 @@ const LoopCommand: ServiceExecute = { case "song": { player.setTrackRepeat(true); interaction.editOrReply({ - components: [ads_component], + components: [config.config.ads_component], embeds: [ new Embed() .setColor("#a861ff") .setDescription(`Song loop has been successfully turned ${player.trackRepeat ? "on" : "off"}`) - .setImage(ads_image) + .setImage(config.config.ads_image) .addFields([ { name: "Sponsor", - value: ads_text, + value: config.config.ads_text, inline: false, }, ]) @@ -55,16 +55,16 @@ const LoopCommand: ServiceExecute = { case "queue": { player.setQueueRepeat(true); interaction.editOrReply({ - components: [ads_component], + components: [config.config.ads_component], embeds: [ new Embed() .setColor("#a861ff") .setDescription(`${player.queueRepeat ? "on" : "off"} Queue loop complete`) - .setImage(ads_image) + .setImage(config.config.ads_image) .addFields([ { name: "Sponsor", - value: ads_text, + value: config.config.ads_text, inline: false, }, ]) @@ -77,16 +77,16 @@ const LoopCommand: ServiceExecute = { player.setTrackRepeat(false); player.setQueueRepeat(false); interaction.editOrReply({ - components: [ads_component], + components: [config.config.ads_component], embeds: [ new Embed() .setColor("#a861ff") .setDescription(`Loop closed successfully.`) - .setImage(ads_image) + .setImage(config.config.ads_image) .addFields([ { name: "Sponsor", - value: ads_text, + value: config.config.ads_text, inline: false, }, ]) diff --git a/src/client/service/commands/MusicPlay.ts b/src/client/service/commands/MusicPlay.ts index 06c148b..317b618 100644 --- a/src/client/service/commands/MusicPlay.ts +++ b/src/client/service/commands/MusicPlay.ts @@ -1,8 +1,8 @@ import { CommandContext, UsingClient } from 'seyfert'; import { PlayCommandOptions } from "@/client/commands/music/play"; import { IDatabase } from "@/client/interfaces/IDatabase"; -import { ads_component, ads_image, ads_text } from "@/lib/ad"; import { ServiceExecute } from "@/client/structures/ServiceExecute"; +import config from '@/config'; const MusicPlay: ServiceExecute = { name: "MusicPlay", @@ -92,7 +92,7 @@ const MusicPlay: ServiceExecute = { { const playlist = res.playlist; await interaction.editOrReply({ - components: [ads_component], + components: [config.config.ads_component], embeds: [ { author: { @@ -102,7 +102,7 @@ const MusicPlay: ServiceExecute = { title: `\`\`🟢\`\` ${t.play.added_playlist.get()}: \`${playlist.name}\``, color: 0xa861ff, // Purple color image: { - url: ads_image, + url: config.config.ads_image, }, fields: [ { @@ -117,7 +117,7 @@ const MusicPlay: ServiceExecute = { }, { name: "Sponsor", - value: ads_text, + value: config.config.ads_text, inline: false, }, ], @@ -137,7 +137,7 @@ const MusicPlay: ServiceExecute = { { const track = res.tracks[0]; await interaction.editOrReply({ - components: [ads_component], + components: [config.config.ads_component], embeds: [ { author: { @@ -147,7 +147,7 @@ const MusicPlay: ServiceExecute = { title: `\`\`🟢\`\` ${t.play.added_song.get()}: \`${track.title}\``, color: 0xa861ff, // Purple color image: { - url: ads_image, + url: config.config.ads_image, }, fields: [ { @@ -162,7 +162,7 @@ const MusicPlay: ServiceExecute = { }, { name: "Sponsor", - value: ads_text, + value: config.config.ads_text, inline: false, }, ], @@ -194,7 +194,7 @@ const MusicPlay: ServiceExecute = { player.queue.add(track); await interaction.editOrReply({ - components: [ads_component], + components: [config.config.ads_component], embeds: [ { author: { @@ -204,7 +204,7 @@ const MusicPlay: ServiceExecute = { title: `\`\`🟢\`\` ${t.play.added_song.get()}: \`${track.title}\``, color: 0xa861ff, // Purple color image: { - url: ads_image, + url: config.config.ads_image, }, fields: [ { @@ -219,7 +219,7 @@ const MusicPlay: ServiceExecute = { }, { name: "Sponsor", - value: ads_text, + value: config.config.ads_text, inline: false, }, ],