Compare commits

...

2 commits

4 changed files with 45 additions and 4 deletions

View file

@ -21,6 +21,7 @@ import { commands } from "../commands";
import { BOT_ID, BOT_TOKEN } from "./config";
import { DeployCommandsProps } from "./types";
import Logger from "../utils/Logger";
import { BotClient } from "./client";
const logger = new Logger("Deployer");
@ -32,13 +33,15 @@ const rest = new REST({ version: "9" }).setToken(BOT_TOKEN);
export async function deployCommands({ guildId }: DeployCommandsProps) {
try {
logger.log("Started refreshing (/) commands.");
const guildName = BotClient.guilds.cache.get(guildId)?.name;
logger.log(`Started refreshing (/) commands for ${guildName}`);
await rest.put(Routes.applicationGuildCommands(BOT_ID, guildId), {
body: commandsData
});
logger.log("Successfully reloaded (/) commands.");
logger.log(`Successfully reloaded (/) commands for ${guildName}`);
} catch (err) {
logger.error(err);
}

View file

@ -54,6 +54,7 @@ export async function execute(interaction: ChatInputCommandInteraction) {
// TODO: This all works as intended, but I'd like for it so be a reusable function
// instead because all of this is used in src/main.ts
try {
// If the user is banned in this guild, don't let them post
if (dt.isBanned(interaction.guild?.id!, interaction.user.id)) {
return interaction.reply({
content: "You are banned from confessions in this server!",
@ -61,6 +62,7 @@ export async function execute(interaction: ChatInputCommandInteraction) {
});
}
// If no guild info is present for this guild, don't let the user post
if (!dt.getGuildInfo(interaction.guild?.id!)) {
return interaction.reply({
content:
@ -82,6 +84,15 @@ export async function execute(interaction: ChatInputCommandInteraction) {
const color = getRandomColor();
const messageId = StoreMan.genId();
// Looks like:
//
// |
// | Anonymous Confession a1b2
// |
// | "example confession content"
// |
//
const userConfessionEmbed = new EmbedBuilder()
.setColor(color)
.setTitle(`Anonymous Confession \`${messageId}\``)
@ -89,6 +100,20 @@ export async function execute(interaction: ChatInputCommandInteraction) {
isAttachment(attachment) && userConfessionEmbed.setImage(attachment);
// Looks like:
//
// |
// | Anonymous Confession a1b2
// |
// | "example confession content"
// |
// | Author
// | @user1
// |
// | Author ID
// | 1234567890
// |
//
const adminConfessionEmbed = new EmbedBuilder()
.setColor(color)
.setTitle(`Anonymous Confession \`${messageId}\``)
@ -148,6 +173,7 @@ export async function execute(interaction: ChatInputCommandInteraction) {
const confessionsLength = dt.getGuildInfo(interaction.guild?.id!)
?.confessions.length!;
// If there are 2 or more confessions, remove the previous confession's button components
if (confessionsLength >= 2) {
await (
BotClient.channels.cache.get(confessChannel!) as TextChannel

View file

@ -35,6 +35,15 @@ export async function execute(interaction: CommandInteraction) {
? "Banned Members:\n"
: "There are no banned members.";
// For each member, add them to the message content.
// It will end up looking something like this:
//
// Banned Members:
//
// @user1 | a1b2
// @user2 | c3d4
// @user3 | e5f6
//
for (const member of bannedMembers) {
content += `\n<@${member.user}> | \`${member.confessionId}\``;
}

View file

@ -18,7 +18,6 @@
import {
ChatInputCommandInteraction,
CommandInteraction,
EmbedBuilder,
SlashCommandBuilder,
TextChannel
@ -38,6 +37,8 @@ export const data = new SlashCommandBuilder()
);
export async function execute(interaction: ChatInputCommandInteraction) {
// If there is no guild info, don't let the user delete anything
if (!dt.getGuildInfo(interaction.guild?.id!)) {
return interaction.reply({
content:
@ -49,6 +50,8 @@ export async function execute(interaction: ChatInputCommandInteraction) {
const idVal = interaction.options.getString("id")!;
const result = dt.getConfession(interaction.guild?.id!, idVal);
// If a confession is found with the given ID, check if the user is the one that posted it, and delete it if they are.
// Otherwise, don't let the user delete anything.
if (result) {
try {
const confession = dt.getConfession(
@ -60,9 +63,9 @@ export async function execute(interaction: ChatInputCommandInteraction) {
const emptyEmbed = new EmbedBuilder()
.setColor(getRandomColor())
.setTitle("Confession Deleted")
// @ts-ignore
.setDescription("[Confession Deleted]");
// Replace the given confession with an empty embed
await (BotClient.channels.cache.get(channelId) as TextChannel).messages
.fetch(confession!)
.then(e => {