V1.0.1 - Fix setup permission issue, sonar fixes
This commit is contained in:
parent
3db443effc
commit
33d9770b5f
|
@ -1,6 +1,6 @@
|
||||||
export const config = {
|
export const config = {
|
||||||
'name': 'Group Up', // Name of the bot
|
'name': 'Group Up', // Name of the bot
|
||||||
'version': '1.0.0', // Version of the bot
|
'version': '1.0.1', // Version of the bot
|
||||||
'token': 'the_bot_token', // Discord API Token for this bot
|
'token': 'the_bot_token', // Discord API Token for this bot
|
||||||
'localToken': 'local_testing_token', // Discord API Token for a secondary OPTIONAL testing bot, THIS MUST BE DIFFERENT FROM "token"
|
'localToken': 'local_testing_token', // Discord API Token for a secondary OPTIONAL testing bot, THIS MUST BE DIFFERENT FROM "token"
|
||||||
'prefix': '/', // Prefix for all commands
|
'prefix': '/', // Prefix for all commands
|
||||||
|
|
|
@ -49,7 +49,7 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
let prefillTimeZone = '';
|
let prefillTimeZone = '';
|
||||||
let prefillDate = '';
|
let prefillDate = '';
|
||||||
let prefillDescription = '';
|
let prefillDescription = '';
|
||||||
if (interaction.message && interaction.message.embeds[0].fields && interaction.message.embeds[0].fields[LfgEmbedIndexes.StartTime].name === lfgStartTimeName) {
|
if (interaction.message?.embeds[0].fields && interaction.message.embeds[0].fields[LfgEmbedIndexes.StartTime].name === lfgStartTimeName) {
|
||||||
if (interaction.message.embeds[0].fields[LfgEmbedIndexes.StartTime].value !== invalidDateTimeStr) {
|
if (interaction.message.embeds[0].fields[LfgEmbedIndexes.StartTime].value !== invalidDateTimeStr) {
|
||||||
let rawEventDateTime = interaction.message.embeds[0].fields[LfgEmbedIndexes.StartTime].value.split('\n')[0].split(' ');
|
let rawEventDateTime = interaction.message.embeds[0].fields[LfgEmbedIndexes.StartTime].value.split('\n')[0].split(' ');
|
||||||
const monthIdx = rawEventDateTime.findIndex((item) => monthsShort.includes(item.toUpperCase()));
|
const monthIdx = rawEventDateTime.findIndex((item) => monthsShort.includes(item.toUpperCase()));
|
||||||
|
@ -103,7 +103,7 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
});
|
});
|
||||||
selectMenus.push(generateCustomEventRow(prefillArray.length ? prefillArray[0] : '', prefillArray.length > 1 ? prefillArray[prefillArray.length - 1] : ''));
|
selectMenus.push(generateCustomEventRow(prefillArray.length ? prefillArray[0] : '', prefillArray.length > 1 ? prefillArray[prefillArray.length - 1] : ''));
|
||||||
|
|
||||||
if (interaction.data.customId && interaction.data.customId.includes(fillerChar)) {
|
if (interaction.data.customId?.includes(fillerChar)) {
|
||||||
// Let discord know we didn't ignore the user
|
// Let discord know we didn't ignore the user
|
||||||
await bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
await bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
||||||
type: InteractionResponseTypes.DeferredUpdateMessage,
|
type: InteractionResponseTypes.DeferredUpdateMessage,
|
||||||
|
|
|
@ -22,9 +22,9 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove any pipe characters to avoid issues down the process
|
// Remove any pipe characters to avoid issues down the process
|
||||||
const activityTitle = (tempDataMap.get(activityTitleId) || '').replace(/\|/g, '');
|
const activityTitle = (tempDataMap.get(activityTitleId) ?? '').replace(/\|/g, '');
|
||||||
const activitySubtitle = (tempDataMap.get(activitySubtitleId) || '').replace(/\|/g, '');
|
const activitySubtitle = (tempDataMap.get(activitySubtitleId) ?? '').replace(/\|/g, '');
|
||||||
const activityMaxPlayers = parseInt(tempDataMap.get(activityMaxPlayersId) || '0');
|
const activityMaxPlayers = parseInt(tempDataMap.get(activityMaxPlayersId) ?? '0');
|
||||||
if (isNaN(activityMaxPlayers) || activityMaxPlayers < 1 || activityMaxPlayers > 99) {
|
if (isNaN(activityMaxPlayers) || activityMaxPlayers < 1 || activityMaxPlayers > 99) {
|
||||||
bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
||||||
type: InteractionResponseTypes.ChannelMessageWithSource,
|
type: InteractionResponseTypes.ChannelMessageWithSource,
|
||||||
|
|
|
@ -55,10 +55,10 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const rawEventTime = tempDataMap.get(eventTimeId) || '';
|
const rawEventTime = tempDataMap.get(eventTimeId) ?? '';
|
||||||
const rawEventTimeZone = tempDataMap.get(eventTimeZoneId) || '';
|
const rawEventTimeZone = tempDataMap.get(eventTimeZoneId) ?? '';
|
||||||
const rawEventDate = tempDataMap.get(eventDateId) || '';
|
const rawEventDate = tempDataMap.get(eventDateId) ?? '';
|
||||||
const eventDescription = tempDataMap.get(eventDescriptionId) || noDescProvided;
|
const eventDescription = tempDataMap.get(eventDescriptionId) ?? noDescProvided;
|
||||||
if (!rawEventTime || !rawEventTimeZone || !rawEventDate) {
|
if (!rawEventTime || !rawEventTimeZone || !rawEventDate) {
|
||||||
// Error out if user somehow failed to provide one of the fields (eventDescription is allowed to be null/empty)
|
// Error out if user somehow failed to provide one of the fields (eventDescription is allowed to be null/empty)
|
||||||
somethingWentWrong(bot, interaction, `missingFieldFromEventDescription@${rawEventTime}_${rawEventTimeZone}_${rawEventDate}`);
|
somethingWentWrong(bot, interaction, `missingFieldFromEventDescription@${rawEventTime}_${rawEventTimeZone}_${rawEventDate}`);
|
||||||
|
|
|
@ -55,7 +55,7 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventMessage && eventMessage.embeds[0].fields) {
|
if (eventMessage?.embeds[0].fields) {
|
||||||
eventMessage.embeds[0].fields[LfgEmbedIndexes.StartTime].value = generateTimeFieldStr(eventDateTimeStr, eventDateTime);
|
eventMessage.embeds[0].fields[LfgEmbedIndexes.StartTime].value = generateTimeFieldStr(eventDateTimeStr, eventDateTime);
|
||||||
const tIdx = eventMessage.embeds[0].fields[LfgEmbedIndexes.ICSLink].value.indexOf('?t=') + 3;
|
const tIdx = eventMessage.embeds[0].fields[LfgEmbedIndexes.ICSLink].value.indexOf('?t=') + 3;
|
||||||
const nIdx = eventMessage.embeds[0].fields[LfgEmbedIndexes.ICSLink].value.indexOf('&n=');
|
const nIdx = eventMessage.embeds[0].fields[LfgEmbedIndexes.ICSLink].value.indexOf('&n=');
|
||||||
|
|
|
@ -17,13 +17,13 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
for (const row of interaction.data.components) {
|
for (const row of interaction.data.components) {
|
||||||
if (row.components?.[0]) {
|
if (row.components?.[0]) {
|
||||||
const textField = row.components[0];
|
const textField = row.components[0];
|
||||||
tempDataMap.set(textField.customId || 'missingCustomId', textField.value || '');
|
tempDataMap.set(textField.customId || 'missingCustomId', textField.value || noDescProvided);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const newDescription = tempDataMap.get(eventDescriptionId);
|
const newDescription = tempDataMap.get(eventDescriptionId);
|
||||||
|
|
||||||
if (eventMessage && eventMessage.embeds[0].fields) {
|
if (eventMessage?.embeds[0].fields) {
|
||||||
eventMessage.embeds[0].fields[LfgEmbedIndexes.Description].value = newDescription || noDescProvided;
|
eventMessage.embeds[0].fields[LfgEmbedIndexes.Description].value = newDescription ?? noDescProvided;
|
||||||
|
|
||||||
// Send edit confirmation
|
// Send edit confirmation
|
||||||
addTokenToMap(bot, interaction, interaction.guildId, interaction.channelId, interaction.member.id);
|
addTokenToMap(bot, interaction, interaction.guildId, interaction.channelId, interaction.member.id);
|
||||||
|
|
|
@ -65,9 +65,9 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove any pipe characters to avoid issues down the process
|
// Remove any pipe characters to avoid issues down the process
|
||||||
const activityTitle = (tempDataMap.get(activityTitleId) || '').replace(/\|/g, '');
|
const activityTitle = (tempDataMap.get(activityTitleId) ?? '').replace(/\|/g, '');
|
||||||
const activitySubtitle = (tempDataMap.get(activitySubtitleId) || '').replace(/\|/g, '');
|
const activitySubtitle = (tempDataMap.get(activitySubtitleId) ?? '').replace(/\|/g, '');
|
||||||
const activityMaxPlayers = parseInt(tempDataMap.get(activityMaxPlayersId) || '0');
|
const activityMaxPlayers = parseInt(tempDataMap.get(activityMaxPlayersId) ?? '0');
|
||||||
if (isNaN(activityMaxPlayers) || activityMaxPlayers < 1 || activityMaxPlayers > 99) {
|
if (isNaN(activityMaxPlayers) || activityMaxPlayers < 1 || activityMaxPlayers > 99) {
|
||||||
bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
||||||
type: InteractionResponseTypes.ChannelMessageWithSource,
|
type: InteractionResponseTypes.ChannelMessageWithSource,
|
||||||
|
@ -114,7 +114,7 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
|
|
||||||
// Get event to apply edit
|
// Get event to apply edit
|
||||||
const eventMessage = await bot.helpers.getMessage(evtChannelId, evtMessageId).catch((e: Error) => utils.commonLoggers.messageGetError('editActivity.ts', 'get eventMessage', e));
|
const eventMessage = await bot.helpers.getMessage(evtChannelId, evtMessageId).catch((e: Error) => utils.commonLoggers.messageGetError('editActivity.ts', 'get eventMessage', e));
|
||||||
if (eventMessage && eventMessage.embeds[0].fields) {
|
if (eventMessage?.embeds[0].fields) {
|
||||||
await deleteTokenEarly(bot, interaction, interaction.guildId, interaction.channelId, interaction.member.id);
|
await deleteTokenEarly(bot, interaction, interaction.guildId, interaction.channelId, interaction.member.id);
|
||||||
// Update member lists
|
// Update member lists
|
||||||
const [currentMemberCount, _oldMaxMemberCount] = getEventMemberCount(eventMessage.embeds[0].fields[LfgEmbedIndexes.JoinedMembers].name);
|
const [currentMemberCount, _oldMaxMemberCount] = getEventMemberCount(eventMessage.embeds[0].fields[LfgEmbedIndexes.JoinedMembers].name);
|
||||||
|
@ -173,7 +173,7 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
|
|
||||||
selectMenus.push(makeCustomEventRow(interaction.data.customId.replaceAll(fillerChar, '').split(idSeparator)[1] || ''));
|
selectMenus.push(makeCustomEventRow(interaction.data.customId.replaceAll(fillerChar, '').split(idSeparator)[1] || ''));
|
||||||
|
|
||||||
if (interaction.data.customId && interaction.data.customId.includes(fillerChar)) {
|
if (interaction.data.customId.includes(fillerChar)) {
|
||||||
// Let discord know we didn't ignore the user
|
// Let discord know we didn't ignore the user
|
||||||
await bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
await bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
||||||
type: InteractionResponseTypes.DeferredUpdateMessage,
|
type: InteractionResponseTypes.DeferredUpdateMessage,
|
||||||
|
|
|
@ -15,7 +15,7 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
const [evtGuildId, evtChannelId, evtMessageId] = (interaction.data.customId.replaceAll(pathIdxEnder, '').split(idSeparator)[1] || '').split(pathIdxSeparator).map((id) => BigInt(id || '0'));
|
const [evtGuildId, evtChannelId, evtMessageId] = (interaction.data.customId.replaceAll(pathIdxEnder, '').split(idSeparator)[1] || '').split(pathIdxSeparator).map((id) => BigInt(id || '0'));
|
||||||
const eventMessage = await bot.helpers.getMessage(evtChannelId, evtMessageId).catch((e: Error) => utils.commonLoggers.messageGetError('editActivity.ts', 'get eventMessage', e));
|
const eventMessage = await bot.helpers.getMessage(evtChannelId, evtMessageId).catch((e: Error) => utils.commonLoggers.messageGetError('editActivity.ts', 'get eventMessage', e));
|
||||||
|
|
||||||
if (eventMessage && eventMessage.embeds[0]) {
|
if (eventMessage?.embeds[0]) {
|
||||||
// Remove user from event
|
// Remove user from event
|
||||||
removeMemberFromEvent(bot, interaction, eventMessage.embeds[0], evtMessageId, evtChannelId, interaction.user.id, evtGuildId, true);
|
removeMemberFromEvent(bot, interaction, eventMessage.embeds[0], evtMessageId, evtChannelId, interaction.user.id, evtGuildId, true);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -19,7 +19,7 @@ export const addTokenToMap = (bot: Bot, interaction: Interaction, guildId: bigin
|
||||||
token: interaction.token,
|
token: interaction.token,
|
||||||
timeoutId: setTimeout(
|
timeoutId: setTimeout(
|
||||||
(guildId, channelId, userId) => {
|
(guildId, channelId, userId) => {
|
||||||
deleteTokenEarly(bot, interaction, guildId, channelId, userId);
|
deleteTokenEarly(bot, interaction, guildId, channelId, userId).catch((e) => utils.commonLoggers.interactionSendError('tokenCleanup.ts:addTokenToMap', interaction, e));
|
||||||
},
|
},
|
||||||
tokenTimeoutMS,
|
tokenTimeoutMS,
|
||||||
guildId,
|
guildId,
|
||||||
|
@ -30,8 +30,8 @@ export const addTokenToMap = (bot: Bot, interaction: Interaction, guildId: bigin
|
||||||
|
|
||||||
export const deleteTokenEarly = async (bot: Bot, interaction: Interaction, guildId: bigint, channelId: bigint, userId: bigint) => {
|
export const deleteTokenEarly = async (bot: Bot, interaction: Interaction, guildId: bigint, channelId: bigint, userId: bigint) => {
|
||||||
const tokenMapEntry = tokenMap.get(generateMapId(guildId, channelId, userId));
|
const tokenMapEntry = tokenMap.get(generateMapId(guildId, channelId, userId));
|
||||||
if (tokenMapEntry && tokenMapEntry.token) {
|
if (tokenMapEntry?.token) {
|
||||||
await bot.helpers.deleteOriginalInteractionResponse(tokenMap.get(generateMapId(guildId, channelId, userId))?.token || '').catch((e: Error) =>
|
await bot.helpers.deleteOriginalInteractionResponse(tokenMap.get(generateMapId(guildId, channelId, userId))?.token ?? '').catch((e: Error) =>
|
||||||
utils.commonLoggers.interactionSendError('tokenCleanup.ts:deleteTokenEarly', interaction, e)
|
utils.commonLoggers.interactionSendError('tokenCleanup.ts:deleteTokenEarly', interaction, e)
|
||||||
);
|
);
|
||||||
clearTimeout(tokenMapEntry.timeoutId);
|
clearTimeout(tokenMapEntry.timeoutId);
|
||||||
|
|
|
@ -61,8 +61,8 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
for (const option of interaction.data.options[0].options) {
|
for (const option of interaction.data.options[0].options) {
|
||||||
tempDataMap.set(option.name || 'missingCustomId', option.value as string || '');
|
tempDataMap.set(option.name || 'missingCustomId', option.value as string || '');
|
||||||
}
|
}
|
||||||
const eventLink = tempDataMap.get(eventLinkName) || '';
|
const eventLink = tempDataMap.get(eventLinkName) ?? '';
|
||||||
const userToAdd = BigInt(tempDataMap.get(userName) || '0');
|
const userToAdd = BigInt(tempDataMap.get(userName) ?? '0');
|
||||||
const eventIds = utils.messageUrlToIds(eventLink);
|
const eventIds = utils.messageUrlToIds(eventLink);
|
||||||
|
|
||||||
// Verify fields exist
|
// Verify fields exist
|
||||||
|
|
|
@ -10,7 +10,6 @@ import {
|
||||||
DiscordEmbedField,
|
DiscordEmbedField,
|
||||||
Interaction,
|
Interaction,
|
||||||
InteractionResponseTypes,
|
InteractionResponseTypes,
|
||||||
LT, log,
|
|
||||||
MessageComponentTypes,
|
MessageComponentTypes,
|
||||||
OverwriteTypes,
|
OverwriteTypes,
|
||||||
} from '../../deps.ts';
|
} from '../../deps.ts';
|
||||||
|
@ -110,7 +109,7 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
name: 'Editing/Deleting your event:',
|
name: 'Editing/Deleting your event:',
|
||||||
value: 'To edit or delete your event, simply click on the ✏️ or 🗑️ buttons respectively.',
|
value: 'To edit or delete your event, simply click on the ✏️ or 🗑️ buttons respectively.',
|
||||||
}];
|
}];
|
||||||
const sendMessagePermSting = '`SEND_MESSAGES`\n`VIEW_CHANNEL`\n`EMBED_LINKS`'
|
const sendMessagePermSting = '`SEND_MESSAGES`\n`VIEW_CHANNEL`\n`EMBED_LINKS`';
|
||||||
const permissionFields: Array<DiscordEmbedField> = [
|
const permissionFields: Array<DiscordEmbedField> = [
|
||||||
{
|
{
|
||||||
name: `Please make sure ${config.name} has the following permissions for the current channel:`,
|
name: `Please make sure ${config.name} has the following permissions for the current channel:`,
|
||||||
|
@ -258,7 +257,7 @@ The Discord Slash Command system will ensure you provide all the required detail
|
||||||
// Retrofit all old LFG posts that we found
|
// Retrofit all old LFG posts that we found
|
||||||
oldLfgMsgs.forEach((oldEventId) => {
|
oldLfgMsgs.forEach((oldEventId) => {
|
||||||
const oldEvent = messages.get(oldEventId);
|
const oldEvent = messages.get(oldEventId);
|
||||||
if (oldEvent && oldEvent.embeds[0].fields && oldEvent.embeds[0].footer) {
|
if (oldEvent?.embeds[0].fields && oldEvent.embeds[0].footer) {
|
||||||
const eventMembers = [...getLfgMembers(oldEvent.embeds[0].fields[LfgEmbedIndexes.JoinedMembers].value), ...getLfgMembers(oldEvent.embeds[0].fields[LfgEmbedIndexes.AlternateMembers].value)];
|
const eventMembers = [...getLfgMembers(oldEvent.embeds[0].fields[LfgEmbedIndexes.JoinedMembers].value), ...getLfgMembers(oldEvent.embeds[0].fields[LfgEmbedIndexes.AlternateMembers].value)];
|
||||||
const eventDateTime = new Date(parseInt((oldEvent.embeds[0].fields[LfgEmbedIndexes.StartTime].value.split('tz#')[1] || ' ').slice(0, -1)));
|
const eventDateTime = new Date(parseInt((oldEvent.embeds[0].fields[LfgEmbedIndexes.StartTime].value.split('tz#')[1] || ' ').slice(0, -1)));
|
||||||
if (!isNaN(eventDateTime.getTime())) {
|
if (!isNaN(eventDateTime.getTime())) {
|
||||||
|
@ -339,10 +338,12 @@ The Discord Slash Command system will ensure you provide all the required detail
|
||||||
} else {
|
} else {
|
||||||
// Clean up DB and map
|
// Clean up DB and map
|
||||||
lfgChannelSettings.delete(lfgChannelSettingKey);
|
lfgChannelSettings.delete(lfgChannelSettingKey);
|
||||||
await dbClient.execute('DELETE FROM guild_settings WHERE guildId = ? AND lfgChannelId = ?', [interaction.guildId, interaction.channelId]).catch((e) => utils.commonLoggers.dbError('setup.ts', 'delete guild/lfgChannel', e));
|
await dbClient.execute('DELETE FROM guild_settings WHERE guildId = ? AND lfgChannelId = ?', [interaction.guildId, interaction.channelId]).catch((e) =>
|
||||||
|
utils.commonLoggers.dbError('setup.ts', 'delete guild/lfgChannel', e)
|
||||||
|
);
|
||||||
|
|
||||||
if (introMsg) {
|
if (introMsg) {
|
||||||
bot.helpers.deleteMessage(interaction.channelId, introMsg.id, 'embed missing').catch((e) => utils.commonLoggers.messageDeleteError('setup.ts', 'embed missing cleanup', e))
|
bot.helpers.deleteMessage(interaction.channelId, introMsg.id, 'embed missing').catch((e) => utils.commonLoggers.messageDeleteError('setup.ts', 'embed missing cleanup', e));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Could not send initial message
|
// Could not send initial message
|
||||||
|
|
|
@ -128,7 +128,7 @@ export const notifyEventMembers = async (bot: Bot, event: ActiveEvent, secondTry
|
||||||
dbClient.execute(queries.updateEventFlags(1, 0), [event.channelId, event.messageId]).catch((e) => utils.commonLoggers.dbError('notificationSystem.ts@notifySuccess', 'update event in', e));
|
dbClient.execute(queries.updateEventFlags(1, 0), [event.channelId, event.messageId]).catch((e) => utils.commonLoggers.dbError('notificationSystem.ts@notifySuccess', 'update event in', e));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (!secondTry) loudLogFailure(bot, event, notifyStepName);
|
if (!secondTry) loudLogFailure(bot, event, notifyStepName).catch((e) => utils.commonLoggers.messageSendError('notificationSystem.ts@notify', 'loudLog Failed', e));
|
||||||
// Update DB to indicate notifications have not been sent out
|
// Update DB to indicate notifications have not been sent out
|
||||||
dbClient.execute(queries.updateEventFlags(-1, 0), [event.channelId, event.messageId]).catch((e) => utils.commonLoggers.dbError('notificationSystem.ts@notifyFail', 'update event in', e));
|
dbClient.execute(queries.updateEventFlags(-1, 0), [event.channelId, event.messageId]).catch((e) => utils.commonLoggers.dbError('notificationSystem.ts@notifyFail', 'update event in', e));
|
||||||
return false;
|
return false;
|
||||||
|
@ -182,7 +182,7 @@ export const lockEvent = async (bot: Bot, event: ActiveEvent, secondTry = false)
|
||||||
dbClient.execute(queries.updateEventFlags(1, 1), [event.channelId, event.messageId]).catch((e) => utils.commonLoggers.dbError('notificationSystem.ts@lockSuccess', 'update event in', e));
|
dbClient.execute(queries.updateEventFlags(1, 1), [event.channelId, event.messageId]).catch((e) => utils.commonLoggers.dbError('notificationSystem.ts@lockSuccess', 'update event in', e));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (!secondTry) loudLogFailure(bot, event, lockStepName);
|
if (!secondTry) loudLogFailure(bot, event, lockStepName).catch((e) => utils.commonLoggers.messageSendError('notificationSystem.ts@lock', 'loudLog Failed', e));
|
||||||
// Update DB to indicate event has not been locked
|
// Update DB to indicate event has not been locked
|
||||||
dbClient.execute(queries.updateEventFlags(1, -1), [event.channelId, event.messageId]).catch((e) => utils.commonLoggers.dbError('notificationSystem.ts@lockFail', 'update event in', e));
|
dbClient.execute(queries.updateEventFlags(1, -1), [event.channelId, event.messageId]).catch((e) => utils.commonLoggers.dbError('notificationSystem.ts@lockFail', 'update event in', e));
|
||||||
return false;
|
return false;
|
||||||
|
@ -202,7 +202,7 @@ export const deleteEvent = async (bot: Bot, event: ActiveEvent, secondTry = fals
|
||||||
dbClient.execute(queries.deleteEvent, [event.channelId, event.messageId]).catch((e) => utils.commonLoggers.dbError('notificationSystem.ts@deleteSuccess', 'delete event from', e));
|
dbClient.execute(queries.deleteEvent, [event.channelId, event.messageId]).catch((e) => utils.commonLoggers.dbError('notificationSystem.ts@deleteSuccess', 'delete event from', e));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (!secondTry) loudLogFailure(bot, event, deleteStepName);
|
if (!secondTry) loudLogFailure(bot, event, deleteStepName).catch((e) => utils.commonLoggers.messageSendError('notificationSystem.ts@delete', 'loudLog Failed', e));
|
||||||
// Update DB to indicate delete failed
|
// Update DB to indicate delete failed
|
||||||
dbClient.execute(queries.updateEventFlags(-1, -1), [event.channelId, event.messageId]).catch((e) => utils.commonLoggers.dbError('notificationSystem.ts@deleteFail', 'update event in', e));
|
dbClient.execute(queries.updateEventFlags(-1, -1), [event.channelId, event.messageId]).catch((e) => utils.commonLoggers.dbError('notificationSystem.ts@deleteFail', 'update event in', e));
|
||||||
return false;
|
return false;
|
||||||
|
@ -232,7 +232,7 @@ export const handleFailures = async (bot: Bot, event: ActiveEvent) => {
|
||||||
|
|
||||||
if (!rerunSuccess) {
|
if (!rerunSuccess) {
|
||||||
// Failed at completing a step! Event may have been deleted?
|
// Failed at completing a step! Event may have been deleted?
|
||||||
loudLogFailure(bot, event, stepName, true);
|
loudLogFailure(bot, event, stepName, true).catch((e) => utils.commonLoggers.messageSendError('notificationSystem.ts@rerun', 'loudLog Failed', e));
|
||||||
dbClient.execute(queries.deleteEvent, [event.channelId, event.messageId]).catch((e) => utils.commonLoggers.dbError('notificationSystem.ts@handleFailures', 'delete event from', e));
|
dbClient.execute(queries.deleteEvent, [event.channelId, event.messageId]).catch((e) => utils.commonLoggers.dbError('notificationSystem.ts@handleFailures', 'delete event from', e));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue