Handle TODO for rejecting a promotion
This commit is contained in:
parent
2fcd475a4a
commit
50df64506a
|
@ -19,6 +19,7 @@ const actions = [
|
||||||
'btn-joinEvent',
|
'btn-joinEvent',
|
||||||
'btn-joinWLEvent',
|
'btn-joinWLEvent',
|
||||||
'btn-leaveEvent',
|
'btn-leaveEvent',
|
||||||
|
'btn-leaveEventViaDM',
|
||||||
'btn-altEvent',
|
'btn-altEvent',
|
||||||
'btn-joinReqApprove',
|
'btn-joinReqApprove',
|
||||||
'btn-joinReqDeny',
|
'btn-joinReqDeny',
|
||||||
|
|
|
@ -20,6 +20,7 @@ import { updateEventButton } from './live-event/updateEvent.ts';
|
||||||
import { toggleWLStatusButton } from './live-event/toggleWLStatus.ts';
|
import { toggleWLStatusButton } from './live-event/toggleWLStatus.ts';
|
||||||
import { editActivityButton } from './live-event/editActivity.ts';
|
import { editActivityButton } from './live-event/editActivity.ts';
|
||||||
import { editActivityCustomButton } from './live-event/editActivity-custom.ts';
|
import { editActivityCustomButton } from './live-event/editActivity-custom.ts';
|
||||||
|
import { leaveEventViaDMButton } from './live-event/leaveViaDM.ts';
|
||||||
|
|
||||||
export const buttons: Array<Button> = [
|
export const buttons: Array<Button> = [
|
||||||
gameSelectionButton,
|
gameSelectionButton,
|
||||||
|
@ -43,4 +44,5 @@ export const buttons: Array<Button> = [
|
||||||
toggleWLStatusButton,
|
toggleWLStatusButton,
|
||||||
editActivityButton,
|
editActivityButton,
|
||||||
editActivityCustomButton,
|
editActivityCustomButton,
|
||||||
|
leaveEventViaDMButton,
|
||||||
];
|
];
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
import { Bot, Interaction } from '../../../deps.ts';
|
||||||
|
import { dbClient, queries } from '../../db.ts';
|
||||||
|
import { somethingWentWrong } from '../../commandUtils.ts';
|
||||||
|
import utils from '../../utils.ts';
|
||||||
|
import { removeMemberFromEvent } from './utils.ts';
|
||||||
|
import { pathIdxEnder, idSeparator, pathIdxSeparator } from '../eventUtils.ts';
|
||||||
|
|
||||||
|
export const customId = 'leaveEventViaDM';
|
||||||
|
|
||||||
|
const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
|
if (interaction.data?.customId) {
|
||||||
|
// Light Telemetry
|
||||||
|
dbClient.execute(queries.callIncCnt('btn-leaveEventViaDM')).catch((e) => utils.commonLoggers.dbError('leaveEventViaDM.ts', 'call sproc INC_CNT on', e));
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
if (eventMessage && eventMessage.embeds[0]) {
|
||||||
|
// Remove user from event
|
||||||
|
removeMemberFromEvent(bot, interaction, eventMessage.embeds[0], evtMessageId, evtChannelId, interaction.user.id, evtGuildId, true);
|
||||||
|
} else {
|
||||||
|
somethingWentWrong(bot, interaction, 'getEventFailInLeaveEventViaDMButton');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
somethingWentWrong(bot, interaction, 'noDataFromLeaveEventViaDMButton');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const leaveEventViaDMButton = {
|
||||||
|
customId,
|
||||||
|
execute,
|
||||||
|
};
|
|
@ -1,10 +1,11 @@
|
||||||
import { ActionRow, ApplicationCommandFlags, Bot, ButtonStyles, Embed, Interaction, InteractionResponseTypes, MessageComponentTypes } from '../../../deps.ts';
|
import { ActionRow, ApplicationCommandFlags, Bot, ButtonStyles, Embed, Interaction, InteractionResponseTypes, MessageComponentTypes } from '../../../deps.ts';
|
||||||
import { LFGMember, UrlIds } from '../../types/commandTypes.ts';
|
import { LFGMember, UrlIds } from '../../types/commandTypes.ts';
|
||||||
import { infoColor1, safelyDismissMsg, sendDirectMessage, somethingWentWrong, successColor } from '../../commandUtils.ts';
|
import { infoColor1, safelyDismissMsg, sendDirectMessage, somethingWentWrong, successColor } from '../../commandUtils.ts';
|
||||||
import { generateAlternateList, generateMemberList, generateMemberTitle, idSeparator, leaveEventBtnStr, LfgEmbedIndexes, noMembersStr } from '../eventUtils.ts';
|
import { generateAlternateList, generateMemberList, generateMemberTitle, idSeparator, leaveEventBtnStr, LfgEmbedIndexes, noMembersStr, pathIdxSeparator } from '../eventUtils.ts';
|
||||||
import { selfDestructMessage } from '../tokenCleanup.ts';
|
import { selfDestructMessage } from '../tokenCleanup.ts';
|
||||||
import { approveStr, customId as joinRequestCustomId, denyStr } from './joinRequest.ts';
|
import { approveStr, customId as joinRequestCustomId, denyStr } from './joinRequest.ts';
|
||||||
import { customId as updateEventCustomId } from './updateEvent.ts';
|
import { customId as updateEventCustomId } from './updateEvent.ts';
|
||||||
|
import { customId as leaveViaDMCustomId } from './leaveViaDM.ts';
|
||||||
import utils from '../../utils.ts';
|
import utils from '../../utils.ts';
|
||||||
|
|
||||||
// Join status map to prevent spamming the system
|
// Join status map to prevent spamming the system
|
||||||
|
@ -206,7 +207,7 @@ export const removeMemberFromEvent = async (
|
||||||
type: MessageComponentTypes.Button,
|
type: MessageComponentTypes.Button,
|
||||||
label: leaveEventBtnStr,
|
label: leaveEventBtnStr,
|
||||||
style: ButtonStyles.Danger,
|
style: ButtonStyles.Danger,
|
||||||
customId: 'leaveEventCustomId', // TODO: fix
|
customId: `${leaveViaDMCustomId}${idSeparator}${evtGuildId}${pathIdxSeparator}${evtChannelId}${pathIdxSeparator}${evtMessageId}`,
|
||||||
}],
|
}],
|
||||||
}],
|
}],
|
||||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('utils.ts', 'user promotion dm', e));
|
}).catch((e: Error) => utils.commonLoggers.messageSendError('utils.ts', 'user promotion dm', e));
|
||||||
|
|
Loading…
Reference in New Issue