sonar cleanup
This commit is contained in:
parent
5a8cd8e8bb
commit
d8b5f010c2
|
@ -111,7 +111,7 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
}).catch((e: Error) => utils.commonLoggers.interactionSendError('step1-gameSelection.ts:ping', interaction, e));
|
}).catch((e: Error) => utils.commonLoggers.interactionSendError('step1-gameSelection.ts:ping', interaction, e));
|
||||||
|
|
||||||
// Update the original game selector
|
// Update the original game selector
|
||||||
await bot.helpers.editOriginalInteractionResponse(tokenMap.get(generateMapId(interaction.guildId, interaction.channelId, interaction.member.id))?.token || '', {
|
await bot.helpers.editOriginalInteractionResponse(tokenMap.get(generateMapId(interaction.guildId, interaction.channelId, interaction.member.id))?.token ?? '', {
|
||||||
components: selectMenus,
|
components: selectMenus,
|
||||||
}).catch((e: Error) => utils.commonLoggers.interactionSendError('step1-gameSelection.ts:edit', interaction, e));
|
}).catch((e: Error) => utils.commonLoggers.interactionSendError('step1-gameSelection.ts:edit', interaction, e));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { queries } from '../../db/common.ts';
|
||||||
export const customId = 'finalize';
|
export const customId = 'finalize';
|
||||||
|
|
||||||
const execute = async (bot: Bot, interaction: Interaction) => {
|
const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
if (interaction.data?.components?.length && interaction.guildId && interaction.channelId && interaction.member && interaction.member.user) {
|
if (interaction.data?.components?.length && interaction.guildId && interaction.channelId && interaction?.member?.user) {
|
||||||
// User selected activity and has filled out fields, delete the selectMenus
|
// User selected activity and has filled out fields, delete the selectMenus
|
||||||
await deleteTokenEarly(bot, interaction, interaction.guildId, interaction.channelId, interaction.member.id);
|
await deleteTokenEarly(bot, interaction, interaction.guildId, interaction.channelId, interaction.member.id);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ export const customId = 'createEvent';
|
||||||
|
|
||||||
const execute = async (bot: Bot, interaction: Interaction) => {
|
const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
if (
|
if (
|
||||||
interaction.data?.customId && interaction.member && interaction.guildId && interaction.channelId && interaction.message && interaction.message.embeds[0] && interaction.message.embeds[0].fields
|
interaction.data?.customId && interaction.member && interaction.guildId && interaction.channelId && interaction?.message?.embeds?.[0]?.fields
|
||||||
) {
|
) {
|
||||||
// Light Telemetry
|
// Light Telemetry
|
||||||
dbClient.execute(queries.callIncCnt(interaction.data.customId.includes(idSeparator) ? 'btn-createWLEvt' : 'btn-createEvt')).catch((e) =>
|
dbClient.execute(queries.callIncCnt(interaction.data.customId.includes(idSeparator) ? 'btn-createWLEvt' : 'btn-createEvt')).catch((e) =>
|
||||||
|
|
|
@ -27,7 +27,7 @@ import { customId as editEventCustomId } from '../live-event/editEvent.ts';
|
||||||
|
|
||||||
export const getNestedActivity = (idxPath: Array<number>, activities: Array<Activity>): Array<Activity> => {
|
export const getNestedActivity = (idxPath: Array<number>, activities: Array<Activity>): Array<Activity> => {
|
||||||
const nextIdx = idxPath[0];
|
const nextIdx = idxPath[0];
|
||||||
if (idxPath.length && activities[nextIdx] && activities[nextIdx].options) {
|
if (idxPath.length && activities[nextIdx]?.options) {
|
||||||
idxPath.shift();
|
idxPath.shift();
|
||||||
return getNestedActivity(idxPath, activities[nextIdx].options || []);
|
return getNestedActivity(idxPath, activities[nextIdx].options || []);
|
||||||
} else {
|
} else {
|
||||||
|
@ -160,7 +160,7 @@ export const createLFGPost = (
|
||||||
name: 'Description:',
|
name: 'Description:',
|
||||||
value: eventDescription,
|
value: eventDescription,
|
||||||
}, {
|
}, {
|
||||||
name: generateMemberTitle(memberList, activity.maxMembers || 0),
|
name: generateMemberTitle(memberList, activity.maxMembers ?? 0),
|
||||||
value: generateMemberList(memberList),
|
value: generateMemberList(memberList),
|
||||||
inline: true,
|
inline: true,
|
||||||
}, {
|
}, {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { alternateMemberToEvent } from './utils.ts';
|
||||||
export const customId = 'alternateEvent';
|
export const customId = 'alternateEvent';
|
||||||
|
|
||||||
const execute = (bot: Bot, interaction: Interaction) => {
|
const execute = (bot: Bot, interaction: Interaction) => {
|
||||||
if (interaction.data?.customId && interaction.member && interaction.member.user && interaction.channelId && interaction.message && interaction.message.embeds[0]) {
|
if (interaction.data?.customId && interaction?.member?.user && interaction.channelId && interaction?.message?.embeds?.[0]) {
|
||||||
// Light Telemetry
|
// Light Telemetry
|
||||||
dbClient.execute(queries.callIncCnt('btn-altEvent')).catch((e) => utils.commonLoggers.dbError('alternateEvent.ts', 'call sproc INC_CNT on', e));
|
dbClient.execute(queries.callIncCnt('btn-altEvent')).catch((e) => utils.commonLoggers.dbError('alternateEvent.ts', 'call sproc INC_CNT on', e));
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { alternateMemberToEvent } from './utils.ts';
|
||||||
export const customId = 'alternateRequest';
|
export const customId = 'alternateRequest';
|
||||||
|
|
||||||
const execute = async (bot: Bot, interaction: Interaction) => {
|
const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
if (interaction.data?.customId && interaction.user && interaction.message && interaction.message.embeds[0] && interaction.message.embeds[0].description) {
|
if (interaction.data?.customId && interaction.user && interaction?.message?.embeds?.[0]?.description) {
|
||||||
// Light Telemetry
|
// Light Telemetry
|
||||||
dbClient.execute(queries.callIncCnt('btn-joinReqAlt')).catch((e) => utils.commonLoggers.dbError('alternateRequest.ts', 'call sproc INC_CNT on', e));
|
dbClient.execute(queries.callIncCnt('btn-joinReqAlt')).catch((e) => utils.commonLoggers.dbError('alternateRequest.ts', 'call sproc INC_CNT on', e));
|
||||||
|
|
||||||
|
|
|
@ -12,114 +12,133 @@ export const confirmedCustomId = 'confirmedCustomId';
|
||||||
export const confirmStr = 'yes';
|
export const confirmStr = 'yes';
|
||||||
|
|
||||||
const execute = async (bot: Bot, interaction: Interaction) => {
|
const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
if (interaction.data?.customId && interaction.data?.components?.length && interaction.channelId && interaction.guildId && interaction.member && interaction.member.user) {
|
if (interaction.data?.customId && interaction.data?.components?.length && interaction.channelId && interaction.guildId && interaction?.member?.user) {
|
||||||
// Light Telemetry
|
// Light Telemetry
|
||||||
dbClient.execute(queries.callIncCnt('btn-confirmDelEvent')).catch((e) => utils.commonLoggers.dbError('deleteConfirmed.ts@incCnt', 'call sproc INC_CNT on', e));
|
dbClient.execute(queries.callIncCnt('btn-confirmDelEvent')).catch((e) => utils.commonLoggers.dbError('deleteConfirmed.ts@incCnt', 'call sproc INC_CNT on', e));
|
||||||
|
|
||||||
// Parse out our data
|
// Parse out our data
|
||||||
const tempDataMap: Map<string, string> = new Map();
|
const tempDataMap: Map<string, string> = new Map();
|
||||||
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 || 'missingValue');
|
tempDataMap.set(textField.customId || 'missingCustomId', textField.value || 'missingValue');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const actionByManager = interaction.data.customId.endsWith(pathIdxEnder);
|
const actionByManager = interaction.data.customId.endsWith(pathIdxEnder);
|
||||||
const [evtChannelId, evtMessageId] = (interaction.data.customId.replaceAll(pathIdxEnder, '').split(idSeparator)[1] || '').split(pathIdxSeparator).map((id) => BigInt(id || '0'));
|
const [evtChannelId, evtMessageId] = (interaction.data.customId.replaceAll(pathIdxEnder, '').split(idSeparator)[1] || '').split(pathIdxSeparator).map((id) => BigInt(id || '0'));
|
||||||
const lfgChannelSetting = lfgChannelSettings.get(generateGuildSettingKey(interaction.guildId, interaction.channelId)) || {
|
const lfgChannelSetting = lfgChannelSettings.get(generateGuildSettingKey(interaction.guildId, interaction.channelId)) || {
|
||||||
managed: false,
|
managed: false,
|
||||||
managerRoleId: 0n,
|
managerRoleId: 0n,
|
||||||
logChannelId: 0n,
|
logChannelId: 0n,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (tempDataMap.get(confirmedCustomId)?.toLowerCase() === confirmStr) {
|
if (tempDataMap.get(confirmedCustomId)?.toLowerCase() === confirmStr) {
|
||||||
const guildName = await getGuildName(bot, interaction.guildId);
|
const guildName = await getGuildName(bot, interaction.guildId);
|
||||||
const eventMessage = await bot.helpers.getMessage(evtChannelId, evtMessageId).catch((e: Error) => utils.commonLoggers.messageGetError('deleteConfirmed.ts', 'get eventMessage', e));
|
const eventMessage = await bot.helpers.getMessage(evtChannelId, evtMessageId).catch((e: Error) => utils.commonLoggers.messageGetError('deleteConfirmed.ts', 'get eventMessage', e));
|
||||||
const userId = interaction.member.id;
|
const userId = interaction.member.id;
|
||||||
const userName = interaction.member.user.username;
|
const userName = interaction.member.user.username;
|
||||||
// Delete event
|
// Delete event
|
||||||
bot.helpers.deleteMessage(evtChannelId, evtMessageId, 'User deleted event').then(() => {
|
bot.helpers
|
||||||
dbClient.execute(queries.deleteEvent, [evtChannelId, evtMessageId]).catch((e) => utils.commonLoggers.dbError('deleteConfirmed.ts@deleteEvent', 'delete event from', e));
|
.deleteMessage(evtChannelId, evtMessageId, 'User deleted event')
|
||||||
|
.then(() => {
|
||||||
|
dbClient.execute(queries.deleteEvent, [evtChannelId, evtMessageId]).catch((e) => utils.commonLoggers.dbError('deleteConfirmed.ts@deleteEvent', 'delete event from', e));
|
||||||
|
|
||||||
// Acknowledge user so discord doesn't get annoyed
|
// Acknowledge user so discord doesn't get annoyed
|
||||||
bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
bot.helpers
|
||||||
type: InteractionResponseTypes.ChannelMessageWithSource,
|
.sendInteractionResponse(interaction.id, interaction.token, {
|
||||||
data: {
|
type: InteractionResponseTypes.ChannelMessageWithSource,
|
||||||
flags: ApplicationCommandFlags.Ephemeral,
|
data: {
|
||||||
embeds: [{
|
flags: ApplicationCommandFlags.Ephemeral,
|
||||||
color: successColor,
|
embeds: [
|
||||||
title: 'Event successfully deleted.',
|
{
|
||||||
description: safelyDismissMsg,
|
color: successColor,
|
||||||
}],
|
title: 'Event successfully deleted.',
|
||||||
},
|
description: safelyDismissMsg,
|
||||||
}).catch((e: Error) => utils.commonLoggers.interactionSendError('deleteConfirmed.ts', interaction, e));
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.catch((e: Error) => utils.commonLoggers.interactionSendError('deleteConfirmed.ts', interaction, e));
|
||||||
|
|
||||||
if (actionByManager) {
|
if (actionByManager) {
|
||||||
const ownerId = BigInt(eventMessage?.embeds[0].footer?.iconUrl?.split('#')[1] || '0');
|
const ownerId = BigInt(eventMessage?.embeds[0].footer?.iconUrl?.split('#')[1] || '0');
|
||||||
const eventEmbed = eventMessage?.embeds[0] || { title: 'Event not found', color: failColor };
|
const eventEmbed = eventMessage?.embeds[0] || { title: 'Event not found', color: failColor };
|
||||||
bot.helpers.sendMessage(lfgChannelSetting.logChannelId, {
|
bot.helpers
|
||||||
embeds: [{
|
.sendMessage(lfgChannelSetting.logChannelId, {
|
||||||
color: infoColor2,
|
embeds: [
|
||||||
title: `Event deleted by a ${config.name} Manager`,
|
{
|
||||||
description: `The following event was deleted by ${userName} - <@${userId}>.`,
|
color: infoColor2,
|
||||||
timestamp: new Date().getTime(),
|
title: `Event deleted by a ${config.name} Manager`,
|
||||||
}, eventEmbed],
|
description: `The following event was deleted by ${userName} - <@${userId}>.`,
|
||||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('deleteConfirmed.ts', 'send log message', e));
|
timestamp: new Date().getTime(),
|
||||||
|
},
|
||||||
|
eventEmbed,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
.catch((e: Error) => utils.commonLoggers.messageSendError('deleteConfirmed.ts', 'send log message', e));
|
||||||
|
|
||||||
sendDirectMessage(bot, ownerId, {
|
sendDirectMessage(bot, ownerId, {
|
||||||
embeds: [{
|
embeds: [
|
||||||
color: infoColor2,
|
{
|
||||||
title: `Notice: A ${config.name} Manager has deleted one of your events in ${guildName}`,
|
color: infoColor2,
|
||||||
description: 'The deleted event is listed below.',
|
title: `Notice: A ${config.name} Manager has deleted one of your events in ${guildName}`,
|
||||||
fields: [
|
description: 'The deleted event is listed below.',
|
||||||
{
|
fields: [
|
||||||
name: `${config.name} Manager:`,
|
{
|
||||||
value: generateMemberList([{
|
name: `${config.name} Manager:`,
|
||||||
id: userId,
|
value: generateMemberList([
|
||||||
name: userName,
|
{
|
||||||
}]),
|
id: userId,
|
||||||
inline: true,
|
name: userName,
|
||||||
},
|
},
|
||||||
{
|
]),
|
||||||
name: 'Are you unhappy with this action?',
|
inline: true,
|
||||||
value: `Please reach out to the ${config.name} Manager that performed this action, or the moderators/administrators of ${guildName}.`,
|
},
|
||||||
},
|
{
|
||||||
],
|
name: 'Are you unhappy with this action?',
|
||||||
}, eventEmbed],
|
value: `Please reach out to the ${config.name} Manager that performed this action, or the moderators/administrators of ${guildName}.`,
|
||||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('deleteConfirmed.ts', 'send DM fail', e));
|
},
|
||||||
}
|
],
|
||||||
}).catch((e) => {
|
},
|
||||||
utils.commonLoggers.messageDeleteError('deleteConfirmed.ts', 'deleteEventFailedDB', e);
|
eventEmbed,
|
||||||
somethingWentWrong(bot, interaction, 'deleteEventMessageInDeleteConfirmedButton');
|
],
|
||||||
});
|
}).catch((e: Error) => utils.commonLoggers.messageSendError('deleteConfirmed.ts', 'send DM fail', e));
|
||||||
} else {
|
}
|
||||||
// User either did not type yes confirm field was missing, lets see which it was
|
})
|
||||||
if (tempDataMap.get(confirmedCustomId)) {
|
.catch((e) => {
|
||||||
// User did not type yes.
|
utils.commonLoggers.messageDeleteError('deleteConfirmed.ts', 'deleteEventFailedDB', e);
|
||||||
bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
somethingWentWrong(bot, interaction, 'deleteEventMessageInDeleteConfirmedButton');
|
||||||
type: InteractionResponseTypes.ChannelMessageWithSource,
|
});
|
||||||
data: {
|
} else if (tempDataMap.get(confirmedCustomId)) {
|
||||||
flags: ApplicationCommandFlags.Ephemeral,
|
// User either did not type yes confirm field was missing, lets see which it was
|
||||||
embeds: [{
|
// User did not type yes.
|
||||||
color: infoColor1,
|
bot.helpers
|
||||||
title: 'Event not deleted.',
|
.sendInteractionResponse(interaction.id, interaction.token, {
|
||||||
description: `If you are trying to delete the event, please make sure you type \`${confirmStr}\` into the field provided.
|
type: InteractionResponseTypes.ChannelMessageWithSource,
|
||||||
|
data: {
|
||||||
|
flags: ApplicationCommandFlags.Ephemeral,
|
||||||
|
embeds: [
|
||||||
|
{
|
||||||
|
color: infoColor1,
|
||||||
|
title: 'Event not deleted.',
|
||||||
|
description: `If you are trying to delete the event, please make sure you type \`${confirmStr}\` into the field provided.
|
||||||
|
|
||||||
${safelyDismissMsg}`,
|
${safelyDismissMsg}`,
|
||||||
}],
|
},
|
||||||
},
|
],
|
||||||
}).catch((e: Error) => utils.commonLoggers.interactionSendError('deleteConfirmed.ts', interaction, e));
|
},
|
||||||
} else {
|
})
|
||||||
// Field was missing
|
.catch((e: Error) => utils.commonLoggers.interactionSendError('deleteConfirmed.ts', interaction, e));
|
||||||
somethingWentWrong(bot, interaction, 'noIdsFromDeleteConfirmedButton');
|
} else {
|
||||||
}
|
// Field was missing
|
||||||
}
|
somethingWentWrong(bot, interaction, 'noIdsFromDeleteConfirmedButton');
|
||||||
} else {
|
}
|
||||||
somethingWentWrong(bot, interaction, 'noDataFromDeleteConfirmedButton');
|
} else {
|
||||||
}
|
somethingWentWrong(bot, interaction, 'noDataFromDeleteConfirmedButton');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deleteConfirmedButton = {
|
export const deleteConfirmedButton = {
|
||||||
customId,
|
customId,
|
||||||
execute,
|
execute,
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,7 +9,7 @@ import utils from '../../utils.ts';
|
||||||
export const customId = 'deleteEvent';
|
export const customId = 'deleteEvent';
|
||||||
|
|
||||||
const execute = (bot: Bot, interaction: Interaction) => {
|
const execute = (bot: Bot, interaction: Interaction) => {
|
||||||
if (interaction.data?.customId && interaction.member && interaction.member.user && interaction.channelId && interaction.guildId && interaction.message && interaction.message.embeds[0]) {
|
if (interaction.data?.customId && interaction?.member?.user && interaction.channelId && interaction.guildId && interaction?.message?.embeds?.[0]) {
|
||||||
// Light Telemetry
|
// Light Telemetry
|
||||||
dbClient.execute(queries.callIncCnt('btn-delEvent')).catch((e) => utils.commonLoggers.dbError('deleteEvent.ts', 'call sproc INC_CNT on', e));
|
dbClient.execute(queries.callIncCnt('btn-delEvent')).catch((e) => utils.commonLoggers.dbError('deleteEvent.ts', 'call sproc INC_CNT on', e));
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
!selectedActivity.maxMembers || !selectedCategory || !selectedActivity.name || (isNaN(selectedActivity.maxMembers) || (selectedActivity.maxMembers < 1 || selectedActivity.maxMembers > 99))
|
!selectedActivity.maxMembers || !selectedCategory || !selectedActivity.name || (isNaN(selectedActivity.maxMembers) || (selectedActivity.maxMembers < 1 || selectedActivity.maxMembers > 99))
|
||||||
) {
|
) {
|
||||||
// Verify fields exist
|
// Verify fields exist
|
||||||
somethingWentWrong(bot, interaction, `parseFailInEditCustomActivity@${selectedCategory}|${selectedActivity.name}|${selectedActivity.maxMembers || 'undefined'}$`);
|
somethingWentWrong(bot, interaction, `parseFailInEditCustomActivity@${selectedCategory}|${selectedActivity.name}|${selectedActivity.maxMembers ?? 'undefined'}$`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
}).catch((e: Error) => utils.commonLoggers.interactionSendError('editActivity.ts@ping', interaction, e));
|
}).catch((e: Error) => utils.commonLoggers.interactionSendError('editActivity.ts@ping', interaction, e));
|
||||||
|
|
||||||
// Update the original game selector
|
// Update the original game selector
|
||||||
await bot.helpers.editOriginalInteractionResponse(tokenMap.get(generateMapId(interaction.guildId, interaction.channelId, interaction.member.id))?.token || '', {
|
await bot.helpers.editOriginalInteractionResponse(tokenMap.get(generateMapId(interaction.guildId, interaction.channelId, interaction.member.id))?.token ?? '', {
|
||||||
components: selectMenus,
|
components: selectMenus,
|
||||||
}).catch((e: Error) => utils.commonLoggers.interactionSendError('editActivity.ts@edit', interaction, e));
|
}).catch((e: Error) => utils.commonLoggers.interactionSendError('editActivity.ts@edit', interaction, e));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -14,8 +14,7 @@ export const customId = 'editEvent';
|
||||||
|
|
||||||
const execute = (bot: Bot, interaction: Interaction) => {
|
const execute = (bot: Bot, interaction: Interaction) => {
|
||||||
if (
|
if (
|
||||||
interaction.data?.customId && interaction.member && interaction.channelId && interaction.guildId && interaction.message && interaction.message.components &&
|
interaction.data?.customId && interaction.member && interaction.channelId && interaction.guildId && interaction?.message?.components?.[0].components
|
||||||
interaction.message.components[0].components
|
|
||||||
) {
|
) {
|
||||||
// Light Telemetry
|
// Light Telemetry
|
||||||
dbClient.execute(queries.callIncCnt('btn-editEvent')).catch((e) => utils.commonLoggers.dbError('editEvent.ts', 'call sproc INC_CNT on', e));
|
dbClient.execute(queries.callIncCnt('btn-editEvent')).catch((e) => utils.commonLoggers.dbError('editEvent.ts', 'call sproc INC_CNT on', e));
|
||||||
|
|
|
@ -11,8 +11,7 @@ export const customId = 'joinEvent';
|
||||||
|
|
||||||
const execute = async (bot: Bot, interaction: Interaction) => {
|
const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
if (
|
if (
|
||||||
interaction.data?.customId && interaction.member && interaction.member.user && interaction.channelId && interaction.guildId && interaction.message && interaction.message.embeds[0] &&
|
interaction.data?.customId && interaction?.member?.user && interaction.channelId && interaction.guildId && interaction?.message?.embeds?.[0]?.fields
|
||||||
interaction.message.embeds[0].fields
|
|
||||||
) {
|
) {
|
||||||
// Light Telemetry
|
// Light Telemetry
|
||||||
dbClient.execute(queries.callIncCnt(interaction.data.customId.includes(idSeparator) ? 'btn-joinWLEvent' : 'btn-joinEvent')).catch((e) =>
|
dbClient.execute(queries.callIncCnt(interaction.data.customId.includes(idSeparator) ? 'btn-joinWLEvent' : 'btn-joinEvent')).catch((e) =>
|
||||||
|
@ -62,7 +61,7 @@ ${safelyDismissMsg}`,
|
||||||
|
|
||||||
If this request is urgent, please speak with${urgentManagerStr}the owner of [this event](${messageUrl}), <@${ownerId}>, to resolve the issue.
|
If this request is urgent, please speak with${urgentManagerStr}the owner of [this event](${messageUrl}), <@${ownerId}>, to resolve the issue.
|
||||||
|
|
||||||
The status of your recent Join Request for [this event](${messageUrl}) is: \`${joinRequestMap.get(joinRequestKey)?.status || 'Failed to retrieve status'}\`
|
The status of your recent Join Request for [this event](${messageUrl}) is: \`${joinRequestMap.get(joinRequestKey)?.status ?? 'Failed to retrieve status'}\`
|
||||||
|
|
||||||
${safelyDismissMsg}`,
|
${safelyDismissMsg}`,
|
||||||
}],
|
}],
|
||||||
|
|
|
@ -13,8 +13,7 @@ export const denyStr = 'denied';
|
||||||
|
|
||||||
const execute = async (bot: Bot, interaction: Interaction) => {
|
const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
if (
|
if (
|
||||||
interaction.data?.customId && interaction.user && interaction.channelId && interaction.message && interaction.message.embeds[0] && interaction.message.embeds[0].fields &&
|
interaction.data?.customId && interaction.user && interaction.channelId && interaction?.message?.embeds?.[0]?.fields && interaction?.message?.embeds?.[0]?.description
|
||||||
interaction.message.embeds[0].description
|
|
||||||
) {
|
) {
|
||||||
const memberRequesting = getLfgMembers(interaction.message.embeds[0].fields[0].value || '')[0];
|
const memberRequesting = getLfgMembers(interaction.message.embeds[0].fields[0].value || '')[0];
|
||||||
const approved = interaction.data.customId.includes(approveStr);
|
const approved = interaction.data.customId.includes(approveStr);
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { removeMemberFromEvent } from './utils.ts';
|
||||||
export const customId = 'leaveEvent';
|
export const customId = 'leaveEvent';
|
||||||
|
|
||||||
const execute = (bot: Bot, interaction: Interaction) => {
|
const execute = (bot: Bot, interaction: Interaction) => {
|
||||||
if (interaction.data?.customId && interaction.member && interaction.channelId && interaction.guildId && interaction.message && interaction.message.embeds[0]) {
|
if (interaction.data?.customId && interaction.member && interaction.channelId && interaction.guildId && interaction?.message?.embeds?.[0]) {
|
||||||
// Light Telemetry
|
// Light Telemetry
|
||||||
dbClient.execute(queries.callIncCnt('btn-leaveEvent')).catch((e) => utils.commonLoggers.dbError('leaveEvent.ts', 'call sproc INC_CNT on', e));
|
dbClient.execute(queries.callIncCnt('btn-leaveEvent')).catch((e) => utils.commonLoggers.dbError('leaveEvent.ts', 'call sproc INC_CNT on', e));
|
||||||
|
|
||||||
|
|
|
@ -129,9 +129,9 @@ ${safelyDismissMsg}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Generic no response response
|
// Generic no response response
|
||||||
const noEdit = (bot: Bot, interaction: Interaction, loudAcknowledge: boolean) => {
|
const noEdit = async (bot: Bot, interaction: Interaction, loudAcknowledge: boolean) => {
|
||||||
if (loudAcknowledge) {
|
if (loudAcknowledge) {
|
||||||
bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
await bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
||||||
type: InteractionResponseTypes.ChannelMessageWithSource,
|
type: InteractionResponseTypes.ChannelMessageWithSource,
|
||||||
data: {
|
data: {
|
||||||
flags: ApplicationCommandFlags.Ephemeral,
|
flags: ApplicationCommandFlags.Ephemeral,
|
||||||
|
@ -145,7 +145,7 @@ ${safelyDismissMsg}`,
|
||||||
},
|
},
|
||||||
}).catch((e: Error) => utils.commonLoggers.interactionSendError('utils.ts', interaction, e));
|
}).catch((e: Error) => utils.commonLoggers.interactionSendError('utils.ts', interaction, e));
|
||||||
} else {
|
} else {
|
||||||
bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
await bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
||||||
type: InteractionResponseTypes.DeferredUpdateMessage,
|
type: InteractionResponseTypes.DeferredUpdateMessage,
|
||||||
}).catch((e: Error) => utils.commonLoggers.interactionSendError('utils.ts', interaction, e));
|
}).catch((e: Error) => utils.commonLoggers.interactionSendError('utils.ts', interaction, e));
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ const details: CommandDetails = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const execute = async (bot: Bot, interaction: Interaction) => {
|
const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
if (interaction.data?.options?.[0].options && interaction.channelId && interaction.guildId && interaction.member && interaction.member.user) {
|
if (interaction.data?.options?.[0].options && interaction.channelId && interaction.guildId && interaction?.member?.user) {
|
||||||
// Get action and log to db
|
// Get action and log to db
|
||||||
const actionName = interaction.data.options[0].name;
|
const actionName = interaction.data.options[0].name;
|
||||||
dbClient.execute(queries.callIncCnt(`cmd-${actionName}`)).catch((e) => utils.commonLoggers.dbError('managerJLA.ts', 'call sproc INC_CNT on', e));
|
dbClient.execute(queries.callIncCnt(`cmd-${actionName}`)).catch((e) => utils.commonLoggers.dbError('managerJLA.ts', 'call sproc INC_CNT on', e));
|
||||||
|
|
|
@ -241,7 +241,7 @@ The Discord Slash Command system will ensure you provide all the required detail
|
||||||
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?.text.includes('Created by:')) {
|
||||||
oldLfgMsgs.push(msg.id);
|
oldLfgMsgs.push(msg.id);
|
||||||
} else {
|
} else {
|
||||||
msgsToDel.push(msg.id);
|
msgsToDel.push(msg.id);
|
||||||
|
@ -266,7 +266,7 @@ The Discord Slash Command system will ensure you provide all the required detail
|
||||||
oldEvent.embeds[0].fields[LfgEmbedIndexes.StartTime].value = generateTimeFieldStr(eventDateTimeStr, eventDateTime);
|
oldEvent.embeds[0].fields[LfgEmbedIndexes.StartTime].value = generateTimeFieldStr(eventDateTimeStr, eventDateTime);
|
||||||
oldEvent.embeds[0].footer.text = oldEvent.embeds[0].footer.text.split(' | ')[0];
|
oldEvent.embeds[0].footer.text = oldEvent.embeds[0].footer.text.split(' | ')[0];
|
||||||
const ownerName = oldEvent.embeds[0].footer.text.split(': ')[1];
|
const ownerName = oldEvent.embeds[0].footer.text.split(': ')[1];
|
||||||
const ownerId = eventMembers.find((member) => ownerName === member.name)?.id || 0n;
|
const ownerId = eventMembers.find((member) => ownerName === member.name)?.id ?? 0n;
|
||||||
oldEvent.embeds[0].footer.iconUrl = `${config.links.creatorIcon}#${ownerId}`;
|
oldEvent.embeds[0].footer.iconUrl = `${config.links.creatorIcon}#${ownerId}`;
|
||||||
bot.helpers.editMessage(oldEvent.channelId, oldEvent.id, {
|
bot.helpers.editMessage(oldEvent.channelId, oldEvent.id, {
|
||||||
content: '',
|
content: '',
|
||||||
|
|
|
@ -11,7 +11,7 @@ const tzOverrides: Array<Array<string>> = [
|
||||||
['PST', '-08:00'],
|
['PST', '-08:00'],
|
||||||
['IST', '+05:30'],
|
['IST', '+05:30'],
|
||||||
];
|
];
|
||||||
const abbrOverrides: Array<string> = tzOverrides.map(tzSet => tzSet[0]);
|
const abbrOverrides: Array<string> = tzOverrides.map((tzSet) => tzSet[0]);
|
||||||
|
|
||||||
// Prefill the map
|
// Prefill the map
|
||||||
for (const override of tzOverrides) {
|
for (const override of tzOverrides) {
|
||||||
|
@ -22,11 +22,9 @@ for (const override of tzOverrides) {
|
||||||
const attemptAdd = (tzAbbr: string, tzOffset: string) => {
|
const attemptAdd = (tzAbbr: string, tzOffset: string) => {
|
||||||
if (!abbrOverrides.includes(tzAbbr)) {
|
if (!abbrOverrides.includes(tzAbbr)) {
|
||||||
if (tzMap.has(tzAbbr) && tzMap.get(tzAbbr) !== tzOffset) {
|
if (tzMap.has(tzAbbr) && tzMap.get(tzAbbr) !== tzOffset) {
|
||||||
console.error(`DOUBLED TZ ABBR WITH DIFF OFFSETS: ${tzAbbr} | ${tzOffset} | ${tzMap.get(tzAbbr)}`)
|
console.error(`DOUBLED TZ ABBR WITH DIFF OFFSETS: ${tzAbbr} | ${tzOffset} | ${tzMap.get(tzAbbr)}`);
|
||||||
} else {
|
} else if (!tzAbbr.includes('+') && !tzAbbr.includes('-')) {
|
||||||
if (!tzAbbr.includes('+') && !tzAbbr.includes('-')) {
|
tzMap.set(tzAbbr, tzOffset);
|
||||||
tzMap.set(tzAbbr, tzOffset);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -34,10 +32,10 @@ const attemptAdd = (tzAbbr: string, tzOffset: string) => {
|
||||||
// Get each TZ from the csv
|
// Get each TZ from the csv
|
||||||
for (const row of csvRows) {
|
for (const row of csvRows) {
|
||||||
const [rawSTDOffset, rawDSTOffset, rawSTDAbbr, rawDSTAbbr] = row.replaceAll('?', '-').toUpperCase().split(',');
|
const [rawSTDOffset, rawDSTOffset, rawSTDAbbr, rawDSTAbbr] = row.replaceAll('?', '-').toUpperCase().split(',');
|
||||||
const STDOffset = (rawSTDOffset || '');
|
const STDOffset = rawSTDOffset || '';
|
||||||
const DSTOffset = (rawDSTOffset || '');
|
const DSTOffset = rawDSTOffset || '';
|
||||||
const STDAbbr = (rawSTDAbbr || '');
|
const STDAbbr = rawSTDAbbr || '';
|
||||||
const DSTAbbr = (rawDSTAbbr || '');
|
const DSTAbbr = rawDSTAbbr || '';
|
||||||
|
|
||||||
attemptAdd(STDAbbr, STDOffset);
|
attemptAdd(STDAbbr, STDOffset);
|
||||||
if (STDAbbr !== DSTAbbr) {
|
if (STDAbbr !== DSTAbbr) {
|
||||||
|
@ -47,7 +45,7 @@ for (const row of csvRows) {
|
||||||
|
|
||||||
// Log it out to copy to source
|
// Log it out to copy to source
|
||||||
const tzIt = tzMap.entries();
|
const tzIt = tzMap.entries();
|
||||||
let tzVal = tzIt.next()
|
let tzVal = tzIt.next();
|
||||||
while (!tzVal.done) {
|
while (!tzVal.done) {
|
||||||
if (tzVal.value[0]) {
|
if (tzVal.value[0]) {
|
||||||
console.log(`['${tzVal.value[0]}','${tzVal.value[1]}'],`);
|
console.log(`['${tzVal.value[0]}','${tzVal.value[1]}'],`);
|
||||||
|
|
Loading…
Reference in New Issue