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 { getMessageAttachment, validateAttachment } = require('#utils/attachment');
|
||||||
const { createEmbed } = require('#utils/embed');
|
const { createEmbed } = require('#utils/embed');
|
||||||
const { acknowledge } = require('#utils/interactions');
|
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 { editOrReply } = require('#utils/message');
|
||||||
const { STATICS, STATIC_ACTIONS } = require('#utils/statics');
|
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');
|
const { Components } = require('detritus-client/lib/utils');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -22,6 +23,12 @@ module.exports = {
|
||||||
integrationTypes: [
|
integrationTypes: [
|
||||||
ApplicationIntegrationTypes.USER_INSTALL
|
ApplicationIntegrationTypes.USER_INSTALL
|
||||||
],
|
],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {Context} context
|
||||||
|
* @param {Argument} args
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
run: async (context, args) => {
|
run: async (context, args) => {
|
||||||
try{
|
try{
|
||||||
await acknowledge(context, false, [...PERMISSION_GROUPS.baseline_slash]);
|
await acknowledge(context, false, [...PERMISSION_GROUPS.baseline_slash]);
|
||||||
|
@ -44,10 +51,6 @@ module.exports = {
|
||||||
timeout: 100000,
|
timeout: 100000,
|
||||||
run: async (ctx) => {
|
run: async (ctx) => {
|
||||||
if (ctx.userId !== context.userId) return await ctx.respond(InteractionCallbackTypes.DEFERRED_UPDATE_MESSAGE);
|
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 translate = await googleTranslate(context, ocr.response.body.text, "en", "auto")
|
||||||
|
|
||||||
|
@ -75,7 +78,7 @@ module.exports = {
|
||||||
})
|
})
|
||||||
|
|
||||||
await editOrReply(context, createEmbed("default", context, {
|
await editOrReply(context, createEmbed("default", context, {
|
||||||
embeds: [{
|
embeds: [createEmbed("default", context, {
|
||||||
thumbnail: {
|
thumbnail: {
|
||||||
url: attachment
|
url: attachment
|
||||||
},
|
},
|
||||||
|
@ -84,7 +87,7 @@ module.exports = {
|
||||||
iconUrl: STATICS.googlelens,
|
iconUrl: STATICS.googlelens,
|
||||||
text: `Google Lens • ${context.application.name} • Took ${ocr.timings}s`
|
text: `Google Lens • ${context.application.name} • Took ${ocr.timings}s`
|
||||||
}
|
}
|
||||||
}],
|
})],
|
||||||
components
|
components
|
||||||
}))
|
}))
|
||||||
}catch(e){
|
}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
|
// These categories will be displayed to users, add them in the correct order
|
||||||
const categories = {
|
const categories = {
|
||||||
"core": `${icon("home")} Core Commands`,
|
"core": `${icon("home")} System Commands`,
|
||||||
"info": `${icon("information")} Information Commands`,
|
"info": `${icon("information")} Information Commands`,
|
||||||
"search": `${icon("mag")} Search Commands`,
|
"search": `${icon("mag")} Search Commands`,
|
||||||
"utils": `${icon("tools")} Utility Commands`,
|
"utils": `${icon("tools")} Utility Commands`,
|
||||||
"fun": `${icon("stars")} Fun Commands`,
|
"fun": `${icon("stars")} Fun Commands`,
|
||||||
"mod": `${icon("shield")} "Moderation Command}`
|
"mod": `${icon("shield")} Moderation Command`
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
|
@ -48,33 +48,37 @@ module.exports.editOrReply = function(context, message, disableReference = false
|
||||||
}
|
}
|
||||||
|
|
||||||
return context.editOrRespond(message).catch(async (e)=>{
|
return context.editOrRespond(message).catch(async (e)=>{
|
||||||
const errorData = await e.response.json();
|
try{
|
||||||
if(MESSAGE_BLOCK_REASONS[errorData.code]){
|
|
||||||
// Delete the public response
|
|
||||||
await context.deleteResponse();
|
|
||||||
|
|
||||||
message.flags = MessageFlags.EPHEMERAL
|
|
||||||
|
|
||||||
// Create a notice
|
const errorData = await e.response.json();
|
||||||
if(message.content){
|
if(MESSAGE_BLOCK_REASONS[errorData.code]){
|
||||||
if(message.embeds && message.embeds.length <= 4){
|
// Delete the public response
|
||||||
message.embeds.unshift({
|
await context.deleteResponse();
|
||||||
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);
|
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