deno fmt
This commit is contained in:
parent
a43fade7d5
commit
79673bdf91
10
deps.ts
10
deps.ts
|
@ -12,6 +12,8 @@ export {
|
||||||
ApplicationCommandFlags,
|
ApplicationCommandFlags,
|
||||||
ApplicationCommandOptionTypes,
|
ApplicationCommandOptionTypes,
|
||||||
ApplicationCommandTypes,
|
ApplicationCommandTypes,
|
||||||
|
BitwisePermissionFlags,
|
||||||
|
ButtonStyles,
|
||||||
ChannelTypes,
|
ChannelTypes,
|
||||||
createBot,
|
createBot,
|
||||||
editBotMember,
|
editBotMember,
|
||||||
|
@ -19,13 +21,11 @@ export {
|
||||||
getBotIdFromToken,
|
getBotIdFromToken,
|
||||||
Intents,
|
Intents,
|
||||||
InteractionResponseTypes,
|
InteractionResponseTypes,
|
||||||
|
MessageComponentTypes,
|
||||||
|
OverwriteTypes,
|
||||||
sendInteractionResponse,
|
sendInteractionResponse,
|
||||||
sendMessage,
|
sendMessage,
|
||||||
startBot,
|
startBot,
|
||||||
OverwriteTypes,
|
|
||||||
BitwisePermissionFlags,
|
|
||||||
MessageComponentTypes,
|
|
||||||
ButtonStyles,
|
|
||||||
} from 'https://deno.land/x/discordeno@17.0.1/mod.ts';
|
} from 'https://deno.land/x/discordeno@17.0.1/mod.ts';
|
||||||
export type {
|
export type {
|
||||||
ActionRow,
|
ActionRow,
|
||||||
|
@ -35,6 +35,7 @@ export type {
|
||||||
ButtonComponent,
|
ButtonComponent,
|
||||||
CreateApplicationCommand,
|
CreateApplicationCommand,
|
||||||
CreateMessage,
|
CreateMessage,
|
||||||
|
DiscordEmbedField,
|
||||||
Embed,
|
Embed,
|
||||||
EventHandlers,
|
EventHandlers,
|
||||||
Guild,
|
Guild,
|
||||||
|
@ -42,7 +43,6 @@ export type {
|
||||||
MakeRequired,
|
MakeRequired,
|
||||||
Message,
|
Message,
|
||||||
PermissionStrings,
|
PermissionStrings,
|
||||||
DiscordEmbedField,
|
|
||||||
} from 'https://deno.land/x/discordeno@17.0.1/mod.ts';
|
} from 'https://deno.land/x/discordeno@17.0.1/mod.ts';
|
||||||
|
|
||||||
export { Client } from 'https://deno.land/x/mysql@v2.11.0/mod.ts';
|
export { Client } from 'https://deno.land/x/mysql@v2.11.0/mod.ts';
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
import config from '../../config.ts';
|
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 { 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 { CommandDetails } from '../types/commandTypes.ts';
|
||||||
import utils from '../utils.ts';
|
import utils from '../utils.ts';
|
||||||
|
|
||||||
|
@ -59,7 +73,8 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
embeds: [{
|
embeds: [{
|
||||||
color: failColor,
|
color: failColor,
|
||||||
title: 'Unable to setup LFG channel.',
|
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));
|
}).catch((e: Error) => utils.commonLoggers.interactionSendError('setup.ts', interaction, e));
|
||||||
|
@ -92,9 +107,9 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
\`/alternate\`
|
\`/alternate\`
|
||||||
|
|
||||||
The Discord Slash Command system will ensure you provide all the required details.`,
|
The Discord Slash Command system will ensure you provide all the required details.`,
|
||||||
})
|
});
|
||||||
if (setupOpts.options?.length) {
|
if (setupOpts.options?.length) {
|
||||||
setupOpts.options.forEach(opt => {
|
setupOpts.options.forEach((opt) => {
|
||||||
if (opt.name === managerRoleStr) {
|
if (opt.name === managerRoleStr) {
|
||||||
managerRoleId = BigInt(opt.value as string || '0');
|
managerRoleId = BigInt(opt.value as string || '0');
|
||||||
} else if (opt.name === logChannelStr) {
|
} else if (opt.name === logChannelStr) {
|
||||||
|
@ -111,7 +126,8 @@ The Discord Slash Command system will ensure you provide all the required detail
|
||||||
embeds: [{
|
embeds: [{
|
||||||
color: failColor,
|
color: failColor,
|
||||||
title: 'Unable to setup log channel or manager role.',
|
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: [{
|
fields: [{
|
||||||
name: 'Error Code:',
|
name: 'Error Code:',
|
||||||
value: `setupLog${logChannelId}Mgr${managerRoleId}`,
|
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.`,
|
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.`,
|
description: `${config.name} will only send messages here as frequently as your event managers update events.`,
|
||||||
color: infoColor2,
|
color: infoColor2,
|
||||||
}]
|
}],
|
||||||
}).catch((e: Error) => {
|
}).catch((e: Error) => {
|
||||||
utils.commonLoggers.messageSendError('setup.ts', 'log-test', e);
|
utils.commonLoggers.messageSendError('setup.ts', 'log-test', e);
|
||||||
logChannelErrorOut = true;
|
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
|
// Delete all messages that are not LFG posts
|
||||||
const msgsToDel: Array<bigint> = [];
|
const msgsToDel: Array<bigint> = [];
|
||||||
const oldLfgMsgs: Array<bigint> = []
|
const oldLfgMsgs: Array<bigint> = [];
|
||||||
messages.forEach(msg => {
|
messages.forEach((msg) => {
|
||||||
if (msg.authorId === botId && msg.embeds.length && msg.embeds[0].footer && msg.embeds[0].footer.text.includes('Created by:')) {
|
if (msg.authorId === botId && msg.embeds.length && msg.embeds[0].footer && msg.embeds[0].footer.text.includes('Created by:')) {
|
||||||
oldLfgMsgs.push(msg.id);
|
oldLfgMsgs.push(msg.id);
|
||||||
} else {
|
} else {
|
||||||
|
@ -219,10 +235,11 @@ The Discord Slash Command system will ensure you provide all the required detail
|
||||||
|
|
||||||
// Store the ids to the db
|
// Store the ids to the db
|
||||||
let dbErrorOut = false;
|
let dbErrorOut = false;
|
||||||
await dbClient.execute('INSERT INTO guild_settings(guildId,lfgChannelId,managerRoleId,logChannelId) values(?,?,?,?)', [interaction.guildId, interaction.channelId, managerRoleId, logChannelId]).catch((e) => {
|
await dbClient.execute('INSERT INTO guild_settings(guildId,lfgChannelId,managerRoleId,logChannelId) values(?,?,?,?)', [interaction.guildId, interaction.channelId, managerRoleId, logChannelId])
|
||||||
utils.commonLoggers.dbError('setup.ts', 'insert into guild_settings', e);
|
.catch((e) => {
|
||||||
dbErrorOut = true;
|
utils.commonLoggers.dbError('setup.ts', 'insert into guild_settings', e);
|
||||||
});
|
dbErrorOut = true;
|
||||||
|
});
|
||||||
if (dbErrorOut) {
|
if (dbErrorOut) {
|
||||||
// DB died?
|
// DB died?
|
||||||
somethingWentWrong(bot, interaction, 'setupDBInsertFailed');
|
somethingWentWrong(bot, interaction, 'setupDBInsertFailed');
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import config from '../config.ts';
|
import config from '../config.ts';
|
||||||
import { Client } from '../deps.ts';
|
import { Client } from '../deps.ts';
|
||||||
import { LOCALMODE } from '../flags.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({
|
export const dbClient = await new Client().connect({
|
||||||
hostname: LOCALMODE ? config.db.localhost : config.db.host,
|
hostname: LOCALMODE ? config.db.localhost : config.db.host,
|
||||||
|
|
|
@ -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}`);
|
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) =>
|
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}`);
|
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) =>
|
const channelUpdateError = (location: string, message: string, err: Error) => genericLogger(LT.ERROR, `${location} | Failed to update channel | ${message} | Error: ${err.name} - ${err.message}`);
|
||||||
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}`);
|
const dbError = (location: string, type: string, err: Error) => genericLogger(LT.ERROR, `${location} | Failed to ${type} database | Error: ${err.name} - ${err.message}`);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue