From fb55cbc67dd801f4f7bb91760d434052065e58d5 Mon Sep 17 00:00:00 2001 From: derpystuff <3515180-derpystuff@users.noreply.gitlab.com> Date: Sun, 19 Nov 2023 12:30:44 +0100 Subject: [PATCH] initial work to support interaction contexts --- labscore/paginator/structures/BasePaginator.js | 5 +---- labscore/utils/message.js | 7 +++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/labscore/paginator/structures/BasePaginator.js b/labscore/paginator/structures/BasePaginator.js index b8299a9..2145315 100644 --- a/labscore/paginator/structures/BasePaginator.js +++ b/labscore/paginator/structures/BasePaginator.js @@ -18,10 +18,7 @@ module.exports = class BasePaginator extends EventEmitter { // Support application command context if(data.context.editOrRespond) { this.editOrRespond = data.context.editOrRespond.bind(data.context) - this.editOrReply = (d) => { - console.log(d) - return this.editOrRespond(d) - } + this.editOrReply = (d) => this.editOrRespond(d) } } diff --git a/labscore/utils/message.js b/labscore/utils/message.js index 8caff47..2af63c3 100644 --- a/labscore/utils/message.js +++ b/labscore/utils/message.js @@ -7,6 +7,13 @@ module.exports.editOrReply = function(context, message, disableReference = false if(!message.message_reference && !disableReference) message.reference = true // Disable mentions if(!message.allowedMentions) message.allowedMentions = {parse: [], repliedUser: false} + + // Handle responses for interaction context + if(context.editOrRespond){ + return context.editOrRespond(message).catch((e)=>{ + basecamp(`<:ico_w3:1086624963047460874>\`[${process.env.HOSTNAME}]\` **\` SHARD_MESSAGE_ERROR \`** \`[Shard ${context.client.shardId}]\` Command \`${context.command.name}\` failed to respond: @ \`${Date.now()}\`\nGuild: \`${context.guild.id}\`\nChannel: \`${context.channel.id}\`\nUser: \`${context.user.id}\`\`\`\`js\n${e}\`\`\``) + }) + } // Only respond if the command is still available and we have permissions to respond. if(!context.message.deleted && context.channel.can(Permissions.SEND_MESSAGES)) return context.editOrReply(message).catch((e)=> basecamp(`<:ico_w3:1086624963047460874>\`[${process.env.HOSTNAME}]\` **\` SHARD_MESSAGE_ERROR \`** \`[Shard ${context.client.shardId}]\` Command \`${context.message.content}\` failed to reply: @ \`${Date.now()}\`\nGuild: \`${context.guild.id}\`\nChannel: \`${context.channel.id}\`\nUser: \`${context.user.id}\`\`\`\`js\n${e}\`\`\``)