several small adjustments smiley

This commit is contained in:
bignutty 2024-08-08 23:11:40 +02:00
parent f280311212
commit cd624c9066
4 changed files with 47 additions and 37 deletions

View file

@ -4,7 +4,7 @@ const { paginator } = require('#client');
const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed') const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed')
const { link, pill } = require('#utils/markdown') const { link, pill } = require('#utils/markdown')
const { editOrReply } = require('#utils/message') const { editOrReply } = require('#utils/message')
const { STATICS } = require('#utils/statics') const { STATICS, STATIC_ASSETS } = require('#utils/statics')
// TODO: Turn this into a general purpose permissions constant // TODO: Turn this into a general purpose permissions constant
const { Permissions, InteractionCallbackTypes } = require("detritus-client/lib/constants"); const { Permissions, InteractionCallbackTypes } = require("detritus-client/lib/constants");
@ -64,7 +64,13 @@ async function quoraPaginator(context, pages, refMappings, currentRef) {
} }
await sctx.editOrRespond({ await sctx.editOrRespond({
embeds: [ embeds: [
createEmbed("loading", context, "Loading quora result...") createEmbed("image", context, {
url: STATIC_ASSETS.chat_loading,
provider: {
icon: STATICS.quora,
text: `Quora • ${context.application.name}`
}
})
], ],
components: [] components: []
}) })
@ -110,7 +116,7 @@ async function quoraPaginator(context, pages, refMappings, currentRef) {
options: selectOptions options: selectOptions
}) })
await ctx.editOrRespond({ content: `<@${context.userId}> Select a question.`, components }) await ctx.editOrRespond({ embeds: context.response.embeds, components })
} }
}) })
} }

View file

@ -61,7 +61,9 @@ module.exports.ICONS = Object.freeze({
"flask_mini": "<:ico_subt_flask:1263593669215256597>", "flask_mini": "<:ico_subt_flask:1263593669215256597>",
"subtext_lightbulb": "<:ico_subt_lightbulb:1263593690358616084>", "subtext_lightbulb": "<:ico_subt_lightbulb:1263593690358616084>",
"button_mag": "<:ico_button_mag:1271212564122173552>",
"button_thermometer": "<:ico_button_thermometer:1263593823016062987>", "button_thermometer": "<:ico_button_thermometer:1263593823016062987>",
"button_trash": "<:ico_button_trash:1271212355883372716>",
"button_user_profile_swap": "<:ico_button_user_profile_swap:1263594003442700368>", "button_user_profile_swap": "<:ico_button_user_profile_swap:1263594003442700368>",
"button_chevron_left": "<:button_chevron_left:1263594121256374413>", "button_chevron_left": "<:button_chevron_left:1263594121256374413>",
@ -227,6 +229,14 @@ module.exports.MUSIC_PLATFORM_ICONS = Object.freeze({
"youtubeMusic": "1271169027124760736" "youtubeMusic": "1271169027124760736"
}) })
module.exports.COMPONENT_BUTTON_ICONS = Object.freeze({
NEXT: this.ICONS.button_chevron_right,
PREVIOUS: this.ICONS.button_chevron_left,
STOP: this.ICONS.button_trash,
SEARCH: this.ICONS.button_mag,
UNKNOWN: this.ICONS.question_large
})
module.exports.GUILD_FEATURE_ICONS_REDESIGN = Object.freeze({ module.exports.GUILD_FEATURE_ICONS_REDESIGN = Object.freeze({
"ActivitiesIcon": "<:ico_d_activities:1263595238929334272>", "ActivitiesIcon": "<:ico_d_activities:1263595238929334272>",
"AnnouncementsIcon": "<:ico_d_announcements:1263595270684545205>", "AnnouncementsIcon": "<:ico_d_announcements:1263595270684545205>",
@ -276,6 +286,7 @@ module.exports.GUILD_FEATURE_ICONS_REDESIGN = Object.freeze({
"VoiceIcon": "<:ico_d_voicenormal:1263596678087446548>", "VoiceIcon": "<:ico_d_voicenormal:1263596678087446548>",
}) })
// This list should be synced with https://docs.discord.sex/resources/guild#guild-features
module.exports.GUILD_FEATURES = Object.freeze({ module.exports.GUILD_FEATURES = Object.freeze({
"ACTIVITIES_ALPHA": { icon: this.GUILD_FEATURE_ICONS_REDESIGN.ActivitiesIcon }, "ACTIVITIES_ALPHA": { icon: this.GUILD_FEATURE_ICONS_REDESIGN.ActivitiesIcon },
"ACTIVITIES_EMPLOYEE": { icon: this.GUILD_FEATURE_ICONS_REDESIGN.ActivitiesIcon }, "ACTIVITIES_EMPLOYEE": { icon: this.GUILD_FEATURE_ICONS_REDESIGN.ActivitiesIcon },
@ -1111,3 +1122,21 @@ module.exports.YOUTUBE_CATEGORIES = {
// Special character that allows for fully hidden masked links on all (supported) platforms. // Special character that allows for fully hidden masked links on all (supported) platforms.
module.exports.HIDDEN_MASKED_LINK_CHARACTER = "󠄴"; module.exports.HIDDEN_MASKED_LINK_CHARACTER = "󠄴";
/**
* These will force the command to become "incognito".
*/
module.exports.MESSAGE_BLOCK_REASONS = Object.freeze({
20016: {
message: "the channel's slowmode settings",
support_article: 360016150952
},
200000: {
message: "the server's AutoMod setup",
support_article: 4421269296535
},
// TODO: Handle permissions properly, this works as a "hack" for now.
50013: {
message: "the channel's permission setup",
support_article: 10543994968087
}
});

View file

@ -1,3 +1,4 @@
const { COMPONENT_BUTTON_ICONS } = require("#constants");
const { icon } = require("#utils/markdown"); const { icon } = require("#utils/markdown");
const InteractionPaginator = require("./InteractionPaginator"); const InteractionPaginator = require("./InteractionPaginator");
const assert = require("assert"); const assert = require("assert");
@ -10,14 +11,6 @@ const allowedEvents = new Set([
"MESSAGE_CREATE" "MESSAGE_CREATE"
]); ]);
const ButtonEmoji = Object.freeze({
NEXT: icon("button_chevron_right"),
PREVIOUS: icon("button_chevron_left"),
STOP: '<:ico_trash:929498022386221096>',
SEARCH: '<:search:1063080546365866056>',
UNKNOWN: '<:ico_question:949420315677691934>'
})
const { hasOwnProperty } = Object.prototype; const { hasOwnProperty } = Object.prototype;
const instances = new WeakSet(); const instances = new WeakSet();
@ -126,14 +119,14 @@ module.exports = class Paginator {
customId: "custom", customId: "custom",
disabled: 0, disabled: 0,
style: 2, style: 2,
emoji: ButtonEmoji.UNKNOWN emoji: COMPONENT_BUTTON_ICONS.UNKNOWN
}, b)); }, b));
} else { } else {
components.createButton({ components.createButton({
customId: b, customId: b,
disabled: 0, disabled: 0,
style: 2, style: 2,
emoji: ButtonEmoji[b.toUpperCase()] emoji: COMPONENT_BUTTON_ICONS[b.toUpperCase()]
}); });
} }
} }

