@itsmapleleaf/gatekeeper
Advanced tools
Comparing version 0.3.3 to 0.4.0
@@ -58,2 +58,6 @@ import type * as Discord from "discord.js"; | ||
defer: () => void; | ||
/** | ||
* Like `defer()`, but the loading message will only be shown to the user that ran the command. | ||
*/ | ||
ephemeralDefer: () => void; | ||
}; | ||
@@ -60,0 +64,0 @@ /** |
@@ -32,2 +32,16 @@ "use strict"; | ||
}, | ||
ephemeralDefer: () => { | ||
actionQueue.push({ | ||
name: "defer", | ||
priority: deferPriority, | ||
run: async () => { | ||
if (interaction.deferred) | ||
return; | ||
if (interaction.isCommand()) | ||
await interaction.deferReply({ ephemeral: true }); | ||
if (interaction.isMessageComponent()) | ||
await interaction.deferUpdate(); | ||
}, | ||
}); | ||
}, | ||
reply: (render) => { | ||
@@ -147,2 +161,11 @@ const state = { | ||
async function addReply(interaction, options) { | ||
var _a; | ||
if (interaction.deferred && interaction.ephemeral) { | ||
// edge case: if the reply is deferred and ephemeral, | ||
// calling followUp will edit the ephemeral loading message | ||
// instead of creating a new public message, | ||
// so we have to create this public message manually for now | ||
// instead of using reply functions | ||
return (_a = interaction.channel) === null || _a === void 0 ? void 0 : _a.send(options); | ||
} | ||
if (interaction.deferred) { | ||
@@ -149,0 +172,0 @@ return interaction.editReply(options); |
@@ -76,4 +76,3 @@ "use strict"; | ||
.filter(helpers_1.isTruthy); | ||
const replyComponents = components | ||
.map((component) => { | ||
const replyComponents = components.map((component) => { | ||
if (component.type !== "actionRow") | ||
@@ -84,18 +83,16 @@ return; | ||
components: component.children.map((child) => { | ||
switch (child.type) { | ||
case "selectMenu": | ||
return Object.assign(Object.assign({}, child), { type: "SELECT_MENU" }); | ||
case "button": | ||
return Object.assign(Object.assign({}, child), { type: "BUTTON" }); | ||
case "link": | ||
return Object.assign(Object.assign({}, child), { style: "LINK", type: "BUTTON" }); | ||
if (child.type === "selectMenu") { | ||
return Object.assign(Object.assign({}, child), { type: "SELECT_MENU" }); | ||
} | ||
if (child.type === "link") { | ||
return Object.assign(Object.assign({}, child), { style: "LINK", type: "BUTTON" }); | ||
} | ||
return Object.assign(Object.assign({}, child), { type: "BUTTON" }); | ||
}), | ||
}; | ||
}) | ||
.filter(helpers_1.isTruthy); | ||
}); | ||
const options = { | ||
content, | ||
embeds, | ||
components: replyComponents, | ||
components: replyComponents.filter(helpers_1.isTruthy), | ||
}; | ||
@@ -102,0 +99,0 @@ // content can't be an empty string... at all |
@@ -20,5 +20,8 @@ "use strict"; | ||
while ((action = actions.shift())) { | ||
await logger | ||
.promise(`Running ${action.name}`, Promise.resolve(action.run())) | ||
.catch(); // do nothing; the logger will log the error | ||
try { | ||
await logger.promise(`Running ${action.name}`, Promise.resolve(action.run())); | ||
} | ||
catch (_a) { | ||
// do nothing; the logger will log the error | ||
} | ||
} | ||
@@ -25,0 +28,0 @@ flushing = false; |
@@ -5,3 +5,3 @@ { | ||
"author": "itsmapleleaf", | ||
"version": "0.3.3", | ||
"version": "0.4.0", | ||
"main": "dist/main.js", | ||
@@ -44,13 +44,13 @@ "types": "dist/main.d.ts", | ||
"devDependencies": { | ||
"jest": "27.1.0", | ||
"@types/jest": "27.0.1", | ||
"@types/lodash": "4.14.172", | ||
"@types/node": "16.7.10", | ||
"jest": "27.2.4", | ||
"@types/jest": "27.0.2", | ||
"@types/lodash": "4.14.175", | ||
"@types/node": "16.10.3", | ||
"cpy-cli": "3.1.1", | ||
"discord.js": "^13.1.0", | ||
"esbuild": "0.12.25", | ||
"discord.js": "^13.2.0", | ||
"esbuild": "0.13.4", | ||
"esbuild-jest": "0.5.0", | ||
"release-it": "14.11.5", | ||
"release-it": "14.11.6", | ||
"trash-cli": "4.0.0", | ||
"typescript": "4.4.2" | ||
"typescript": "4.4.3" | ||
}, | ||
@@ -57,0 +57,0 @@ "publishConfig": { |
76180
1879