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 { client } from "..";
import { RUNNER_ROLE_ID } from "../config.json";
import { ROLE_ID_RUNNER } from "../config.json";
const data = new SlashCommandBuilder()
.setName("clear")
.setDescription("Clears bot messages in this channel");
const permissions = [RUNNER_ROLE_ID];
const permissions = [ROLE_ID_RUNNER];
const execute = async (interaction) => {
await interaction.reply("Clearing messages...");

View File

@ -1,12 +1,12 @@
import { SlashCommandBuilder } from "discord.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()
.setName("end")
.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) => {
await interaction.reply("Moving members...");
@ -15,22 +15,22 @@ const execute = async (interaction) => {
const picking = findChannelfromCache(
interaction.guild.channels.cache,
"picking",
PICKING_ID
VOICE_ID_PICKING
);
const blu = findChannelfromCache(
interaction.guild.channels.cache,
"blu",
BLU_ID
VOICE_ID_BLU
);
const red = findChannelfromCache(
interaction.guild.channels.cache,
"red",
RED_ID
VOICE_ID_RED
);
if (!picking || !blu || !red) {
return console.error("Could not find all channels for /end");
}
// get members in voice channel
let members = blu.members.concat(red.members);
if (members.size === 0) {

View File

@ -1,5 +1,5 @@
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 path from "path";
@ -56,7 +56,7 @@ const data = new SlashCommandBuilder()
.setDescription("Player to protect from sitting out, intended for medic")
);
const permissions = [RUNNER_ROLE_ID];
const permissions = [ROLE_ID_RUNNER];
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
@ -64,10 +64,10 @@ const execute = async (interaction) => {
// get voice channels
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(
(channel) => channel.name === "picking" || channel.id === PICKING_ID
(channel) => channel.name === "picking" || channel.id === VOICE_ID_PICKING
);
// get members in voice channel

View File

@ -1,13 +1,13 @@
import { SlashCommandBuilder } from "discord.js";
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
const data = new SlashCommandBuilder()
.setName("fklist")
.setDescription("Pulls addup channel members into fk channel and lists them");
const permissions = [RUNNER_ROLE_ID];
const permissions = [ROLE_ID_RUNNER];
const synonyms = ["listfk"];
@ -18,12 +18,12 @@ const execute = async (interaction) => {
const picking = findChannelfromCache(
interaction.guild.channels.cache,
"picking",
PICKING_ID
VOICE_ID_PICKING
);
const fk = findChannelfromCache(
interaction.guild.channels.cache,
"fatkid",
FK_ID
VOICE_ID_FK
);
if (!picking || !fk) {
return console.error("Could not find all channels for /fklist");

View File

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

View File

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

View File

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

View File

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