View file

@ -1,27 +1,9 @@
const { Permissions, MessageFlags } = require("detritus-client/lib/constants") const { Permissions, MessageFlags } = require("detritus-client/lib/constants")
const { basecamp } = require("../logging") const { basecamp } = require("../logging")
const { createEmbed } = require("./embed") const { COLORS, MESSAGE_BLOCK_REASONS } = require("#constants")
const { COLORS } = require("#constants")
const { icon, link } = require("./markdown") const { icon, link } = require("./markdown")
/**
* These will force the command to become "incognito".
*/
const BLOCK_REASONS = {
20016: {
message: "the channel's slowmode settings",
support_article: 360016150952
},
200000: {
message: "the server's AutoMod setup",
support_article: 4421269296535
},
// TODO: Handle permissions properly, this works as a "hack" for now.
50013: {
message: "the channel's permission setup",
support_article: 10543994968087
}
}
module.exports.editOrReply = function(context, message, disableReference = false){ module.exports.editOrReply = function(context, message, disableReference = false){
// Apply message_reference // Apply message_reference
@ -52,7 +34,7 @@ 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(); const errorData = await e.response.json();
if(BLOCK_REASONS[errorData.code]){ if(MESSAGE_BLOCK_REASONS[errorData.code]){
// Delete the public response // Delete the public response
await context.deleteResponse(); await context.deleteResponse();
@ -62,13 +44,13 @@ module.exports.editOrReply = function(context, message, disableReference = false
if(message.content){ if(message.content){
if(message.embeds && message.embeds.length <= 4){ if(message.embeds && message.embeds.length <= 4){
message.embeds.unshift({ message.embeds.unshift({
description: `${icon("flask_incognito")} This response has been made incognito due to ${BLOCK_REASONS[errorData.code].message}.`, description: `${icon("flask_incognito")} This response has been made incognito due to ${MESSAGE_BLOCK_REASONS[errorData.code].message}.`,
color: COLORS.incognito color: COLORS.incognito
}) })
} }
} else { } else {
// Uses new subtext formatting to look more "native" // Uses new subtext formatting to look more "native"
message.content = `-# ${icon("flask_mini")} This response has been made incognito due to ${BLOCK_REASONS[errorData.code].message}. ${link("https://support.discord.com/hc/en-us/articles/" + BLOCK_REASONS[errorData.code].support_article, "Learn More", "Support Article")}` 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); let replacementMessage = await context.createMessage(message);