The code class AutodeleteReply:
class AutodeleteReply {
constructor(
interaction,
client,
expirationSeconds = 2,
baseMessageContent = "",
ephemeral = false,
embeds = []
) {
// Force expirationSeconds to be at least 1
expirationSeconds = Math.floor(Math.abs(expirationSeconds));
expirationSeconds = expirationSeconds < 1 ? 1 : expirationSeconds;
// Make sure all embeds are valid.
embeds.filter((embed) => embed instanceof Embed);
// Create time reference object.
const timeDeletionString = `${bold(
`This message will auto-delete`
)} in ${unixTimeTag(
getUnixTime(
getDateFromOffsets(new Date(), 0, expirationSeconds, 0, 0, 0, 0, 0, 0)
),
true
)}…`;
// Expand message.
const fullMessage =
baseMessageContent.length === 0
? timeDeletionString
: [baseMessageContent, timeDeletionString].join("\n\n");
let msgObj = {
content: fullMessage,
ephemeral: ephemeral,
};
if (embeds.length > 0) {
msgObj.embeds = embeds;
}
const actions = [interaction.reply, timer, interaction.deleteReply];
const payloads = [messageResolvable, expirationSeconds * 1000, null];
this.post = async function () {
if (actions.every((action) => typeof action === "function")) {
for (let actionIndex = 0; actionIndex < 3; actionIndex++) {
if (nudf(payloads[actionIndex])) {
await actions[actionIndex]();
} else {
await actions[actionIndex](payloads[actionIndex]);
}
}
} else {
// Custom error that yells at you if not everything in the 'actions' variable is a function.
}
};
}
}
…But wait there's more…