From 949a08956abb226355ccbb90a7f902fd62c886f0 Mon Sep 17 00:00:00 2001 From: ethanf Date: Sat, 25 Nov 2023 13:28:11 -0600 Subject: [PATCH] refactor: channel ids moved + add tokenless config --- config.json | 10 ++++++++++ index.js | 22 +++++++++------------- register.js | 2 +- 3 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 config.json diff --git a/config.json b/config.json new file mode 100644 index 0000000..0b428eb --- /dev/null +++ b/config.json @@ -0,0 +1,10 @@ +{ + "TOKEN": "redacted", + "CLIENT_ID": "1177748390092742767", + "GUILD_ID": "658490352189046784", + "COMMAND_CHANNEL_ID": "1177469184192565288", + "ADDUP_ID": "1175649994674544721", + "BLU_ID": "1175649793943552010", + "RED_ID": "1175649777648680971", + "FK_ID": "1176396207183106078" +} \ No newline at end of file diff --git a/index.js b/index.js index 3418d72..b1a251f 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ import { Client, GatewayIntentBits } from "discord.js"; -const { token } = require("./config.json"); +const { TOKEN, COMMAND_CHANNEL_ID, ADDUP_ID, BLU_ID, RED_ID, FK_ID } = require("./config.json"); + const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates], }); @@ -11,7 +12,7 @@ client.on("ready", () => { client.on("interactionCreate", async (interaction) => { if (!interaction.isChatInputCommand()) return; - if (interaction.channelId !== "1177469184192565288") { + if (interaction.channelId !== COMMAND_CHANNEL_ID) { await interaction.reply({ content: "wrong channel, or you lack the required permissions", ephemeral: true, @@ -31,18 +32,15 @@ client.on("interactionCreate", async (interaction) => { // get voice channels const blu = interaction.guild.channels.cache.find( - (channel) => - channel.name === "blu" || channel.id === "1175649793943552010" + (channel) => channel.name === "blu" || channel.id === BLU_ID ); if (!blu) return console.error("Can't find channel 'blu'!"); const red = interaction.guild.channels.cache.find( - (channel) => - channel.name === "red" || channel.id === "1175649777648680971" + (channel) => channel.name === "red" || channel.id === RED_ID ); if (!red) return console.error("Can't find channel 'red'!"); const addup = interaction.guild.channels.cache.find( - (channel) => - channel.name === "add-up" || channel.id === "1175649994674544721" + (channel) => channel.name === "add-up" || channel.id === ADDUP_ID ); if (!addup) return console.error("Can't find channel 'add-up'!"); @@ -86,13 +84,11 @@ client.on("interactionCreate", async (interaction) => { // get voice channels const addup = interaction.guild.channels.cache.find( - (channel) => - channel.name === "add-up" || channel.id === "1175649994674544721" + (channel) => channel.name === "add-up" || channel.id === ADDUP_ID ); if (!addup) return console.error("Can't find channel 'add-up'!"); const fk = interaction.guild.channels.cache.find( - (channel) => - channel.name === "fatkid" || channel.id === "1176396207183106078" + (channel) => channel.name === "fatkid" || channel.id === FK_ID ); if (!fk) return console.error("Can't find channel 'fatkid'!"); @@ -131,4 +127,4 @@ client.on("interactionCreate", async (interaction) => { } }); -client.login(token); +client.login(TOKEN); diff --git a/register.js b/register.js index 2f99504..de0ea14 100644 --- a/register.js +++ b/register.js @@ -1,5 +1,5 @@ import { REST, Routes } from "discord.js"; -const { token, client_id, guild_id } = require("./config.json"); +const { token, client_id } = require("./config.json"); const commands = [ {