Use a constant
This commit is contained in:
parent
a2279ef93c
commit
e89e674aa2
|
@ -30,6 +30,7 @@ import { dt } from "../main";
|
||||||
import { StoreMan } from "../storeman";
|
import { StoreMan } from "../storeman";
|
||||||
import getRandomColor from "../utils/getRandomColor";
|
import getRandomColor from "../utils/getRandomColor";
|
||||||
import Logger from "../utils/Logger";
|
import Logger from "../utils/Logger";
|
||||||
|
import { messageOpts } from "../constants";
|
||||||
|
|
||||||
const logger = new Logger("(/) confess");
|
const logger = new Logger("(/) confess");
|
||||||
|
|
||||||
|
@ -60,7 +61,7 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
if (dt.isBannedByUser(guildId, userId)) {
|
if (dt.isBannedByUser(guildId, userId)) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "You are banned from confessions in this server!",
|
content: "You are banned from confessions in this server!",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +70,7 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content:
|
content:
|
||||||
"The bot hasn't been set up yet! Ask the server admins to set it up.",
|
"The bot hasn't been set up yet! Ask the server admins to set it up.",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +186,7 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
|
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "Confession sent!",
|
content: "Confession sent!",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error("An error occured:", err);
|
logger.error("An error occured:", err);
|
||||||
|
|
|
@ -27,6 +27,7 @@ import { dt } from "../main";
|
||||||
import { BotClient } from "../bot";
|
import { BotClient } from "../bot";
|
||||||
import getRandomColor from "../utils/getRandomColor";
|
import getRandomColor from "../utils/getRandomColor";
|
||||||
import Logger from "../utils/Logger";
|
import Logger from "../utils/Logger";
|
||||||
|
import { messageOpts } from "../constants";
|
||||||
|
|
||||||
const logger = new Logger("(/) confessdel");
|
const logger = new Logger("(/) confessdel");
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content:
|
content:
|
||||||
"The bot hasn't been set up yet! Ask the server admins to set it up.",
|
"The bot hasn't been set up yet! Ask the server admins to set it up.",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,13 +85,13 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
|
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "Confession removed.",
|
content: "Confession removed.",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error("A confession delete error occured:", err);
|
logger.error("A confession delete error occured:", err);
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "An error occured.",
|
content: "An error occured.",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -99,18 +100,18 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
return result
|
return result
|
||||||
? interaction.reply({
|
? interaction.reply({
|
||||||
content: "You are not allowed to remove this confession.",
|
content: "You are not allowed to remove this confession.",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
})
|
})
|
||||||
: interaction.reply({
|
: interaction.reply({
|
||||||
content:
|
content:
|
||||||
"Either the confession wasn't found or you may not be allowed to remove it.",
|
"Either the confession wasn't found or you may not be allowed to remove it.",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error("A confession delete interaction occured:", err);
|
logger.error("A confession delete interaction occured:", err);
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "An error occured.",
|
content: "An error occured.",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import {
|
||||||
import { dt } from "../main";
|
import { dt } from "../main";
|
||||||
import Logger from "../utils/Logger";
|
import Logger from "../utils/Logger";
|
||||||
import { BanReason } from "../storeman";
|
import { BanReason } from "../storeman";
|
||||||
|
import { messageOpts } from "../constants";
|
||||||
|
|
||||||
const logger = new Logger("(/) confessban");
|
const logger = new Logger("(/) confessban");
|
||||||
|
|
||||||
|
@ -95,7 +96,7 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
try {
|
try {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "That user is already banned!",
|
content: "That user is already banned!",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error("A ban interaction error occured:", err);
|
logger.error("A ban interaction error occured:", err);
|
||||||
|
@ -108,11 +109,11 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
return result
|
return result
|
||||||
? interaction.reply({
|
? interaction.reply({
|
||||||
content: "User was banned.",
|
content: "User was banned.",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
})
|
})
|
||||||
: interaction.reply({
|
: interaction.reply({
|
||||||
content: "No confession with that ID was found.",
|
content: "No confession with that ID was found.",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error("A ban interaction error occured:", err);
|
logger.error("A ban interaction error occured:", err);
|
||||||
|
@ -127,11 +128,11 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
return result
|
return result
|
||||||
? interaction.reply({
|
? interaction.reply({
|
||||||
content: "User was banned.",
|
content: "User was banned.",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
})
|
})
|
||||||
: interaction.reply({
|
: interaction.reply({
|
||||||
content: "How did we get here? (An error occured.)}",
|
content: "How did we get here? (An error occured.)}",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error("A banuser interaction error occured:", err);
|
logger.error("A banuser interaction error occured:", err);
|
||||||
|
@ -172,13 +173,13 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
try {
|
try {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: determineContent(),
|
content: determineContent(),
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error("A banlist interaction error occured:", err);
|
logger.error("A banlist interaction error occured:", err);
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "A server-side error occurred when getting the ban list.",
|
content: "A server-side error occurred when getting the ban list.",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// /confessmod pardon <id>
|
// /confessmod pardon <id>
|
||||||
|
@ -189,11 +190,11 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
return result
|
return result
|
||||||
? interaction.reply({
|
? interaction.reply({
|
||||||
content: "User was unbanned.",
|
content: "User was unbanned.",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
})
|
})
|
||||||
: interaction.reply({
|
: interaction.reply({
|
||||||
content: "No confession with that ID was found.",
|
content: "No confession with that ID was found.",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error("An unban interaction error occured:", err);
|
logger.error("An unban interaction error occured:", err);
|
||||||
|
@ -207,11 +208,11 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
return result
|
return result
|
||||||
? interaction.reply({
|
? interaction.reply({
|
||||||
content: "User was unbanned.",
|
content: "User was unbanned.",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
})
|
})
|
||||||
: interaction.reply({
|
: interaction.reply({
|
||||||
content: "That user is not banned from confessions.",
|
content: "That user is not banned from confessions.",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error("An unban user interaction error occured:", err);
|
logger.error("An unban user interaction error occured:", err);
|
||||||
|
@ -220,6 +221,6 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
|
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "Unknown error",
|
content: "Unknown error",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import {
|
||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
import { dt } from "../main";
|
import { dt } from "../main";
|
||||||
import Logger from "../utils/Logger";
|
import Logger from "../utils/Logger";
|
||||||
|
import { messageOpts } from "../constants";
|
||||||
|
|
||||||
const logger = new Logger("(/) setup");
|
const logger = new Logger("(/) setup");
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ export async function execute(interaction: CommandInteraction) {
|
||||||
if (dt.checkSetup(guildId)) {
|
if (dt.checkSetup(guildId)) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "This guild has already been set up!",
|
content: "This guild has already been set up!",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +71,7 @@ export async function execute(interaction: CommandInteraction) {
|
||||||
try {
|
try {
|
||||||
const response = await interaction.reply({
|
const response = await interaction.reply({
|
||||||
content: `# Let's get started, ${username}!\nFirst, let's choose a channel for your confessions.`,
|
content: `# Let's get started, ${username}!\nFirst, let's choose a channel for your confessions.`,
|
||||||
ephemeral: true,
|
...messageOpts,
|
||||||
components: [channelRow]
|
components: [channelRow]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -101,7 +102,7 @@ export async function execute(interaction: CommandInteraction) {
|
||||||
|
|
||||||
const logResponse = await interaction.followUp({
|
const logResponse = await interaction.followUp({
|
||||||
content: "# Now, select a logging channel, for moderation purposes.",
|
content: "# Now, select a logging channel, for moderation purposes.",
|
||||||
ephemeral: true,
|
...messageOpts,
|
||||||
components: [logChannelRow, buttonRow]
|
components: [logChannelRow, buttonRow]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -159,7 +160,7 @@ export async function execute(interaction: CommandInteraction) {
|
||||||
!skipped &&
|
!skipped &&
|
||||||
interaction.followUp({
|
interaction.followUp({
|
||||||
content: "No channel selected. Please try again.",
|
content: "No channel selected. Please try again.",
|
||||||
ephemeral: true,
|
...messageOpts,
|
||||||
components: []
|
components: []
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -170,7 +171,7 @@ export async function execute(interaction: CommandInteraction) {
|
||||||
!collected.size &&
|
!collected.size &&
|
||||||
interaction.followUp({
|
interaction.followUp({
|
||||||
content: "No channel selected. Try again.",
|
content: "No channel selected. Try again.",
|
||||||
ephemeral: true,
|
...messageOpts,
|
||||||
components: []
|
components: []
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -23,6 +23,7 @@ import {
|
||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
import { deployCommands } from "../bot";
|
import { deployCommands } from "../bot";
|
||||||
import Logger from "../utils/Logger";
|
import Logger from "../utils/Logger";
|
||||||
|
import { messageOpts } from "../constants";
|
||||||
|
|
||||||
const logger = new Logger("(/) update");
|
const logger = new Logger("(/) update");
|
||||||
const minutes = 5;
|
const minutes = 5;
|
||||||
|
@ -39,7 +40,7 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
if (cooldownList.has(guildId)) {
|
if (cooldownList.has(guildId)) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: `You can only run the update command once every ${minutes} minutes.`,
|
content: `You can only run the update command once every ${minutes} minutes.`,
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +59,6 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
|
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "Commands refreshed.",
|
content: "Commands refreshed.",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
3
src/constants.ts
Normal file
3
src/constants.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export const messageOpts = {
|
||||||
|
ephemeral: true
|
||||||
|
}
|
|
@ -31,6 +31,7 @@ import { StoreMan } from "./storeman";
|
||||||
import Logger from "./utils/Logger";
|
import Logger from "./utils/Logger";
|
||||||
import getRandomColor from "./utils/getRandomColor";
|
import getRandomColor from "./utils/getRandomColor";
|
||||||
import { submit } from "./modals";
|
import { submit } from "./modals";
|
||||||
|
import { messageOpts } from "./constants";
|
||||||
|
|
||||||
export const dt = new StoreMan(StoreMan.checkFile());
|
export const dt = new StoreMan(StoreMan.checkFile());
|
||||||
const logger = new Logger("Main");
|
const logger = new Logger("Main");
|
||||||
|
@ -100,7 +101,7 @@ BotClient.on(Events.InteractionCreate, async interaction => {
|
||||||
dt.isBannedByUser(interaction.guild?.id!, interaction.user.id)
|
dt.isBannedByUser(interaction.guild?.id!, interaction.user.id)
|
||||||
? interaction.reply({
|
? interaction.reply({
|
||||||
content: "You are banned from confessions in this server!",
|
content: "You are banned from confessions in this server!",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
})
|
})
|
||||||
: interaction.showModal(submit);
|
: interaction.showModal(submit);
|
||||||
}
|
}
|
||||||
|
@ -121,7 +122,7 @@ BotClient.on(Events.InteractionCreate, async interaction => {
|
||||||
if (dt.isBannedByUser(interaction.guild?.id!, interaction.user.id)) {
|
if (dt.isBannedByUser(interaction.guild?.id!, interaction.user.id)) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "You are banned from confessions in this server!",
|
content: "You are banned from confessions in this server!",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +130,7 @@ BotClient.on(Events.InteractionCreate, async interaction => {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content:
|
content:
|
||||||
"The bot hasn't been set up yet! Ask the server admins to set it up.",
|
"The bot hasn't been set up yet! Ask the server admins to set it up.",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +219,7 @@ BotClient.on(Events.InteractionCreate, async interaction => {
|
||||||
|
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "Confession sent!",
|
content: "Confession sent!",
|
||||||
ephemeral: true
|
...messageOpts
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error("An error occured:", err);
|
logger.error("An error occured:", err);
|
||||||
|
|
Loading…
Reference in a new issue