chore: improve config naming

This commit is contained in:
ethanf 2024-03-26 23:56:43 -05:00
parent 2bed3c07e9
commit 9feac9211f
8 changed files with 45 additions and 47 deletions

View File

@ -1,12 +1,12 @@
import { SlashCommandBuilder } from "discord.js"; import { SlashCommandBuilder } from "discord.js";
import { client } from ".."; import { client } from "..";
import { RUNNER_ROLE_ID } from "../config.json"; import { ROLE_ID_RUNNER } from "../config.json";
const data = new SlashCommandBuilder() const data = new SlashCommandBuilder()
.setName("clear") .setName("clear")
.setDescription("Clears bot messages in this channel"); .setDescription("Clears bot messages in this channel");
const permissions = [RUNNER_ROLE_ID]; const permissions = [ROLE_ID_RUNNER];
const execute = async (interaction) => { const execute = async (interaction) => {
await interaction.reply("Clearing messages..."); await interaction.reply("Clearing messages...");

View File

@ -1,12 +1,12 @@
import { SlashCommandBuilder } from "discord.js"; import { SlashCommandBuilder } from "discord.js";
import { findChannelfromCache } from "../utils.js"; import { findChannelfromCache } from "../utils.js";
import { RUNNER_ROLE_ID, PICKING_ID, BLU_ID, RED_ID } from "../config.json"; import { ROLE_ID_RUNNER, VOICE_ID_PICKING, VOICE_ID_BLU, VOICE_ID_RED } from "../config.json";
const data = new SlashCommandBuilder() const data = new SlashCommandBuilder()
.setName("end") .setName("end")
.setDescription("Moves the team channel members back to the picking channel"); .setDescription("Moves the team channel members back to the picking channel");
const permissions = [RUNNER_ROLE_ID]; const permissions = [ROLE_ID_RUNNER];
const execute = async (interaction) => { const execute = async (interaction) => {
await interaction.reply("Moving members..."); await interaction.reply("Moving members...");
@ -15,17 +15,17 @@ const execute = async (interaction) => {
const picking = findChannelfromCache( const picking = findChannelfromCache(
interaction.guild.channels.cache, interaction.guild.channels.cache,
"picking", "picking",
PICKING_ID VOICE_ID_PICKING
); );
const blu = findChannelfromCache( const blu = findChannelfromCache(
interaction.guild.channels.cache, interaction.guild.channels.cache,
"blu", "blu",
BLU_ID VOICE_ID_BLU
); );
const red = findChannelfromCache( const red = findChannelfromCache(
interaction.guild.channels.cache, interaction.guild.channels.cache,
"red", "red",
RED_ID VOICE_ID_RED
); );
if (!picking || !blu || !red) { if (!picking || !blu || !red) {
return console.error("Could not find all channels for /end"); return console.error("Could not find all channels for /end");

View File

@ -1,5 +1,5 @@
import { SlashCommandBuilder } from "discord.js"; import { SlashCommandBuilder } from "discord.js";
import { RUNNER_ROLE_ID, ADDUP_ID, PICKING_ID } from "../config.json"; import { ROLE_ID_RUNNER, VOICE_ID_ADDUP, VOICE_ID_PICKING } from "../config.json";
import fs from "fs"; import fs from "fs";
import path from "path"; import path from "path";
@ -56,7 +56,7 @@ const data = new SlashCommandBuilder()
.setDescription("Player to protect from sitting out, intended for medic") .setDescription("Player to protect from sitting out, intended for medic")
); );
const permissions = [RUNNER_ROLE_ID]; const permissions = [ROLE_ID_RUNNER];
const execute = async (interaction) => { const execute = async (interaction) => {
// pull users in addup into picking, then randomly select other users in picking to be sat out until there are 18 in picking // pull users in addup into picking, then randomly select other users in picking to be sat out until there are 18 in picking
@ -64,10 +64,10 @@ const execute = async (interaction) => {
// get voice channels // get voice channels
const addup = interaction.guild.channels.cache.find( const addup = interaction.guild.channels.cache.find(
(channel) => channel.name === "add-up" || channel.id === ADDUP_ID (channel) => channel.name === "add-up" || channel.id === VOICE_ID_ADDUP
); );
const picking = interaction.guild.channels.cache.find( const picking = interaction.guild.channels.cache.find(
(channel) => channel.name === "picking" || channel.id === PICKING_ID (channel) => channel.name === "picking" || channel.id === VOICE_ID_PICKING
); );
// get members in voice channel // get members in voice channel

View File

@ -1,13 +1,13 @@
import { SlashCommandBuilder } from "discord.js"; import { SlashCommandBuilder } from "discord.js";
import { findChannelfromCache, findPlayer, getApplicableName } from "../utils"; import { findChannelfromCache, findPlayer, getApplicableName } from "../utils";
import { RUNNER_ROLE_ID, PICKING_ID, FK_ID } from "../config.json"; import { ROLE_ID_RUNNER, VOICE_ID_PICKING, VOICE_ID_FK } from "../config.json";
// not really used since fks are now determined randomly // not really used since fks are now determined randomly
const data = new SlashCommandBuilder() const data = new SlashCommandBuilder()
.setName("fklist") .setName("fklist")
.setDescription("Pulls addup channel members into fk channel and lists them"); .setDescription("Pulls addup channel members into fk channel and lists them");
const permissions = [RUNNER_ROLE_ID]; const permissions = [ROLE_ID_RUNNER];
const synonyms = ["listfk"]; const synonyms = ["listfk"];
@ -18,12 +18,12 @@ const execute = async (interaction) => {
const picking = findChannelfromCache( const picking = findChannelfromCache(
interaction.guild.channels.cache, interaction.guild.channels.cache,
"picking", "picking",
PICKING_ID VOICE_ID_PICKING
); );
const fk = findChannelfromCache( const fk = findChannelfromCache(
interaction.guild.channels.cache, interaction.guild.channels.cache,
"fatkid", "fatkid",
FK_ID VOICE_ID_FK
); );
if (!picking || !fk) { if (!picking || !fk) {
return console.error("Could not find all channels for /fklist"); return console.error("Could not find all channels for /fklist");

View File

@ -1,11 +1,11 @@
import { SlashCommandBuilder } from "discord.js"; import { SlashCommandBuilder } from "discord.js";
import { RUNNER_ROLE_ID } from "../config.json"; import { ROLE_ID_RUNNER } from "../config.json";
const data = new SlashCommandBuilder() const data = new SlashCommandBuilder()
.setName("hello") .setName("hello")
.setDescription("Replies 'world'"); .setDescription("Replies 'world'");
const permissions = [RUNNER_ROLE_ID]; const permissions = [ROLE_ID_RUNNER];
const execute = async (interaction) => { const execute = async (interaction) => {
await interaction.reply("world"); await interaction.reply("world");

View File

@ -1,5 +1,5 @@
import { SlashCommandBuilder } from "discord.js"; import { SlashCommandBuilder } from "discord.js";
import { PLAYER_ROLE_ID } from "../config.json"; import { ROLE_ID_PLAYER } from "../config.json";
const data = new SlashCommandBuilder() const data = new SlashCommandBuilder()
.setName("roll") .setName("roll")
@ -12,7 +12,7 @@ const data = new SlashCommandBuilder()
.setMinValue(1) .setMinValue(1)
); );
const permissions = [PLAYER_ROLE_ID]; const permissions = [ROLE_ID_PLAYER];
const execute = async (interaction) => { const execute = async (interaction) => {
const max = interaction.options.getInteger("max"); const max = interaction.options.getInteger("max");

View File

@ -1,15 +1,15 @@
{ {
"TOKEN": "redacted", "TOKEN": "redacted",
"CLIENT_ID": "1177748390092742767",
"GUILD_ID": "1175646363707523132", "GUILD_ID": "1175646363707523132",
"PLAYER_ROLE_ID": "1175646999140384778", "USER_ID_CLIENT": "1177748390092742767",
"RUNNER_ROLE_ID": "1175646976235282452", "USER_ID_DEBUG": "233036215610245120",
"COMMAND_CHANNEL_ID": "1177469184192565288", "ROLE_ID_PLAYER": "1175646999140384778",
"ADDUP_ID": "1175649994674544721", "ROLE_ID_RUNNER": "1175646976235282452",
"PICKING_ID": "1175649967935856680", "TEXT_ID_COMMAND": "1177469184192565288",
"BLU_ID": "1175649793943552010", "VOICE_ID_ADDUP": "1175649994674544721",
"RED_ID": "1175649777648680971", "VOICE_ID_PICKING": "1175649967935856680",
"FK_ID": "1176396207183106078", "VOICE_ID_BLU": "1175649793943552010",
"CAPTAIN_ID": "1178475124563919018", "VOICE_ID_RED": "1175649777648680971",
"VOICE_ID_FK": "1176396207183106078",
"RANKING_WHITELIST": "233036215610245120" "RANKING_WHITELIST": "233036215610245120"
} }

View File

@ -5,13 +5,11 @@ import { getApplicableName, findPlayer } from "./utils.js";
const { const {
TOKEN, TOKEN,
GUILD_ID, GUILD_ID,
RUNNER_ROLE_ID, USER_ID_DEBUG,
COMMAND_CHANNEL_ID, TEXT_ID_COMMAND,
PICKING_ID, VOICE_ID_PICKING,
BLU_ID, VOICE_ID_BLU,
RED_ID, VOICE_ID_RED,
FK_ID,
CAPTAIN_ID,
} = require("./config.json"); } = require("./config.json");
let whitelistStr = require("./config.json").RANKING_WHITELIST; let whitelistStr = require("./config.json").RANKING_WHITELIST;
@ -176,9 +174,9 @@ const balanceArrays = (a1, a2) => {
client.on("ready", () => { client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`); console.log(`Logged in as ${client.user.tag}!`);
console.log( console.log(
`Deleting old messages from this bot in command channel: ${COMMAND_CHANNEL_ID}...` `Deleting old messages from this bot in command channel: ${TEXT_ID_COMMAND}...`
); );
let channel = client.channels.cache.get(COMMAND_CHANNEL_ID); let channel = client.channels.cache.get(TEXT_ID_COMMAND);
if (!channel) return console.error("(ready) Can't find command channel"); if (!channel) return console.error("(ready) Can't find command channel");
channel.messages channel.messages
.fetch({ limit: 100 }) .fetch({ limit: 100 })
@ -195,10 +193,10 @@ client.on("ready", () => {
// send message on error // send message on error
client.on("error", (error) => { client.on("error", (error) => {
console.error(error); console.error(error);
let channel = client.channels.cache.get(COMMAND_CHANNEL_ID); let channel = client.channels.cache.get(TEXT_ID_COMMAND);
if (!channel) return console.error("Can't find command channel"); if (!channel) return console.error("Can't find command channel");
client.channels.cache client.channels.cache
.get(COMMAND_CHANNEL_ID) .get(TEXT_ID_COMMAND)
.send(`Internal error: ${error.message}`) .send(`Internal error: ${error.message}`)
.catch(console.error); .catch(console.error);
}); });
@ -213,7 +211,7 @@ client.on("interactionCreate", async (interaction) => {
if (fileCommand.permissions) { if (fileCommand.permissions) {
const member = interaction.member; const member = interaction.member;
for (const permission of fileCommand.permissions) { for (const permission of fileCommand.permissions) {
if (!member.roles.cache.has(permission) && member.id !== DEBUG_ADMIN_ID) { if (!member.roles.cache.has(permission) && member.id !== USER_ID_DEBUG) {
await interaction.reply({ await interaction.reply({
content: "You lack the required permissions", content: "You lack the required permissions",
ephemeral: true, ephemeral: true,
@ -230,8 +228,8 @@ client.on("interactionCreate", async (interaction) => {
ephemeral: true, ephemeral: true,
}); });
} }
} else if (interaction.channelId !== COMMAND_CHANNEL_ID) { } else if (interaction.channelId !== TEXT_ID_COMMAND) {
//let isRunner = await interaction.member.roles.cache.has(RUNNER_ROLE_ID); //let isRunner = await interaction.member.roles.cache.has(ROLE_ID_RUNNER);
//if (!isRunner) { //if (!isRunner) {
await interaction.reply({ await interaction.reply({
content: "Wrong channel, or you lack the required permissions", content: "Wrong channel, or you lack the required permissions",
@ -245,15 +243,15 @@ client.on("interactionCreate", async (interaction) => {
// get voice channels // get voice channels
const picking = interaction.guild.channels.cache.find( const picking = interaction.guild.channels.cache.find(
(channel) => channel.name === "picking" || channel.id === PICKING_ID (channel) => channel.name === "picking" || channel.id === VOICE_ID_PICKING
); );
if (!picking) return console.error("Can't find channel 'picking'!"); if (!picking) return console.error("Can't find channel 'picking'!");
const blu = interaction.guild.channels.cache.find( const blu = interaction.guild.channels.cache.find(
(channel) => channel.name === "blu" || channel.id === BLU_ID (channel) => channel.name === "blu" || channel.id === VOICE_ID_BLU
); );
if (!blu) return console.error("Can't find channel 'blu'!"); if (!blu) return console.error("Can't find channel 'blu'!");
const red = interaction.guild.channels.cache.find( const red = interaction.guild.channels.cache.find(
(channel) => channel.name === "red" || channel.id === RED_ID (channel) => channel.name === "red" || channel.id === VOICE_ID_RED
); );
if (!red) return console.error("Can't find channel 'red'!"); if (!red) return console.error("Can't find channel 'red'!");