mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-09 14:43:05 -04:00
Merge branch 'main' into nextgen/cardstack
This commit is contained in:
commit
8c036e714a
3 changed files with 41 additions and 34 deletions
|
@ -4,11 +4,12 @@ const { TRANSLATE_DISPLAY_MAPPINGS, TRANSLATE_LANGUAGES, PERMISSION_GROUPS } = r
|
|||
const { getMessageAttachment, validateAttachment } = require('#utils/attachment');
|
||||
const { createEmbed } = require('#utils/embed');
|
||||
const { acknowledge } = require('#utils/interactions');
|
||||
const { codeblock, pill, icon } = require('#utils/markdown');
|
||||
const { codeblock, pill, icon, iconAsEmojiObject } = require('#utils/markdown');
|
||||
const { editOrReply } = require('#utils/message');
|
||||
const { STATICS, STATIC_ACTIONS } = require('#utils/statics');
|
||||
const { Context, Argument } = require('detritus-client/lib/command');
|
||||
|
||||
const { ApplicationCommandTypes, MessageFlags, InteractionContextTypes, ApplicationIntegrationTypes } = require("detritus-client/lib/constants");
|
||||
const { ApplicationCommandTypes, MessageFlags, InteractionContextTypes, ApplicationIntegrationTypes, MessageComponentTypes, InteractionCallbackTypes } = require("detritus-client/lib/constants");
|
||||
const { Components } = require('detritus-client/lib/utils');
|
||||
|
||||
module.exports = {
|
||||
|
@ -22,6 +23,12 @@ module.exports = {
|
|||
integrationTypes: [
|
||||
ApplicationIntegrationTypes.USER_INSTALL
|
||||
],
|
||||
/**
|
||||
*
|
||||
* @param {Context} context
|
||||
* @param {Argument} args
|
||||
* @returns
|
||||
*/
|
||||
run: async (context, args) => {
|
||||
try{
|
||||
await acknowledge(context, false, [...PERMISSION_GROUPS.baseline_slash]);
|
||||
|
@ -45,10 +52,6 @@ module.exports = {
|
|||
run: async (ctx) => {
|
||||
if (ctx.userId !== context.userId) return await ctx.respond(InteractionCallbackTypes.DEFERRED_UPDATE_MESSAGE);
|
||||
|
||||
await ctx.editOrRespond({
|
||||
embeds: [createEmbed("ai_custom", context, STATIC_ACTIONS.translate)]
|
||||
})
|
||||
|
||||
let translate = await googleTranslate(context, ocr.response.body.text, "en", "auto")
|
||||
|
||||
let fromFlag = TRANSLATE_DISPLAY_MAPPINGS[translate.response.body.language.from || sourceLanguage] || ''
|
||||
|
@ -75,7 +78,7 @@ module.exports = {
|
|||
})
|
||||
|
||||
await editOrReply(context, createEmbed("default", context, {
|
||||
embeds: [{
|
||||
embeds: [createEmbed("default", context, {
|
||||
thumbnail: {
|
||||
url: attachment
|
||||
},
|
||||
|
@ -84,7 +87,7 @@ module.exports = {
|
|||
iconUrl: STATICS.googlelens,
|
||||
text: `Google Lens • ${context.application.name} • Took ${ocr.timings}s`
|
||||
}
|
||||
}],
|
||||
})],
|
||||
components
|
||||
}))
|
||||
}catch(e){
|
||||
|
|
|
@ -109,12 +109,12 @@ function createCommandPage(context, prefix, command, slashCommands) {
|
|||
|
||||
// These categories will be displayed to users, add them in the correct order
|
||||
const categories = {
|
||||
"core": `${icon("home")} Core Commands`,
|
||||
"core": `${icon("home")} System Commands`,
|
||||
"info": `${icon("information")} Information Commands`,
|
||||
"search": `${icon("mag")} Search Commands`,
|
||||
"utils": `${icon("tools")} Utility Commands`,
|
||||
"fun": `${icon("stars")} Fun Commands`,
|
||||
"mod": `${icon("shield")} "Moderation Command}`
|
||||
"mod": `${icon("shield")} Moderation Command`
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
|
@ -48,33 +48,37 @@ module.exports.editOrReply = function(context, message, disableReference = false
|
|||
}
|
||||
|
||||
return context.editOrRespond(message).catch(async (e)=>{
|
||||
const errorData = await e.response.json();
|
||||
if(MESSAGE_BLOCK_REASONS[errorData.code]){
|
||||
// Delete the public response
|
||||
await context.deleteResponse();
|
||||
try{
|
||||
|
||||
message.flags = MessageFlags.EPHEMERAL
|
||||
const errorData = await e.response.json();
|
||||
if(MESSAGE_BLOCK_REASONS[errorData.code]){
|
||||
// Delete the public response
|
||||
await context.deleteResponse();
|
||||
|
||||
// Create a notice
|
||||
if(message.content){
|
||||
if(message.embeds && message.embeds.length <= 4){
|
||||
message.embeds.unshift({
|
||||
description: `${icon("flask_incognito")} This response has been made incognito due to ${MESSAGE_BLOCK_REASONS[errorData.code].message}.`,
|
||||
color: COLORS.incognito
|
||||
})
|
||||
message.flags = MessageFlags.EPHEMERAL
|
||||
|
||||
// Create a notice
|
||||
if(message.content){
|
||||
if(message.embeds && message.embeds.length <= 4){
|
||||
message.embeds.unshift({
|
||||
description: `${icon("flask_incognito")} This response has been made incognito due to ${MESSAGE_BLOCK_REASONS[errorData.code].message}.`,
|
||||
color: COLORS.incognito
|
||||
})
|
||||
}
|
||||
} else {
|
||||
// Uses new subtext formatting to look more "native"
|
||||
message.content = `-# ${icon("flask_mini")} This response has been made incognito due to ${MESSAGE_BLOCK_REASONS[errorData.code].message} • ${link("https://support.discord.com/hc/en-us/articles/" + MESSAGE_BLOCK_REASONS[errorData.code].support_article, "Learn More", "Support Article")}`
|
||||
}
|
||||
} else {
|
||||
// Uses new subtext formatting to look more "native"
|
||||
message.content = `-# ${icon("flask_mini")} This response has been made incognito due to ${MESSAGE_BLOCK_REASONS[errorData.code].message} • ${link("https://support.discord.com/hc/en-us/articles/" + MESSAGE_BLOCK_REASONS[errorData.code].support_article, "Learn More", "Support Article")}`
|
||||
|
||||
let replacementMessage = await context.createMessage(message);
|
||||
|
||||
if(!context._meta) context._meta = {}
|
||||
context._meta.replacementMessageId = replacementMessage.id;
|
||||
|
||||
return replacementMessage;
|
||||
}
|
||||
|
||||
let replacementMessage = await context.createMessage(message);
|
||||
|
||||
if(!context._meta) context._meta = {}
|
||||
context._meta.replacementMessageId = replacementMessage.id;
|
||||
|
||||
return replacementMessage;
|
||||
|
||||
}catch(e){
|
||||
console.log(e)
|
||||
}
|
||||
basecamp(formatErrorMessage(3, "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}\`\`\``), message);
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue