From 79673bdf918a8c37494a73518e760c2a2cee22bf Mon Sep 17 00:00:00 2001 From: "Ean Milligan (Bastion)" Date: Sat, 28 Jan 2023 20:59:39 -0500 Subject: [PATCH] deno fmt --- deps.ts | 10 +++++----- src/commands/setup.ts | 43 ++++++++++++++++++++++++++++++------------- src/db.ts | 2 +- src/utils.ts | 3 +-- 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/deps.ts b/deps.ts index d86169f..d254246 100644 --- a/deps.ts +++ b/deps.ts @@ -12,6 +12,8 @@ export { ApplicationCommandFlags, ApplicationCommandOptionTypes, ApplicationCommandTypes, + BitwisePermissionFlags, + ButtonStyles, ChannelTypes, createBot, editBotMember, @@ -19,13 +21,11 @@ export { getBotIdFromToken, Intents, InteractionResponseTypes, + MessageComponentTypes, + OverwriteTypes, sendInteractionResponse, sendMessage, startBot, - OverwriteTypes, - BitwisePermissionFlags, - MessageComponentTypes, - ButtonStyles, } from 'https://deno.land/x/discordeno@17.0.1/mod.ts'; export type { ActionRow, @@ -35,6 +35,7 @@ export type { ButtonComponent, CreateApplicationCommand, CreateMessage, + DiscordEmbedField, Embed, EventHandlers, Guild, @@ -42,7 +43,6 @@ export type { MakeRequired, Message, PermissionStrings, - DiscordEmbedField, } from 'https://deno.land/x/discordeno@17.0.1/mod.ts'; export { Client } from 'https://deno.land/x/mysql@v2.11.0/mod.ts'; diff --git a/src/commands/setup.ts b/src/commands/setup.ts index 5e065ca..86d1f0e 100644 --- a/src/commands/setup.ts +++ b/src/commands/setup.ts @@ -1,7 +1,21 @@ import config from '../../config.ts'; -import { ApplicationCommandFlags, ApplicationCommandOptionTypes, ApplicationCommandTypes, ButtonStyles, Bot, ChannelTypes, Interaction, InteractionResponseTypes, sendMessage, OverwriteTypes, botId, MessageComponentTypes, DiscordEmbedField } from '../../deps.ts'; +import { + ApplicationCommandFlags, + ApplicationCommandOptionTypes, + ApplicationCommandTypes, + Bot, + botId, + ButtonStyles, + ChannelTypes, + DiscordEmbedField, + Interaction, + InteractionResponseTypes, + MessageComponentTypes, + OverwriteTypes, + sendMessage, +} from '../../deps.ts'; import { failColor, infoColor2, somethingWentWrong, successColor } from '../commandUtils.ts'; -import { dbClient, queries, lfgChannelSettings } from '../db.ts'; +import { dbClient, lfgChannelSettings, queries } from '../db.ts'; import { CommandDetails } from '../types/commandTypes.ts'; import utils from '../utils.ts'; @@ -59,7 +73,8 @@ const execute = async (bot: Bot, interaction: Interaction) => { embeds: [{ color: failColor, title: 'Unable to setup LFG channel.', - description: 'This channel is already set as an LFG channel. If you need to edit the channel, please run `/delete lfg-channel` in this channel and then run `/setup` again.\n\nThis will not harm any active events in this channel and simply resets the settings for this channel.', + description: + 'This channel is already set as an LFG channel. If you need to edit the channel, please run `/delete lfg-channel` in this channel and then run `/setup` again.\n\nThis will not harm any active events in this channel and simply resets the settings for this channel.', }], }, }).catch((e: Error) => utils.commonLoggers.interactionSendError('setup.ts', interaction, e)); @@ -92,9 +107,9 @@ const execute = async (bot: Bot, interaction: Interaction) => { \`/alternate\` The Discord Slash Command system will ensure you provide all the required details.`, - }) + }); if (setupOpts.options?.length) { - setupOpts.options.forEach(opt => { + setupOpts.options.forEach((opt) => { if (opt.name === managerRoleStr) { managerRoleId = BigInt(opt.value as string || '0'); } else if (opt.name === logChannelStr) { @@ -111,7 +126,8 @@ The Discord Slash Command system will ensure you provide all the required detail embeds: [{ color: failColor, title: 'Unable to setup log channel or manager role.', - description: `${config.name} attempted to set the log channel or manager role, but one or both were undefined. Please try again and if the issue continues, \`/report\` this issue to the developers with the error code below.`, + description: + `${config.name} attempted to set the log channel or manager role, but one or both were undefined. Please try again and if the issue continues, \`/report\` this issue to the developers with the error code below.`, fields: [{ name: 'Error Code:', value: `setupLog${logChannelId}Mgr${managerRoleId}`, @@ -133,7 +149,7 @@ The Discord Slash Command system will ensure you provide all the required detail title: `This is the channel ${config.name} will be logging events to.`, description: `${config.name} will only send messages here as frequently as your event managers update events.`, color: infoColor2, - }] + }], }).catch((e: Error) => { utils.commonLoggers.messageSendError('setup.ts', 'log-test', e); logChannelErrorOut = true; @@ -200,8 +216,8 @@ The Discord Slash Command system will ensure you provide all the required detail // Delete all messages that are not LFG posts const msgsToDel: Array = []; - const oldLfgMsgs: Array = [] - messages.forEach(msg => { + const oldLfgMsgs: Array = []; + messages.forEach((msg) => { if (msg.authorId === botId && msg.embeds.length && msg.embeds[0].footer && msg.embeds[0].footer.text.includes('Created by:')) { oldLfgMsgs.push(msg.id); } else { @@ -219,10 +235,11 @@ The Discord Slash Command system will ensure you provide all the required detail // Store the ids to the db let dbErrorOut = false; - await dbClient.execute('INSERT INTO guild_settings(guildId,lfgChannelId,managerRoleId,logChannelId) values(?,?,?,?)', [interaction.guildId, interaction.channelId, managerRoleId, logChannelId]).catch((e) => { - utils.commonLoggers.dbError('setup.ts', 'insert into guild_settings', e); - dbErrorOut = true; - }); + await dbClient.execute('INSERT INTO guild_settings(guildId,lfgChannelId,managerRoleId,logChannelId) values(?,?,?,?)', [interaction.guildId, interaction.channelId, managerRoleId, logChannelId]) + .catch((e) => { + utils.commonLoggers.dbError('setup.ts', 'insert into guild_settings', e); + dbErrorOut = true; + }); if (dbErrorOut) { // DB died? somethingWentWrong(bot, interaction, 'setupDBInsertFailed'); diff --git a/src/db.ts b/src/db.ts index abfa900..e208905 100644 --- a/src/db.ts +++ b/src/db.ts @@ -1,7 +1,7 @@ import config from '../config.ts'; import { Client } from '../deps.ts'; import { LOCALMODE } from '../flags.ts'; -import { LfgChannelSetting, DBGuildSettings } from './types/commandTypes.ts'; +import { DBGuildSettings, LfgChannelSetting } from './types/commandTypes.ts'; export const dbClient = await new Client().connect({ hostname: LOCALMODE ? config.db.localhost : config.db.host, diff --git a/src/utils.ts b/src/utils.ts index 620cc00..96f11a5 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -19,8 +19,7 @@ const reactionAddError = (location: string, message: Message | string, err: Erro genericLogger(LT.ERROR, `${location} | Failed to add emoji (${emoji}) to message: ${jsonStringifyBig(message)} | Error: ${err.name} - ${err.message}`); const reactionDeleteError = (location: string, message: Message | string, err: Error, emoji: string) => genericLogger(LT.ERROR, `${location} | Failed to delete emoji (${emoji}) from message: ${jsonStringifyBig(message)} | Error: ${err.name} - ${err.message}`); -const channelUpdateError = (location: string, message: string, err: Error) => - genericLogger(LT.ERROR, `${location} | Failed to update channel | ${message} | Error: ${err.name} - ${err.message}`); +const channelUpdateError = (location: string, message: string, err: Error) => genericLogger(LT.ERROR, `${location} | Failed to update channel | ${message} | Error: ${err.name} - ${err.message}`); const dbError = (location: string, type: string, err: Error) => genericLogger(LT.ERROR, `${location} | Failed to ${type} database | Error: ${err.name} - ${err.message}`);