From 6f8435b699bbb3a9af87e14f7eb3b9d75fcf0741 Mon Sep 17 00:00:00 2001 From: powermaker450 Date: Sat, 12 Oct 2024 18:51:09 -0400 Subject: [PATCH] Prettier --- src/bot/client.ts | 2 +- src/bot/config.ts | 2 +- src/bot/deploy-commands.ts | 2 +- src/bot/index.ts | 2 +- src/bot/types.ts | 2 +- src/commands/confess.ts | 40 +++++++++++++++-------------- src/commands/confessban.ts | 18 ++++++++------ src/commands/confessdel.ts | 47 +++++++++++++++++++++-------------- src/commands/confesspardon.ts | 20 +++++++++------ src/commands/index.ts | 2 +- src/commands/ping.ts | 2 +- src/commands/setup.ts | 4 +-- src/environment.d.ts | 2 +- src/main.ts | 2 +- src/storeman/client.ts | 35 ++++++++++++++++++-------- src/storeman/config.ts | 2 +- src/storeman/index.ts | 2 +- src/storeman/types.ts | 2 +- src/utils/Logger.ts | 2 +- src/utils/config.ts | 2 +- src/utils/getRandomColor.ts | 4 +-- 21 files changed, 116 insertions(+), 80 deletions(-) diff --git a/src/bot/client.ts b/src/bot/client.ts index 7c66fae..d377bfb 100644 --- a/src/bot/client.ts +++ b/src/bot/client.ts @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ import { Client } from "discord.js"; diff --git a/src/bot/config.ts b/src/bot/config.ts index 0f948a2..992ec11 100644 --- a/src/bot/config.ts +++ b/src/bot/config.ts @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ import dotenv from "dotenv"; import Logger from "../utils/Logger"; diff --git a/src/bot/deploy-commands.ts b/src/bot/deploy-commands.ts index aef6b0a..a075504 100644 --- a/src/bot/deploy-commands.ts +++ b/src/bot/deploy-commands.ts @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ import { REST, Routes } from "discord.js"; import { commands } from "../commands"; diff --git a/src/bot/index.ts b/src/bot/index.ts index 330c064..3e06a15 100644 --- a/src/bot/index.ts +++ b/src/bot/index.ts @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ export * from "./client"; export * from "./config"; diff --git a/src/bot/types.ts b/src/bot/types.ts index ac6747f..cb8fc4b 100644 --- a/src/bot/types.ts +++ b/src/bot/types.ts @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ export type DeployCommandsProps = { guildId: string; diff --git a/src/commands/confess.ts b/src/commands/confess.ts index efa3b8e..8be03c8 100644 --- a/src/commands/confess.ts +++ b/src/commands/confess.ts @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ import { CommandInteraction, @@ -33,7 +33,7 @@ const logger = new Logger("(/) confess"); export const data = new SlashCommandBuilder() .setName("confess") .setDescription("Send a confession") - .addStringOption(option => + .addStringOption((option) => option .setName("message") .setRequired(true) @@ -45,7 +45,7 @@ export async function execute(interaction: CommandInteraction) { if (dt.isBanned(interaction.guild?.id!, interaction.user.id)) { return interaction.reply({ content: "You are banned from confessions in this server!", - ephemeral: true + ephemeral: true, }); } @@ -57,7 +57,6 @@ export async function execute(interaction: CommandInteraction) { }); } - const confessChannel = dt.getGuildInfo(interaction.guild?.id!)?.settings .confessChannel; const adminChannel = dt.getGuildInfo(interaction.guild?.id!)?.settings @@ -72,35 +71,40 @@ export async function execute(interaction: CommandInteraction) { .setTitle(`Anonymous Confession \`${messageId}\``) // @ts-ignore .setDescription(messageContent); - + const adminConfessionEmbed = new EmbedBuilder() .setColor(color) .setTitle(`Anonymous Confession \`${messageId}\``) // @ts-ignore .setDescription(messageContent) - .addFields({ + .addFields( + { name: "Author", - value: interaction.user.displayName + value: interaction.user.displayName, }, { name: "Author ID", - value: interaction.user.id - } + value: interaction.user.id, + }, ); const message = await ( BotClient.channels.cache.get(confessChannel!) as TextChannel - ) - .send({ - embeds: [userConfessionEmbed] - }); + ).send({ + embeds: [userConfessionEmbed], + }); - await (BotClient.channels.cache.get(adminChannel!) as TextChannel) - .send({ - embeds: [adminConfessionEmbed] - }); + await (BotClient.channels.cache.get(adminChannel!) as TextChannel).send({ + embeds: [adminConfessionEmbed], + }); - dt.addConfession(message, messageId, interaction.user.displayName, interaction.user.id, messageContent); + dt.addConfession( + message, + messageId, + interaction.user.displayName, + interaction.user.id, + messageContent, + ); return interaction.reply({ content: "Confession sent!", diff --git a/src/commands/confessban.ts b/src/commands/confessban.ts index f881519..af6bc1f 100644 --- a/src/commands/confessban.ts +++ b/src/commands/confessban.ts @@ -14,9 +14,13 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ -import { CommandInteraction, PermissionFlagsBits, SlashCommandBuilder } from "discord.js"; +import { + CommandInteraction, + PermissionFlagsBits, + SlashCommandBuilder, +} from "discord.js"; import { dt } from "../main"; import Logger from "../utils/Logger"; @@ -25,11 +29,11 @@ const logger = new Logger("(/) confessban"); export const data = new SlashCommandBuilder() .setName("confessban") .setDescription("Ban a user from submitting confessions.") - .addStringOption(option => + .addStringOption((option) => option .setName("id") .setDescription("The confession ID to ban") - .setRequired(true) + .setRequired(true), ) .setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers); @@ -37,18 +41,18 @@ export async function execute(interaction: CommandInteraction) { const result = dt.addBan( interaction.guild?.id!, // @ts-ignore - interaction.options.getString("id") + interaction.options.getString("id"), ); try { return result ? interaction.reply({ content: "User was banned.", - ephemeral: true + ephemeral: true, }) : interaction.reply({ content: "No confession with that ID was found.", - ephemeral: true + ephemeral: true, }); } catch (err) { logger.error("An error occured:", err); diff --git a/src/commands/confessdel.ts b/src/commands/confessdel.ts index 0259cdc..8359723 100644 --- a/src/commands/confessdel.ts +++ b/src/commands/confessdel.ts @@ -14,9 +14,14 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ -import { CommandInteraction, EmbedBuilder, SlashCommandBuilder, TextChannel } from "discord.js"; +import { + CommandInteraction, + EmbedBuilder, + SlashCommandBuilder, + TextChannel, +} from "discord.js"; import { dt } from "../main"; import { BotClient } from "../bot"; import getRandomColor from "../utils/getRandomColor"; @@ -27,12 +32,9 @@ const logger = new Logger("(/) confessdel"); export const data = new SlashCommandBuilder() .setName("confessdel") .setDescription("Deletes a confession") - .addStringOption(option => - option - .setName("id") - .setDescription("The confession id") - .setRequired(true) - ) + .addStringOption((option) => + option.setName("id").setDescription("The confession id").setRequired(true), + ); export async function execute(interaction: CommandInteraction) { if (!dt.getGuildInfo(interaction.guild?.id!)) { @@ -42,40 +44,47 @@ export async function execute(interaction: CommandInteraction) { ephemeral: true, }); } - + // @ts-ignore const idVal = interaction.options.getString("id"); const result = dt.getConfession(interaction.guild?.id!, idVal); if (result) { try { - const confession = dt.getConfession(interaction.guild?.id!, idVal)?.messageId; - const channelId = dt.getGuildInfo(interaction.guild?.id!)?.settings.confessChannel!; + const confession = dt.getConfession( + interaction.guild?.id!, + idVal, + )?.messageId; + const channelId = dt.getGuildInfo(interaction.guild?.id!)?.settings + .confessChannel!; const emptyEmbed = new EmbedBuilder() .setColor(getRandomColor()) .setTitle("Confession Deleted") // @ts-ignore .setDescription("[Confession Deleted]"); - await (BotClient.channels.cache.get(channelId) as TextChannel).messages.fetch(confession!).then(e => { - e.edit({ - embeds: [emptyEmbed] - }) - }); + await (BotClient.channels.cache.get(channelId) as TextChannel).messages + .fetch(confession!) + .then((e) => { + e.edit({ + embeds: [emptyEmbed], + }); + }); dt.delConfesssion(interaction, idVal); return interaction.reply({ content: "Confession removed.", - ephemeral: true + ephemeral: true, }); } catch (err) { logger.error("An error occured:", err); } } else { return interaction.reply({ - content: "Either the confession wasn't found or you may not be allowed to remove it.", - ephemeral: true + content: + "Either the confession wasn't found or you may not be allowed to remove it.", + ephemeral: true, }); } } diff --git a/src/commands/confesspardon.ts b/src/commands/confesspardon.ts index b945c3b..0c15f14 100644 --- a/src/commands/confesspardon.ts +++ b/src/commands/confesspardon.ts @@ -14,9 +14,13 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ -import { CommandInteraction, PermissionFlagsBits, SlashCommandBuilder } from "discord.js"; +import { + CommandInteraction, + PermissionFlagsBits, + SlashCommandBuilder, +} from "discord.js"; import { dt } from "../main"; import Logger from "../utils/Logger"; @@ -25,30 +29,30 @@ const logger = new Logger("(/) confesspardon"); export const data = new SlashCommandBuilder() .setName("confesspardon") .setDescription("Unbans a user from confessions") - .addStringOption(option => + .addStringOption((option) => option .setName("id") .setDescription("The confession ID to unban") - .setRequired(true) + .setRequired(true), ) - .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages); export function execute(interaction: CommandInteraction) { const result = dt.removeBan( interaction.guild?.id!, // @ts-ignore - interaction.options.getString("id") + interaction.options.getString("id"), ); try { return result ? interaction.reply({ content: "User was unbanned.", - ephemeral: true + ephemeral: true, }) : interaction.reply({ content: "No confession with that ID was found.", - ephemeral: true + ephemeral: true, }); } catch (err) { logger.error("An error occured:", err); diff --git a/src/commands/index.ts b/src/commands/index.ts index ac8a054..b89843e 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ import * as confess from "./confess"; import * as confessdel from "./confessdel"; diff --git a/src/commands/ping.ts b/src/commands/ping.ts index a954f5d..0fa4f67 100644 --- a/src/commands/ping.ts +++ b/src/commands/ping.ts @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ import { CommandInteraction, SlashCommandBuilder } from "discord.js"; diff --git a/src/commands/setup.ts b/src/commands/setup.ts index dfd0cad..b7cf26c 100644 --- a/src/commands/setup.ts +++ b/src/commands/setup.ts @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ import { ActionRowBuilder, @@ -131,7 +131,7 @@ export async function execute(interaction: CommandInteraction) { interaction.followUp({ content: "No channel selected. Try again.", ephemeral: true, - components: [] + components: [], }); }); } catch (err) { diff --git a/src/environment.d.ts b/src/environment.d.ts index f1e9408..726aecc 100644 --- a/src/environment.d.ts +++ b/src/environment.d.ts @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ declare global { namespace NodeJS { diff --git a/src/main.ts b/src/main.ts index 237372a..d5e867c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ import { BotClient, BOT_TOKEN, deployCommands } from "./bot"; import { commands } from "./commands"; diff --git a/src/storeman/client.ts b/src/storeman/client.ts index 0b21250..3bc7e29 100644 --- a/src/storeman/client.ts +++ b/src/storeman/client.ts @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ import fs from "fs"; import crypto from "crypto"; @@ -38,14 +38,14 @@ export class StoreMan { id: string, author: string, authorId: string, - content: string + content: string, ): Confession { return { id: id, messageId: message.id, author: author, authorId: authorId, - content: content + content: content, }; } @@ -117,7 +117,13 @@ export class StoreMan { } // Attempts to add a confession. Returns true if the confession is sent, false if otherwise. - public addConfession(message: Message, id: string, author: string, authorId: string, content: string): boolean { + public addConfession( + message: Message, + id: string, + author: string, + authorId: string, + content: string, + ): boolean { const guildId = message.guild?.id; for (const guild of this.data) { @@ -127,7 +133,9 @@ export class StoreMan { return false; } - guild.confessions.push(StoreMan.toConfession(message, id, author, authorId, content)); + guild.confessions.push( + StoreMan.toConfession(message, id, author, authorId, content), + ); this.saveFile(); return true; } @@ -138,7 +146,10 @@ export class StoreMan { ); } - public getConfession(guildId: string, confessionId: string): Confession | null { + public getConfession( + guildId: string, + confessionId: string, + ): Confession | null { for (const guild of this.data) { if (guild.id === guildId) { for (const confession of guild.confessions) { @@ -153,7 +164,10 @@ export class StoreMan { } // Attempts to delete a confession. If it is sucessfully deleted, returns true, else false. - public delConfesssion({ guild, user }: CommandInteraction, confessionId: string): boolean { + public delConfesssion( + { guild, user }: CommandInteraction, + confessionId: string, + ): boolean { const guildId = guild?.id; const userId = user.id; @@ -161,7 +175,7 @@ export class StoreMan { if (guild.id === guildId) { for (const confession of guild.confessions) { if (confession.authorId === userId) { - guild.confessions = guild.confessions.filter(confession => { + guild.confessions = guild.confessions.filter((confession) => { return confession.id !== confessionId; }); @@ -208,7 +222,8 @@ export class StoreMan { if (guild.id === guildId) { if (confession) { // Only add the user to the ban list if they aren't banned already - !this.isBanned(guildId, confession.authorId) && guild.settings.bans.push(confession.authorId!); + !this.isBanned(guildId, confession.authorId) && + guild.settings.bans.push(confession.authorId!); this.saveFile(); return true; @@ -224,7 +239,7 @@ export class StoreMan { for (const guild of this.data) { if (guild.id === guildId) { if (this.getConfession(guildId, confessionId)) { - guild.settings.bans = guild.settings.bans.filter(ban => { + guild.settings.bans = guild.settings.bans.filter((ban) => { return ban !== this.getConfession(guildId, confessionId)?.authorId!; }); diff --git a/src/storeman/config.ts b/src/storeman/config.ts index fa27aa2..fb02ac0 100644 --- a/src/storeman/config.ts +++ b/src/storeman/config.ts @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ import dotenv from "dotenv"; dotenv.config(); diff --git a/src/storeman/index.ts b/src/storeman/index.ts index c8248a7..08f0272 100644 --- a/src/storeman/index.ts +++ b/src/storeman/index.ts @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ export * from "./client"; export * from "./config"; diff --git a/src/storeman/types.ts b/src/storeman/types.ts index 00d0fc4..7d16ae5 100644 --- a/src/storeman/types.ts +++ b/src/storeman/types.ts @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ export interface Confession { id: string; diff --git a/src/utils/Logger.ts b/src/utils/Logger.ts index 9997895..06a8202 100644 --- a/src/utils/Logger.ts +++ b/src/utils/Logger.ts @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ import chalk from "chalk"; import { LOG_LEVEL } from "./config"; diff --git a/src/utils/config.ts b/src/utils/config.ts index dd9a9b7..c6a2da0 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ import dotenv from "dotenv"; dotenv.config(); diff --git a/src/utils/getRandomColor.ts b/src/utils/getRandomColor.ts index c68b84d..6ff9e7b 100644 --- a/src/utils/getRandomColor.ts +++ b/src/utils/getRandomColor.ts @@ -14,8 +14,8 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ -const getRandomColor = () => (Math.random() * 0xFFFFFF << 0); +const getRandomColor = () => (Math.random() * 0xffffff) << 0; export default getRandomColor;