fix gm roll mentions, fix api gm roll, add link back to original roll message in gm message
This commit is contained in:
parent
4de1115fa9
commit
f6eb3b2b69
|
@ -78,30 +78,32 @@ export const onWorkerComplete = async (workerMessage: MessageEvent<SolvedRoll>,
|
||||||
if (!apiErroredOut) {
|
if (!apiErroredOut) {
|
||||||
// And message the full details to each of the GMs, alerting roller of every GM that could not be messaged
|
// And message the full details to each of the GMs, alerting roller of every GM that could not be messaged
|
||||||
rollRequest.modifiers.gms.forEach(async (gm) => {
|
rollRequest.modifiers.gms.forEach(async (gm) => {
|
||||||
log(LT.LOG, `Messaging GM ${gm}`);
|
const gmId: bigint = BigInt(gm.startsWith('<') ? gm.substring(2, gm.length - 1) : gm);
|
||||||
|
log(LT.LOG, `Messaging GM ${gm} | ${gmId}`);
|
||||||
// Attempt to DM the GM and send a warning if it could not DM a GM
|
// Attempt to DM the GM and send a warning if it could not DM a GM
|
||||||
await sendDirectMessage(BigInt(gm.substring(2, gm.length - 1)), {
|
await sendDirectMessage(gmId, {
|
||||||
|
content: `Original GM Roll Request: ${rollRequest.apiRoll ? newMsg && newMsg.link : rollRequest.dd.myResponse.link}`,
|
||||||
embeds: rollRequest.modifiers.count ? [gmEmbedDetails.embed, countEmbed] : [gmEmbedDetails.embed],
|
embeds: rollRequest.modifiers.count ? [gmEmbedDetails.embed, countEmbed] : [gmEmbedDetails.embed],
|
||||||
})
|
})
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
// Check if we need to attach a file and send it after the initial details sent
|
// Check if we need to attach a file and send it after the initial details sent
|
||||||
if (gmEmbedDetails.hasAttachment) {
|
if (gmEmbedDetails.hasAttachment) {
|
||||||
await sendDirectMessage(BigInt(gm.substring(2, gm.length - 1)), {
|
await sendDirectMessage(gmId, {
|
||||||
file: gmEmbedDetails.attachment,
|
file: gmEmbedDetails.attachment,
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
if (newMsg && rollRequest.apiRoll) {
|
if (newMsg && rollRequest.apiRoll) {
|
||||||
newMsg.reply(generateDMFailed(gm));
|
newMsg.reply(generateDMFailed(gmId));
|
||||||
} else if (!rollRequest.apiRoll) {
|
} else if (!rollRequest.apiRoll) {
|
||||||
rollRequest.dd.originalMessage.reply(generateDMFailed(gm));
|
rollRequest.dd.originalMessage.reply(generateDMFailed(gmId));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
if (rollRequest.apiRoll && newMsg) {
|
if (rollRequest.apiRoll && newMsg) {
|
||||||
newMsg.reply(generateDMFailed(gm));
|
newMsg.reply(generateDMFailed(gmId));
|
||||||
} else if (!rollRequest.apiRoll) {
|
} else if (!rollRequest.apiRoll) {
|
||||||
rollRequest.dd.originalMessage.reply(generateDMFailed(gm));
|
rollRequest.dd.originalMessage.reply(generateDMFailed(gmId));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -123,11 +123,11 @@ export const generateApiSuccess = (args: string) => ({
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
export const generateDMFailed = (user: string) => ({
|
export const generateDMFailed = (user: bigint) => ({
|
||||||
embeds: [
|
embeds: [
|
||||||
{
|
{
|
||||||
color: failColor,
|
color: failColor,
|
||||||
title: `WARNING: ${user} could not be messaged.`,
|
title: `WARNING: <@${user}> could not be messaged.`,
|
||||||
description: 'If this issue persists, make sure direct messages are allowed from this server.',
|
description: 'If this issue persists, make sure direct messages are allowed from this server.',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -274,7 +274,11 @@ export const generateRollEmbed = async (authorId: bigint, returnDetails: SolvedR
|
||||||
return {
|
return {
|
||||||
embed: {
|
embed: {
|
||||||
color: infoColor2,
|
color: infoColor2,
|
||||||
description: `<@${authorId}>${returnDetails.line1}\n\nResults have been messaged to the following GMs: ${modifiers.gms.join(' ')}`,
|
description: `<@${authorId}>${returnDetails.line1}\n\nResults have been messaged to the following GMs: ${
|
||||||
|
modifiers.gms
|
||||||
|
.map((gm) => (gm.startsWith('<') ? gm : `<@${gm}>`))
|
||||||
|
.join(' ')
|
||||||
|
}`,
|
||||||
},
|
},
|
||||||
hasAttachment: false,
|
hasAttachment: false,
|
||||||
attachment: {
|
attachment: {
|
||||||
|
|
Loading…
Reference in New Issue