adds incognito mode, fixes /emoji

This commit is contained in:
bignutty 2024-06-11 23:16:40 +02:00
parent fbdf212151
commit e61a604b7c
36 changed files with 401 additions and 127 deletions

View file

@ -0,0 +1,23 @@
const { MessageFlags, InteractionCallbackTypes } = require("detritus-client/lib/constants")
const { Context } = require("detritus-client/lib/command")
const { InteractionContext } = require("detritus-client/lib/interaction")
/**
* Acknowledges a command or interaction.
* @param { InteractionContext|Context } context Command/interaction context
* @param { boolean } incognito Specifies if the interaction should run privately (only applicable for interactions)
*/
module.exports.acknowledge = async function(context, incognito = false){
// Interaction flow
if(context.editOrRespond){
if(incognito){
if(!context._meta) context._meta = {};
context._meta.isIncognito = true;
return await context.respond({data: { flags: MessageFlags.EPHEMERAL }, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE});
}
return await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE})
}
// Command Flow
return await context.triggerTyping()
}

View file

@ -1,4 +1,4 @@
const { Permissions } = require("detritus-client/lib/constants")
const { Permissions, MessageFlags } = require("detritus-client/lib/constants")
const { basecamp } = require("../logging")
const { createEmbed } = require("./embed")
@ -10,6 +10,15 @@ module.exports.editOrReply = function(context, message, disableReference = false
// Disable mentions
if(!message.allowedMentions) message.allowedMentions = {parse: [], repliedUser: false}
let flags = 0;
// Special labsCore context clues for the command.
// Currently only used to identify incognito requests
// on user slash commands.
if(context._meta){
if(context._meta.isIncognito) flags = MessageFlags.EPHEMERAL
}
// you can figure out what this does on your own time
message.nonce = Math.floor(Math.random() * 9999 + 1000)
@ -32,7 +41,8 @@ module.exports.editOrReply = function(context, message, disableReference = false
allowedMentions: { parse: [], repliedUser: false },
embeds: [
embedResponse
]
],
flags
})
}catch(e){
/*