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));
|
||||
|
||||
// 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,
|
||||
}).catch((e: Error) => utils.commonLoggers.interactionSendError('step1-gameSelection.ts:edit', interaction, e));
|
||||
} else {
|
||||
|
|
|
@ -12,7 +12,7 @@ import { queries } from '../../db/common.ts';
|
|||
export const customId = 'finalize';
|
||||
|
||||
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
|
||||
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) => {
|
||||
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
|
||||
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> => {
|
||||
const nextIdx = idxPath[0];
|
||||
if (idxPath.length && activities[nextIdx] && activities[nextIdx].options) {
|
||||
if (idxPath.length && activities[nextIdx]?.options) {
|
||||
idxPath.shift();
|
||||
return getNestedActivity(idxPath, activities[nextIdx].options || []);
|
||||
} else {
|
||||
|
@ -160,7 +160,7 @@ export const createLFGPost = (
|
|||
name: 'Description:',
|
||||
value: eventDescription,
|
||||
}, {
|
||||
name: generateMemberTitle(memberList, activity.maxMembers || 0),
|
||||
name: generateMemberTitle(memberList, activity.maxMembers ?? 0),
|
||||
value: generateMemberList(memberList),
|
||||
inline: true,
|
||||
}, {
|
||||
|
|
|
@ -8,7 +8,7 @@ import { alternateMemberToEvent } from './utils.ts';
|
|||
export const customId = 'alternateEvent';
|
||||
|
||||
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
|
||||
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';
|
||||
|
||||
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
|
||||
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';
|
||||
|
||||
const execute = async (bot: Bot, interaction: Interaction) => {
|
||||
if (interaction.data?.customId && interaction.data?.components?.length && interaction.channelId && interaction.guildId && interaction.member && interaction.member.user) {
|
||||
// Light Telemetry
|
||||
dbClient.execute(queries.callIncCnt('btn-confirmDelEvent')).catch((e) => utils.commonLoggers.dbError('deleteConfirmed.ts@incCnt', 'call sproc INC_CNT on', e));
|
||||
if (interaction.data?.customId && interaction.data?.components?.length && interaction.channelId && interaction.guildId && interaction?.member?.user) {
|
||||
// Light Telemetry
|
||||
dbClient.execute(queries.callIncCnt('btn-confirmDelEvent')).catch((e) => utils.commonLoggers.dbError('deleteConfirmed.ts@incCnt', 'call sproc INC_CNT on', e));
|
||||
|
||||
// Parse out our data
|
||||
const tempDataMap: Map<string, string> = new Map();
|
||||
for (const row of interaction.data.components) {
|
||||
if (row.components?.[0]) {
|
||||
const textField = row.components[0];
|
||||
tempDataMap.set(textField.customId || 'missingCustomId', textField.value || 'missingValue');
|
||||
}
|
||||
}
|
||||
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 lfgChannelSetting = lfgChannelSettings.get(generateGuildSettingKey(interaction.guildId, interaction.channelId)) || {
|
||||
managed: false,
|
||||
managerRoleId: 0n,
|
||||
logChannelId: 0n,
|
||||
};
|
||||
// Parse out our data
|
||||
const tempDataMap: Map<string, string> = new Map();
|
||||
for (const row of interaction.data.components) {
|
||||
if (row.components?.[0]) {
|
||||
const textField = row.components[0];
|
||||
tempDataMap.set(textField.customId || 'missingCustomId', textField.value || 'missingValue');
|
||||
}
|
||||
}
|
||||
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 lfgChannelSetting = lfgChannelSettings.get(generateGuildSettingKey(interaction.guildId, interaction.channelId)) || {
|
||||
managed: false,
|
||||
managerRoleId: 0n,
|
||||
logChannelId: 0n,
|
||||
};
|
||||
|
||||
if (tempDataMap.get(confirmedCustomId)?.toLowerCase() === confirmStr) {
|
||||
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 userId = interaction.member.id;
|
||||
const userName = interaction.member.user.username;
|
||||
// Delete event
|
||||
bot.helpers.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));
|
||||
if (tempDataMap.get(confirmedCustomId)?.toLowerCase() === confirmStr) {
|
||||
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 userId = interaction.member.id;
|
||||
const userName = interaction.member.user.username;
|
||||
// Delete event
|
||||
bot.helpers
|
||||
.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
|
||||
bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
||||
type: InteractionResponseTypes.ChannelMessageWithSource,
|
||||
data: {
|
||||
flags: ApplicationCommandFlags.Ephemeral,
|
||||
embeds: [{
|
||||
color: successColor,
|
||||
title: 'Event successfully deleted.',
|
||||
description: safelyDismissMsg,
|
||||
}],
|
||||
},
|
||||
}).catch((e: Error) => utils.commonLoggers.interactionSendError('deleteConfirmed.ts', interaction, e));
|
||||
// Acknowledge user so discord doesn't get annoyed
|
||||
bot.helpers
|
||||
.sendInteractionResponse(interaction.id, interaction.token, {
|
||||
type: InteractionResponseTypes.ChannelMessageWithSource,
|
||||
data: {
|
||||
flags: ApplicationCommandFlags.Ephemeral,
|
||||
embeds: [
|
||||
{
|
||||
color: successColor,
|
||||
title: 'Event successfully deleted.',
|
||||
description: safelyDismissMsg,
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.interactionSendError('deleteConfirmed.ts', interaction, e));
|
||||
|
||||
if (actionByManager) {
|
||||
const ownerId = BigInt(eventMessage?.embeds[0].footer?.iconUrl?.split('#')[1] || '0');
|
||||
const eventEmbed = eventMessage?.embeds[0] || { title: 'Event not found', color: failColor };
|
||||
bot.helpers.sendMessage(lfgChannelSetting.logChannelId, {
|
||||
embeds: [{
|
||||
color: infoColor2,
|
||||
title: `Event deleted by a ${config.name} Manager`,
|
||||
description: `The following event was deleted by ${userName} - <@${userId}>.`,
|
||||
timestamp: new Date().getTime(),
|
||||
}, eventEmbed],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('deleteConfirmed.ts', 'send log message', e));
|
||||
if (actionByManager) {
|
||||
const ownerId = BigInt(eventMessage?.embeds[0].footer?.iconUrl?.split('#')[1] || '0');
|
||||
const eventEmbed = eventMessage?.embeds[0] || { title: 'Event not found', color: failColor };
|
||||
bot.helpers
|
||||
.sendMessage(lfgChannelSetting.logChannelId, {
|
||||
embeds: [
|
||||
{
|
||||
color: infoColor2,
|
||||
title: `Event deleted by a ${config.name} Manager`,
|
||||
description: `The following event was deleted by ${userName} - <@${userId}>.`,
|
||||
timestamp: new Date().getTime(),
|
||||
},
|
||||
eventEmbed,
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('deleteConfirmed.ts', 'send log message', e));
|
||||
|
||||
sendDirectMessage(bot, ownerId, {
|
||||
embeds: [{
|
||||
color: infoColor2,
|
||||
title: `Notice: A ${config.name} Manager has deleted one of your events in ${guildName}`,
|
||||
description: 'The deleted event is listed below.',
|
||||
fields: [
|
||||
{
|
||||
name: `${config.name} Manager:`,
|
||||
value: generateMemberList([{
|
||||
id: userId,
|
||||
name: userName,
|
||||
}]),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: 'Are you unhappy with this action?',
|
||||
value: `Please reach out to the ${config.name} Manager that performed this action, or the moderators/administrators of ${guildName}.`,
|
||||
},
|
||||
],
|
||||
}, eventEmbed],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('deleteConfirmed.ts', 'send DM fail', e));
|
||||
}
|
||||
}).catch((e) => {
|
||||
utils.commonLoggers.messageDeleteError('deleteConfirmed.ts', 'deleteEventFailedDB', e);
|
||||
somethingWentWrong(bot, interaction, 'deleteEventMessageInDeleteConfirmedButton');
|
||||
});
|
||||
} else {
|
||||
// User either did not type yes confirm field was missing, lets see which it was
|
||||
if (tempDataMap.get(confirmedCustomId)) {
|
||||
// User did not type yes.
|
||||
bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
||||
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.
|
||||
sendDirectMessage(bot, ownerId, {
|
||||
embeds: [
|
||||
{
|
||||
color: infoColor2,
|
||||
title: `Notice: A ${config.name} Manager has deleted one of your events in ${guildName}`,
|
||||
description: 'The deleted event is listed below.',
|
||||
fields: [
|
||||
{
|
||||
name: `${config.name} Manager:`,
|
||||
value: generateMemberList([
|
||||
{
|
||||
id: userId,
|
||||
name: userName,
|
||||
},
|
||||
]),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: 'Are you unhappy with this action?',
|
||||
value: `Please reach out to the ${config.name} Manager that performed this action, or the moderators/administrators of ${guildName}.`,
|
||||
},
|
||||
],
|
||||
},
|
||||
eventEmbed,
|
||||
],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('deleteConfirmed.ts', 'send DM fail', e));
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
utils.commonLoggers.messageDeleteError('deleteConfirmed.ts', 'deleteEventFailedDB', e);
|
||||
somethingWentWrong(bot, interaction, 'deleteEventMessageInDeleteConfirmedButton');
|
||||
});
|
||||
} else if (tempDataMap.get(confirmedCustomId)) {
|
||||
// User either did not type yes confirm field was missing, lets see which it was
|
||||
// User did not type yes.
|
||||
bot.helpers
|
||||
.sendInteractionResponse(interaction.id, interaction.token, {
|
||||
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}`,
|
||||
}],
|
||||
},
|
||||
}).catch((e: Error) => utils.commonLoggers.interactionSendError('deleteConfirmed.ts', interaction, e));
|
||||
} else {
|
||||
// Field was missing
|
||||
somethingWentWrong(bot, interaction, 'noIdsFromDeleteConfirmedButton');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
somethingWentWrong(bot, interaction, 'noDataFromDeleteConfirmedButton');
|
||||
}
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.interactionSendError('deleteConfirmed.ts', interaction, e));
|
||||
} else {
|
||||
// Field was missing
|
||||
somethingWentWrong(bot, interaction, 'noIdsFromDeleteConfirmedButton');
|
||||
}
|
||||
} else {
|
||||
somethingWentWrong(bot, interaction, 'noDataFromDeleteConfirmedButton');
|
||||
}
|
||||
};
|
||||
|
||||
export const deleteConfirmedButton = {
|
||||
customId,
|
||||
execute,
|
||||
customId,
|
||||
execute,
|
||||
};
|
||||
|
|
|
@ -9,7 +9,7 @@ import utils from '../../utils.ts';
|
|||
export const customId = 'deleteEvent';
|
||||
|
||||
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
|
||||
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))
|
||||
) {
|
||||
// Verify fields exist
|
||||
somethingWentWrong(bot, interaction, `parseFailInEditCustomActivity@${selectedCategory}|${selectedActivity.name}|${selectedActivity.maxMembers || 'undefined'}$`);
|
||||
somethingWentWrong(bot, interaction, `parseFailInEditCustomActivity@${selectedCategory}|${selectedActivity.name}|${selectedActivity.maxMembers ?? 'undefined'}$`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
|||
}).catch((e: Error) => utils.commonLoggers.interactionSendError('editActivity.ts@ping', interaction, e));
|
||||
|
||||
// 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,
|
||||
}).catch((e: Error) => utils.commonLoggers.interactionSendError('editActivity.ts@edit', interaction, e));
|
||||
} else {
|
||||
|
|
|
@ -14,8 +14,7 @@ export const customId = 'editEvent';
|
|||
|
||||
const execute = (bot: Bot, interaction: Interaction) => {
|
||||
if (
|
||||
interaction.data?.customId && interaction.member && interaction.channelId && interaction.guildId && interaction.message && interaction.message.components &&
|
||||
interaction.message.components[0].components
|
||||
interaction.data?.customId && interaction.member && interaction.channelId && interaction.guildId && interaction?.message?.components?.[0].components
|
||||
) {
|
||||
// Light Telemetry
|
||||
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) => {
|
||||
if (
|
||||
interaction.data?.customId && interaction.member && interaction.member.user && interaction.channelId && interaction.guildId && interaction.message && interaction.message.embeds[0] &&
|
||||
interaction.message.embeds[0].fields
|
||||
interaction.data?.customId && interaction?.member?.user && interaction.channelId && interaction.guildId && interaction?.message?.embeds?.[0]?.fields
|
||||
) {
|
||||
// Light Telemetry
|
||||
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.
|
||||
|
||||
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}`,
|
||||
}],
|
||||
|
|
|
@ -13,8 +13,7 @@ export const denyStr = 'denied';
|
|||
|
||||
const execute = async (bot: Bot, interaction: Interaction) => {
|
||||
if (
|
||||
interaction.data?.customId && interaction.user && interaction.channelId && interaction.message && interaction.message.embeds[0] && interaction.message.embeds[0].fields &&
|
||||
interaction.message.embeds[0].description
|
||||
interaction.data?.customId && interaction.user && interaction.channelId && interaction?.message?.embeds?.[0]?.fields && interaction?.message?.embeds?.[0]?.description
|
||||
) {
|
||||
const memberRequesting = getLfgMembers(interaction.message.embeds[0].fields[0].value || '')[0];
|
||||
const approved = interaction.data.customId.includes(approveStr);
|
||||
|
|
|
@ -8,7 +8,7 @@ import { removeMemberFromEvent } from './utils.ts';
|
|||
export const customId = 'leaveEvent';
|
||||
|
||||
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
|
||||
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
|
||||
const noEdit = (bot: Bot, interaction: Interaction, loudAcknowledge: boolean) => {
|
||||
const noEdit = async (bot: Bot, interaction: Interaction, loudAcknowledge: boolean) => {
|
||||
if (loudAcknowledge) {
|
||||
bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
||||
await bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
||||
type: InteractionResponseTypes.ChannelMessageWithSource,
|
||||
data: {
|
||||
flags: ApplicationCommandFlags.Ephemeral,
|
||||
|
@ -145,7 +145,7 @@ ${safelyDismissMsg}`,
|
|||
},
|
||||
}).catch((e: Error) => utils.commonLoggers.interactionSendError('utils.ts', interaction, e));
|
||||
} else {
|
||||
bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
||||
await bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
||||
type: InteractionResponseTypes.DeferredUpdateMessage,
|
||||
}).catch((e: Error) => utils.commonLoggers.interactionSendError('utils.ts', interaction, e));
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ const details: CommandDetails = {
|
|||
};
|
||||
|
||||
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
|
||||
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));
|
||||
|
|
|
@ -241,7 +241,7 @@ The Discord Slash Command system will ensure you provide all the required detail
|
|||
const msgsToDel: Array<bigint> = [];
|
||||
const oldLfgMsgs: Array<bigint> = [];
|
||||
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);
|
||||
} else {
|
||||
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].footer.text = oldEvent.embeds[0].footer.text.split(' | ')[0];
|
||||
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}`;
|
||||
bot.helpers.editMessage(oldEvent.channelId, oldEvent.id, {
|
||||
content: '',
|
||||
|
|
|
@ -11,7 +11,7 @@ const tzOverrides: Array<Array<string>> = [
|
|||
['PST', '-08:00'],
|
||||
['IST', '+05:30'],
|
||||
];
|
||||
const abbrOverrides: Array<string> = tzOverrides.map(tzSet => tzSet[0]);
|
||||
const abbrOverrides: Array<string> = tzOverrides.map((tzSet) => tzSet[0]);
|
||||
|
||||
// Prefill the map
|
||||
for (const override of tzOverrides) {
|
||||
|
@ -22,11 +22,9 @@ for (const override of tzOverrides) {
|
|||
const attemptAdd = (tzAbbr: string, tzOffset: string) => {
|
||||
if (!abbrOverrides.includes(tzAbbr)) {
|
||||
if (tzMap.has(tzAbbr) && tzMap.get(tzAbbr) !== tzOffset) {
|
||||
console.error(`DOUBLED TZ ABBR WITH DIFF OFFSETS: ${tzAbbr} | ${tzOffset} | ${tzMap.get(tzAbbr)}`)
|
||||
} else {
|
||||
if (!tzAbbr.includes('+') && !tzAbbr.includes('-')) {
|
||||
tzMap.set(tzAbbr, tzOffset);
|
||||
}
|
||||
console.error(`DOUBLED TZ ABBR WITH DIFF OFFSETS: ${tzAbbr} | ${tzOffset} | ${tzMap.get(tzAbbr)}`);
|
||||
} else if (!tzAbbr.includes('+') && !tzAbbr.includes('-')) {
|
||||
tzMap.set(tzAbbr, tzOffset);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -34,10 +32,10 @@ const attemptAdd = (tzAbbr: string, tzOffset: string) => {
|
|||
// Get each TZ from the csv
|
||||
for (const row of csvRows) {
|
||||
const [rawSTDOffset, rawDSTOffset, rawSTDAbbr, rawDSTAbbr] = row.replaceAll('?', '-').toUpperCase().split(',');
|
||||
const STDOffset = (rawSTDOffset || '');
|
||||
const DSTOffset = (rawDSTOffset || '');
|
||||
const STDAbbr = (rawSTDAbbr || '');
|
||||
const DSTAbbr = (rawDSTAbbr || '');
|
||||
const STDOffset = rawSTDOffset || '';
|
||||
const DSTOffset = rawDSTOffset || '';
|
||||
const STDAbbr = rawSTDAbbr || '';
|
||||
const DSTAbbr = rawDSTAbbr || '';
|
||||
|
||||
attemptAdd(STDAbbr, STDOffset);
|
||||
if (STDAbbr !== DSTAbbr) {
|
||||
|
@ -47,7 +45,7 @@ for (const row of csvRows) {
|
|||
|
||||
// Log it out to copy to source
|
||||
const tzIt = tzMap.entries();
|
||||
let tzVal = tzIt.next()
|
||||
let tzVal = tzIt.next();
|
||||
while (!tzVal.done) {
|
||||
if (tzVal.value[0]) {
|
||||
console.log(`['${tzVal.value[0]}','${tzVal.value[1]}'],`);
|
||||
|
|
Loading…
Reference in New Issue