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

@ -1,7 +1,8 @@
const { renderMusicButtons } = require('#utils/buttons'); const { renderMusicButtons } = require('#utils/buttons');
const { createEmbed } = require('#utils/embed') const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { InteractionCallbackTypes, ApplicationCommandTypes } = require("detritus-client/lib/constants");; const { ApplicationCommandTypes } = require("detritus-client/lib/constants");;
const superagent = require('superagent') const superagent = require('superagent')
@ -20,7 +21,7 @@ module.exports = {
], ],
run: async (context, args) => { run: async (context, args) => {
try{ try{
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE}) await acknowledge(context);
const { message } = args; const { message } = args;

View file

@ -2,10 +2,11 @@ const { googleVisionOcr } = require('#api');
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 { codeblock } = require('#utils/markdown'); const { codeblock } = require('#utils/markdown');
const { STATICS } = require('#utils/statics'); const { STATICS } = require('#utils/statics');
const { InteractionCallbackTypes, ApplicationCommandTypes, MessageFlags } = require("detritus-client/lib/constants"); const { ApplicationCommandTypes, MessageFlags } = require("detritus-client/lib/constants");
module.exports = { module.exports = {
name: 'OCR', name: 'OCR',
@ -20,7 +21,7 @@ module.exports = {
], ],
run: async (context, args) => { run: async (context, args) => {
try{ try{
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE}) await acknowledge(context);
const { message } = args; const { message } = args;

View file

@ -3,11 +3,12 @@ const { TRANSLATE_LANGUAGE_MAPPINGS, TRANSLATE_LANGUAGES } = require('#constants
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 { editOrReply } = require('#utils/message'); const { editOrReply } = require('#utils/message');
const { codeblock, icon, pill } = require('#utils/markdown'); const { codeblock, icon, pill } = require('#utils/markdown');
const { STATICS } = require('#utils/statics'); const { STATICS } = require('#utils/statics');
const { InteractionCallbackTypes, ApplicationCommandTypes, MessageFlags } = require("detritus-client/lib/constants"); const { ApplicationCommandTypes, MessageFlags } = require("detritus-client/lib/constants");
module.exports = { module.exports = {
name: 'OCR Translate', name: 'OCR Translate',
@ -21,8 +22,8 @@ module.exports = {
1 1
], ],
run: async (context, args) => { run: async (context, args) => {
await acknowledge(context);
try{ try{
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE})
const { message } = args; const { message } = args;

View file

@ -2,11 +2,12 @@ const { reverseImageSearch } = require('#api');
const { paginator } = require('#client'); const { paginator } = require('#client');
const { getMessageAttachment, validateAttachment } = require('#utils/attachment'); const { getMessageAttachment, validateAttachment } = require('#utils/attachment');
const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed') const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { editOrReply } = require('#utils/message') const { editOrReply } = require('#utils/message')
const { STATICS } = require('#utils/statics') const { STATICS } = require('#utils/statics')
const { InteractionCallbackTypes, ApplicationCommandTypes } = require("detritus-client/lib/constants"); const { ApplicationCommandTypes } = require("detritus-client/lib/constants");
// TODO: create a favicon() util // TODO: create a favicon() util
function createReverseImageSearchResultPage(context, result, source) { function createReverseImageSearchResultPage(context, result, source) {
@ -45,7 +46,7 @@ module.exports = {
], ],
run: async (context, args) => { run: async (context, args) => {
try{ try{
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE}) await acknowledge(context);
const { message } = args; const { message } = args;

View file

@ -1,11 +1,13 @@
const { AudioTranscribe } = require('#obelisk'); const { AudioTranscribe } = require('#obelisk');
const { createEmbed } = require('#utils/embed'); const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { editOrReply } = require('#utils/message'); const { editOrReply } = require('#utils/message');
const { codeblock } = require('#utils/markdown'); const { codeblock } = require('#utils/markdown');
const { STATICS } = require('#utils/statics'); const { STATICS } = require('#utils/statics');
const { InteractionCallbackTypes, ApplicationCommandTypes, MessageFlags } = require("detritus-client/lib/constants");; const { ApplicationCommandTypes, MessageFlags } = require("detritus-client/lib/constants");
;
module.exports = { module.exports = {
name: 'Transcribe Voice Message', name: 'Transcribe Voice Message',
@ -19,38 +21,38 @@ module.exports = {
1 1
], ],
run: async (context, args) => { run: async (context, args) => {
await context.respond({data: { flags: MessageFlags.EPHEMERAL }, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE}) await acknowledge(context);
try { try {
const { message } = args; const { message } = args;
if(!message.attachments.first()) return editOrReply(context, { if (!message.attachments.first()) return editOrReply(context, {
embeds: [createEmbed("warning", context, "No voice message found.")], embeds: [createEmbed("warning", context, "No voice message found.")],
flags: MessageFlags.EPHEMERAL flags: MessageFlags.EPHEMERAL
}) })
if(!message.attachments.first().url.split('?')[0].endsWith('voice-message.ogg')) return editOrReply(context, { if (!message.attachments.first().url.split('?')[0].endsWith('voice-message.ogg')) return editOrReply(context, {
embeds: [createEmbed("warning", context, "No voice message found.")], embeds: [createEmbed("warning", context, "No voice message found.")],
flags: MessageFlags.EPHEMERAL flags: MessageFlags.EPHEMERAL
}) })
const recog = await AudioTranscribe(context, message.attachments.first().url) const recog = await AudioTranscribe(context, message.attachments.first().url)
return editOrReply(context, { return editOrReply(context, {
embeds: [createEmbed("default", context, { embeds: [createEmbed("default", context, {
description: codeblock("md", [ recog.response.body.transcript.substr(0,3900) ]), description: codeblock("md", [recog.response.body.transcript.substr(0, 3900)]),
footer: { footer: {
iconUrl: STATICS.google, iconUrl: STATICS.google,
text: `Google Speech to Text • ${context.application.name}` text: `Google Speech to Text • ${context.application.name}`
} }
})], })],
flags: MessageFlags.EPHEMERAL flags: MessageFlags.EPHEMERAL
}) })
} catch (e) { } catch (e) {
return editOrReply(context, { return editOrReply(context, {
embeds: [createEmbed("error", context, "Unable to transcribe message.")], embeds: [createEmbed("error", context, "Unable to transcribe message.")],
flags: MessageFlags.EPHEMERAL flags: MessageFlags.EPHEMERAL
}) })
} }
}, },
}; };

View file

@ -1,9 +1,10 @@
const { otter } = require('#api'); const { otter } = require('#api');
const { createEmbed } = require('#utils/embed') const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { editOrReply } = require('#utils/message') const { editOrReply } = require('#utils/message')
const { InteractionCallbackTypes } = require("detritus-client/lib/constants"); const { ApplicationCommandOptionTypes } = require("detritus-client/lib/constants");
module.exports = { module.exports = {
description: 'Shows a random otter picture.', description: 'Shows a random otter picture.',
@ -16,8 +17,17 @@ module.exports = {
integrationTypes: [ integrationTypes: [
1 1
], ],
run: async (context) => { options: [
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE}) {
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
}
],
run: async (context, args) => {
await acknowledge(context, args.incognito);
try{ try{
const ott = (await otter()).response.body const ott = (await otter()).response.body

View file

@ -1,7 +1,8 @@
const { createEmbed } = require('#utils/embed'); const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { editOrReply } = require('#utils/message'); const { editOrReply } = require('#utils/message');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require("detritus-client/lib/constants"); const { ApplicationCommandOptionTypes } = require("detritus-client/lib/constants");
module.exports = { module.exports = {
description: 'Get someones avatar.', description: 'Get someones avatar.',
@ -20,10 +21,17 @@ module.exports = {
description: 'User to get the avatar from.', description: 'User to get the avatar from.',
type: ApplicationCommandOptionTypes.USER, type: ApplicationCommandOptionTypes.USER,
required: false required: false
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE}) await acknowledge(context, args.incognito);
if(!args.user) return editOrReply(context, createEmbed("default", context, { if(!args.user) return editOrReply(context, createEmbed("default", context, {
image: { image: {

View file

@ -1,11 +1,12 @@
const { BADGE_ICONS } = require('#constants'); const { BADGE_ICONS } = require('#constants');
const { createEmbed } = require('#utils/embed'); const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { smallIconPill, highlight, smallPill, icon, timestamp } = require('#utils/markdown'); const { smallIconPill, highlight, smallPill, icon, timestamp } = require('#utils/markdown');
const { editOrReply } = require('#utils/message'); const { editOrReply } = require('#utils/message');
const { renderBadges } = require('#utils/users'); const { renderBadges } = require('#utils/users');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes, UserFlags } = require("detritus-client/lib/constants"); const { ApplicationCommandOptionTypes, UserFlags } = require("detritus-client/lib/constants");
module.exports = { module.exports = {
description: 'Displays information about a user', description: 'Displays information about a user',
@ -24,12 +25,19 @@ module.exports = {
description: 'The User.', description: 'The User.',
type: ApplicationCommandOptionTypes.USER, type: ApplicationCommandOptionTypes.USER,
required: false required: false
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
try{ await acknowledge(context, args.incognito);
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE})
try{
const { user, member } = args; const { user, member } = args;
let u = user; let u = user;

View file

@ -1,11 +1,12 @@
const { googleImages } = require('#api'); const { googleImages } = require('#api');
const { paginator } = require('#client'); const { paginator } = require('#client');
const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed') const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { editOrReply } = require('#utils/message') const { editOrReply } = require('#utils/message')
const { STATICS } = require('#utils/statics') const { STATICS } = require('#utils/statics')
const { ApplicationCommandOptionTypes, InteractionCallbackTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
// TODO: create a favicon() util // TODO: create a favicon() util
function createImageResultPage(context, result) { function createImageResultPage(context, result) {
@ -46,10 +47,17 @@ module.exports = {
description: 'Image search query.', description: 'Image search query.',
type: ApplicationCommandOptionTypes.TEXT, type: ApplicationCommandOptionTypes.TEXT,
required: true required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE}) await acknowledge(context, args.incognito);
try { try {
let search = await googleImages(context, args.query, false) //safesearch is always on let search = await googleImages(context, args.query, false) //safesearch is always on

View file

@ -1,12 +1,13 @@
const { google } = require('#api'); const { google } = require('#api');
const { paginator } = require('#client'); const { paginator } = require('#client');
const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed') const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { link, citation } = require('#utils/markdown') const { link, citation } = require('#utils/markdown')
const { editOrReply } = require('#utils/message') const { editOrReply } = require('#utils/message')
const { STATICS } = require('#utils/statics') const { STATICS } = require('#utils/statics')
const { ApplicationCommandOptionTypes, InteractionCallbackTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
// TODO: create a favicon() util // TODO: create a favicon() util
function createSearchResultPage(context, result){ function createSearchResultPage(context, result){
@ -71,10 +72,17 @@ module.exports = {
description: 'Google search query.', description: 'Google search query.',
type: ApplicationCommandOptionTypes.TEXT, type: ApplicationCommandOptionTypes.TEXT,
required: true required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE}) await acknowledge(context, args.incognito);
try{ try{
let search = await google(context, args.query, false) // safe search is always on let search = await google(context, args.query, false) // safe search is always on

View file

@ -1,12 +1,13 @@
const { lyrics } = require('#api'); const { lyrics } = require('#api');
const { paginator } = require('#client'); const { paginator } = require('#client');
const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed') const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { smallIconPill } = require('#utils/markdown'); const { smallIconPill } = require('#utils/markdown');
const { editOrReply } = require('#utils/message') const { editOrReply } = require('#utils/message')
const { STATICS } = require('#utils/statics') const { STATICS } = require('#utils/statics')
const { ApplicationCommandOptionTypes, InteractionCallbackTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
const META_FIELDS = { const META_FIELDS = {
"Album": "stat_videos", "Album": "stat_videos",
@ -56,10 +57,17 @@ module.exports = {
description: 'Song name or partial lyrics.', description: 'Song name or partial lyrics.',
type: ApplicationCommandOptionTypes.TEXT, type: ApplicationCommandOptionTypes.TEXT,
required: true required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE}) await acknowledge(context, args.incognito);
try{ try{
let search = await lyrics(context, args.query) let search = await lyrics(context, args.query)

View file

@ -1,12 +1,13 @@
const { wolframAlpha } = require('#api'); const { wolframAlpha } = require('#api');
const { paginator } = require('#client'); const { paginator } = require('#client');
const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed') const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { citation } = require('#utils/markdown'); const { citation } = require('#utils/markdown');
const { editOrReply } = require('#utils/message') const { editOrReply } = require('#utils/message')
const { STATICS } = require('#utils/statics') const { STATICS } = require('#utils/statics')
const { ApplicationCommandOptionTypes, InteractionCallbackTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
function createWolframPage(context, pod, query, sources) { function createWolframPage(context, pod, query, sources) {
let res = page(createEmbed("default", context, { let res = page(createEmbed("default", context, {
@ -56,10 +57,17 @@ module.exports = {
description: 'Computational Query.', description: 'Computational Query.',
type: ApplicationCommandOptionTypes.TEXT, type: ApplicationCommandOptionTypes.TEXT,
required: true required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE}) await acknowledge(context, args.incognito);
try { try {
let search = await wolframAlpha(context, args.query) let search = await wolframAlpha(context, args.query)

View file

@ -1,9 +1,10 @@
const { paginator } = require('#client'); const { paginator } = require('#client');
const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed') const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { editOrReply } = require('#utils/message') const { editOrReply } = require('#utils/message')
const { ApplicationCommandOptionTypes, InteractionCallbackTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
const superagent = require('superagent') const superagent = require('superagent')
@ -24,10 +25,17 @@ module.exports = {
description: 'Search query, can be a title, words from the comic, etc.', description: 'Search query, can be a title, words from the comic, etc.',
type: ApplicationCommandOptionTypes.TEXT, type: ApplicationCommandOptionTypes.TEXT,
required: true required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE}) await acknowledge(context, args.incognito);
if(!isNaN(parseInt(args.query))){ if(!isNaN(parseInt(args.query))){
try{ try{

View file

@ -2,11 +2,14 @@ const { youtube } = require('#api');
const { paginator } = require('#client'); const { paginator } = require('#client');
const { YOUTUBE_CATEGORIES } = require('#constants'); const { YOUTUBE_CATEGORIES } = require('#constants');
const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed') const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { link, iconPill } = require('#utils/markdown') const { link, iconPill } = require('#utils/markdown')
const { editOrReply } = require('#utils/message') const { editOrReply } = require('#utils/message')
const { STATICS } = require('#utils/statics') const { STATICS } = require('#utils/statics')
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
// TODO: Move this to a numbers utility // TODO: Move this to a numbers utility
// https://www.html-code-generator.com/javascript/shorten-long-numbers // https://www.html-code-generator.com/javascript/shorten-long-numbers
const intToString = num => { const intToString = num => {
@ -106,8 +109,6 @@ function createYoutubePage(context, result){
return res; return res;
} }
const { ApplicationCommandOptionTypes, InteractionCallbackTypes } = require('detritus-client/lib/constants');
module.exports = { module.exports = {
name: 'youtube', name: 'youtube',
description: 'Search for videos on YouTube.', description: 'Search for videos on YouTube.',
@ -126,8 +127,12 @@ module.exports = {
type: ApplicationCommandOptionTypes.STRING, type: ApplicationCommandOptionTypes.STRING,
required: true required: true
}, },
{name: 'type', default: 'all', type: 'string', help: `Video Category`}, {
name: 'type',
default: 'all',
type: 'string',
help: `Video Category`
},
{ {
name: 'type', name: 'type',
description: 'Type of videos to search.', description: 'Type of videos to search.',
@ -166,10 +171,17 @@ module.exports = {
name: "News" name: "News"
}, },
] ]
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE}) await acknowledge(context, args.incognito);
try{ try{
if(!args.type) args.type="all" if(!args.type) args.type="all"

View file

@ -2,11 +2,12 @@ const { dictionary } = require('#api');
const { paginator } = require('#client'); const { paginator } = require('#client');
const { TRANSLATE_LANGUAGE_MAPPINGS, DICTIONARY_LANGUAGES } = require('#constants'); const { TRANSLATE_LANGUAGE_MAPPINGS, DICTIONARY_LANGUAGES } = require('#constants');
const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed') const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { link, iconPill, smallPill, icon, iconLinkPill, pill } = require('#utils/markdown') const { link, iconPill, smallPill, icon, iconLinkPill, pill } = require('#utils/markdown')
const { editOrReply } = require('#utils/message') const { editOrReply } = require('#utils/message')
const { ApplicationCommandOptionTypes, InteractionCallbackTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
const LABELS = { const LABELS = {
"offensive": `${iconPill("warning", "Offensive")}` "offensive": `${iconPill("warning", "Offensive")}`
@ -65,10 +66,17 @@ module.exports = {
description: 'Term to look up.', description: 'Term to look up.',
type: ApplicationCommandOptionTypes.TEXT, type: ApplicationCommandOptionTypes.TEXT,
required: true required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE}) await acknowledge(context, args.incognito);
try{ try{
let search = await dictionary(context, args.term, "en") let search = await dictionary(context, args.term, "en")

View file

@ -1,6 +1,7 @@
const { emojipedia, emojiKitchen } = require("#api"); const { emojipedia, emojiKitchen } = require("#api");
const { createEmbed } = require("#utils/embed"); const { createEmbed } = require("#utils/embed");
const { acknowledge } = require("#utils/interactions");
const { icon, pill, iconPill, highlight, timestamp } = require("#utils/markdown"); const { icon, pill, iconPill, highlight, timestamp } = require("#utils/markdown");
const { editOrReply } = require("#utils/message"); const { editOrReply } = require("#utils/message");
const { STATICS } = require("#utils/statics"); const { STATICS } = require("#utils/statics");
@ -8,7 +9,7 @@ const { STATICS } = require("#utils/statics");
const { ingest } = require("#logging"); const { ingest } = require("#logging");
const { Utils } = require("detritus-client"); const { Utils } = require("detritus-client");
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require("detritus-client/lib/constants"); const { InteractionCallbackTypes, ApplicationCommandOptionTypes, DiscordRegexNames } = require("detritus-client/lib/constants");
const { Components, Snowflake } = require("detritus-client/lib/utils"); const { Components, Snowflake } = require("detritus-client/lib/utils");
const onlyEmoji = require('emoji-aware').onlyEmoji; const onlyEmoji = require('emoji-aware').onlyEmoji;
@ -53,13 +54,20 @@ module.exports = {
description: 'Emoji to enlarge. Use two built-in emoji to mix them.', description: 'Emoji to enlarge. Use two built-in emoji to mix them.',
type: ApplicationCommandOptionTypes.TEXT, type: ApplicationCommandOptionTypes.TEXT,
required: true required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE}) await acknowledge(context, args.incognito);
const { matches } = Utils.regex( const { matches } = Utils.regex(
Constants.DiscordRegexNames.EMOJI, DiscordRegexNames.EMOJI,
args.emoji args.emoji
); );
embeds = [] embeds = []

View file

@ -7,6 +7,7 @@ const { STATICS } = require("#utils/statics");
const { Components } = require("detritus-client/lib/utils"); const { Components } = require("detritus-client/lib/utils");
const { InteractionCallbackTypes, MessageComponentButtonStyles, ApplicationCommandOptionTypes } = require("detritus-client/lib/constants"); const { InteractionCallbackTypes, MessageComponentButtonStyles, ApplicationCommandOptionTypes } = require("detritus-client/lib/constants");
const { acknowledge } = require("#utils/interactions");
const onlyEmoji = require('emoji-aware').onlyEmoji; const onlyEmoji = require('emoji-aware').onlyEmoji;
@ -48,10 +49,17 @@ module.exports = {
description: 'Emoji to enlarge. Use two built-in emoji to mix them.', description: 'Emoji to enlarge. Use two built-in emoji to mix them.',
type: ApplicationCommandOptionTypes.TEXT, type: ApplicationCommandOptionTypes.TEXT,
required: true required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE}) await acknowledge(context, args.incognito);
const emoji = onlyEmoji(args.emoji) const emoji = onlyEmoji(args.emoji)
if(!emoji){ if(!emoji){

View file

@ -1,9 +1,10 @@
const { WebUtilsWebPageScreenshot} = require("#obelisk"); const { WebUtilsWebPageScreenshot} = require("#obelisk");
const { createEmbed } = require("#utils/embed"); const { createEmbed } = require("#utils/embed");
const { acknowledge } = require("#utils/interactions");
const { editOrReply } = require("#utils/message"); const { editOrReply } = require("#utils/message");
const { ApplicationCommandOptionTypes, InteractionCallbackTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
module.exports = { module.exports = {
name: 'screenshot', name: 'screenshot',
@ -22,10 +23,17 @@ module.exports = {
description: 'Website URL.', description: 'Website URL.',
type: ApplicationCommandOptionTypes.TEXT, type: ApplicationCommandOptionTypes.TEXT,
required: true required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE}) await acknowledge(context, args.incognito);
await editOrReply(context, createEmbed("loading", context, `Creating website screenshot...`)) await editOrReply(context, createEmbed("loading", context, `Creating website screenshot...`))

View file

@ -1,11 +1,12 @@
const { darksky } = require('#api'); const { darksky } = require('#api');
const { createEmbed } = require('#utils/embed'); const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { pill, iconPill, smallPill, weatherIcon, timestamp } = require('#utils/markdown'); const { pill, iconPill, smallPill, weatherIcon, timestamp } = require('#utils/markdown');
const { editOrReply } = require('#utils/message'); const { editOrReply } = require('#utils/message');
const { STATICS } = require('#utils/statics'); const { STATICS } = require('#utils/statics');
const { ApplicationCommandOptionTypes, InteractionCallbackTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
module.exports = { module.exports = {
name: 'weather', name: 'weather',
@ -24,10 +25,17 @@ module.exports = {
description: 'City or place to check.', description: 'City or place to check.',
type: ApplicationCommandOptionTypes.TEXT, type: ApplicationCommandOptionTypes.TEXT,
required: true required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE}) await acknowledge(context, args.incognito);
try{ try{
let data = await darksky(context, args.location) let data = await darksky(context, args.location)

View file

@ -2,9 +2,10 @@ const { imtranslator } = require('#api');
const { IMTRANSLATOR_VOICES } = require('#constants'); const { IMTRANSLATOR_VOICES } = require('#constants');
const { createEmbed } = require('#utils/embed'); const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown'); const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
module.exports = { module.exports = {
description: 'Text to Speech with imtranslator voices', description: 'Text to Speech with imtranslator voices',
@ -23,12 +24,19 @@ module.exports = {
type: ApplicationCommandOptionTypes.STRING, type: ApplicationCommandOptionTypes.STRING,
required: true, required: true,
maxLength: 256 maxLength: 256
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
await acknowledge(context, args.incognito);
try{ try{
let s = Date.now() let s = Date.now()
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE})
let audio = await imtranslator(context, args.text, args.voice) let audio = await imtranslator(context, args.text, args.voice)
let diff = (Date.now() - s) let diff = (Date.now() - s)
await context.editOrRespond({ await context.editOrRespond({

View file

@ -2,9 +2,10 @@ const { sapi4 } = require('#api');
const { MICROSOFT_VOICES, MICROSOFT_VOICE_CONFIG } = require('#constants'); const { MICROSOFT_VOICES, MICROSOFT_VOICE_CONFIG } = require('#constants');
const { createEmbed } = require('#utils/embed'); const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown'); const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
module.exports = { module.exports = {
description: 'Text to Speech with microsoft voices', description: 'Text to Speech with microsoft voices',
@ -23,11 +24,18 @@ module.exports = {
type: ApplicationCommandOptionTypes.STRING, type: ApplicationCommandOptionTypes.STRING,
required: true, required: true,
maxLength: 256 maxLength: 256
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
await acknowledge(context, args.incognito);
try{ try{
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE})
let audio = await sapi4(context, args.text, args.voice, MICROSOFT_VOICE_CONFIG[args.voice].pitch, MICROSOFT_VOICE_CONFIG[args.voice].speed) let audio = await sapi4(context, args.text, args.voice, MICROSOFT_VOICE_CONFIG[args.voice].pitch, MICROSOFT_VOICE_CONFIG[args.voice].speed)
await context.editOrRespond({ await context.editOrRespond({
embeds: [createEmbed("defaultNoFooter", context, { description: `${icon("audio")} Audio Generated in ${highlight(audio.timings + "s")}.` })], embeds: [createEmbed("defaultNoFooter", context, { description: `${icon("audio")} Audio Generated in ${highlight(audio.timings + "s")}.` })],

View file

@ -1,9 +1,10 @@
const { moonbase } = require('#api'); const { moonbase } = require('#api');
const { createEmbed } = require('#utils/embed'); const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown'); const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
module.exports = { module.exports = {
description: 'Moonbase Alpha text to speech voices', description: 'Moonbase Alpha text to speech voices',
@ -16,12 +17,18 @@ module.exports = {
type: ApplicationCommandOptionTypes.STRING, type: ApplicationCommandOptionTypes.STRING,
required: true, required: true,
maxLength: 1024 maxLength: 1024
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
await acknowledge(context, args.incognito);
try { try {
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
let audio = await moonbase(context, args.text, args.voice) let audio = await moonbase(context, args.text, args.voice)
await context.editOrRespond({ await context.editOrRespond({

View file

@ -2,9 +2,10 @@ const { playht } = require('#api');
const { PLAYHT_VOICES } = require('#constants'); const { PLAYHT_VOICES } = require('#constants');
const { createEmbed } = require('#utils/embed'); const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown'); const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
module.exports = { module.exports = {
description: 'Text to Speech with playht voices', description: 'Text to Speech with playht voices',
@ -23,11 +24,18 @@ module.exports = {
type: ApplicationCommandOptionTypes.STRING, type: ApplicationCommandOptionTypes.STRING,
required: true, required: true,
maxLength: 256 maxLength: 256
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
await acknowledge(context, args.incognito);
try{ try{
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE})
let audio = await playht(context, args.text, args.voice) let audio = await playht(context, args.text, args.voice)
await context.editOrRespond({ await context.editOrRespond({

View file

@ -2,9 +2,10 @@ const { tiktok } = require('#api');
const { TIKTOK_VOICES_CHARACTERS } = require('#constants'); const { TIKTOK_VOICES_CHARACTERS } = require('#constants');
const { createEmbed } = require('#utils/embed'); const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown'); const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = [] let voices = []
for(const k of Object.keys(TIKTOK_VOICES_CHARACTERS)) voices.unshift({ for(const k of Object.keys(TIKTOK_VOICES_CHARACTERS)) voices.unshift({
@ -28,12 +29,19 @@ module.exports = {
description: 'Voice to use', description: 'Voice to use',
choices: voices, choices: voices,
required: true required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
try { await acknowledge(context, args.incognito);
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
try {
if(args.text.length >= 101) return await context.editOrRespond({ if(args.text.length >= 101) return await context.editOrRespond({
embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")] embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")]
}) })

View file

@ -2,9 +2,10 @@ const { tiktok } = require('#api');
const { TIKTOK_VOICES_FRENCH } = require('#constants'); const { TIKTOK_VOICES_FRENCH } = require('#constants');
const { createEmbed } = require('#utils/embed'); const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown'); const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = [] let voices = []
for(const k of Object.keys(TIKTOK_VOICES_FRENCH)) voices.unshift({ for(const k of Object.keys(TIKTOK_VOICES_FRENCH)) voices.unshift({
@ -28,12 +29,19 @@ module.exports = {
description: 'Voice to use', description: 'Voice to use',
choices: voices, choices: voices,
required: true required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
try { await acknowledge(context, args.incognito);
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
try {
if(args.text.length >= 101) return await context.editOrRespond({ if(args.text.length >= 101) return await context.editOrRespond({
embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")] embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")]
}) })

View file

@ -2,9 +2,10 @@ const { tiktok } = require('#api');
const { TIKTOK_VOICES_GERMAN } = require('#constants'); const { TIKTOK_VOICES_GERMAN } = require('#constants');
const { createEmbed } = require('#utils/embed'); const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown'); const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = [] let voices = []
for(const k of Object.keys(TIKTOK_VOICES_GERMAN)) voices.unshift({ for(const k of Object.keys(TIKTOK_VOICES_GERMAN)) voices.unshift({
@ -28,12 +29,19 @@ module.exports = {
description: 'Voice to use', description: 'Voice to use',
choices: voices, choices: voices,
required: true required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
try { await acknowledge(context, args.incognito);
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
try {
if(args.text.length >= 101) return await context.editOrRespond({ if(args.text.length >= 101) return await context.editOrRespond({
embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")] embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")]
}) })

View file

@ -2,9 +2,10 @@ const { tiktok } = require('#api');
const { TIKTOK_VOICES_INDONESIAN } = require('#constants'); const { TIKTOK_VOICES_INDONESIAN } = require('#constants');
const { createEmbed } = require('#utils/embed'); const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown'); const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = [] let voices = []
for(const k of Object.keys(TIKTOK_VOICES_INDONESIAN)) voices.unshift({ for(const k of Object.keys(TIKTOK_VOICES_INDONESIAN)) voices.unshift({
@ -28,12 +29,19 @@ module.exports = {
description: 'Voice to use', description: 'Voice to use',
choices: voices, choices: voices,
required: true required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
try { await acknowledge(context, args.incognito);
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
try {
if(args.text.length >= 101) return await context.editOrRespond({ if(args.text.length >= 101) return await context.editOrRespond({
embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")] embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")]
}) })

View file

@ -2,9 +2,10 @@ const { tiktok } = require('#api');
const { TIKTOK_VOICES_ITALIAN } = require('#constants'); const { TIKTOK_VOICES_ITALIAN } = require('#constants');
const { createEmbed } = require('#utils/embed'); const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown'); const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = [] let voices = []
for(const k of Object.keys(TIKTOK_VOICES_ITALIAN)) voices.unshift({ for(const k of Object.keys(TIKTOK_VOICES_ITALIAN)) voices.unshift({
@ -28,12 +29,19 @@ module.exports = {
description: 'Voice to use', description: 'Voice to use',
choices: voices, choices: voices,
required: true required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
try { await acknowledge(context, args.incognito);
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
try {
if(args.text.length >= 101) return await context.editOrRespond({ if(args.text.length >= 101) return await context.editOrRespond({
embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")] embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")]
}) })

View file

@ -2,9 +2,10 @@ const { tiktok } = require('#api');
const { TIKTOK_VOICES_JAPANESE } = require('#constants'); const { TIKTOK_VOICES_JAPANESE } = require('#constants');
const { createEmbed } = require('#utils/embed'); const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown'); const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = [] let voices = []
for(const k of Object.keys(TIKTOK_VOICES_JAPANESE)) voices.unshift({ for(const k of Object.keys(TIKTOK_VOICES_JAPANESE)) voices.unshift({
@ -28,12 +29,19 @@ module.exports = {
description: 'Voice to use', description: 'Voice to use',
choices: voices, choices: voices,
required: true required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
try { await acknowledge(context, args.incognito);
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
try {
if(args.text.length >= 101) return await context.editOrRespond({ if(args.text.length >= 101) return await context.editOrRespond({
embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")] embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")]
}) })

View file

@ -2,9 +2,10 @@ const { tiktok } = require('#api');
const { TIKTOK_VOICES_KOREAN } = require('#constants'); const { TIKTOK_VOICES_KOREAN } = require('#constants');
const { createEmbed } = require('#utils/embed'); const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown'); const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = [] let voices = []
for(const k of Object.keys(TIKTOK_VOICES_KOREAN)) voices.unshift({ for(const k of Object.keys(TIKTOK_VOICES_KOREAN)) voices.unshift({
@ -28,12 +29,19 @@ module.exports = {
description: 'Voice to use', description: 'Voice to use',
choices: voices, choices: voices,
required: true required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
try { await acknowledge(context, args.incognito);
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
try {
if(args.text.length >= 101) return await context.editOrRespond({ if(args.text.length >= 101) return await context.editOrRespond({
embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")] embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")]
}) })

View file

@ -2,9 +2,10 @@ const { tiktok } = require('#api');
const { TIKTOK_VOICES_POP_CULTURE } = require('#constants'); const { TIKTOK_VOICES_POP_CULTURE } = require('#constants');
const { createEmbed } = require('#utils/embed'); const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown'); const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = [] let voices = []
for(const k of Object.keys(TIKTOK_VOICES_POP_CULTURE)) voices.unshift({ for(const k of Object.keys(TIKTOK_VOICES_POP_CULTURE)) voices.unshift({
@ -28,12 +29,19 @@ module.exports = {
description: 'Voice to use', description: 'Voice to use',
choices: voices, choices: voices,
required: true, required: true,
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
try { await acknowledge(context, args.incognito);
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
try {
if(args.text.length >= 101) return await context.editOrRespond({ if(args.text.length >= 101) return await context.editOrRespond({
embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")] embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")]
}) })

View file

@ -2,9 +2,10 @@ const { tiktok } = require('#api');
const { TIKTOK_VOICES_PORTUGESE } = require('#constants'); const { TIKTOK_VOICES_PORTUGESE } = require('#constants');
const { createEmbed } = require('#utils/embed'); const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown'); const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = [] let voices = []
for(const k of Object.keys(TIKTOK_VOICES_PORTUGESE)) voices.unshift({ for(const k of Object.keys(TIKTOK_VOICES_PORTUGESE)) voices.unshift({
@ -28,12 +29,19 @@ module.exports = {
description: 'Voice to use', description: 'Voice to use',
choices: voices, choices: voices,
required: true required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
try { await acknowledge(context, args.incognito);
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
try {
if(args.text.length >= 101) return await context.editOrRespond({ if(args.text.length >= 101) return await context.editOrRespond({
embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")] embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")]
}) })

View file

@ -2,9 +2,10 @@ const { tiktok } = require('#api');
const { TIKTOK_VOICES_SONG } = require('#constants'); const { TIKTOK_VOICES_SONG } = require('#constants');
const { createEmbed } = require('#utils/embed'); const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown'); const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = [] let voices = []
for(const k of Object.keys(TIKTOK_VOICES_SONG)) voices.unshift({ for(const k of Object.keys(TIKTOK_VOICES_SONG)) voices.unshift({
@ -28,12 +29,18 @@ module.exports = {
description: 'Voice to use', description: 'Voice to use',
choices: voices, choices: voices,
required: true, required: true,
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
await acknowledge(context, args.incognito);
try { try {
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
if(args.text.length >= 101) return await context.editOrRespond({ if(args.text.length >= 101) return await context.editOrRespond({
embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")] embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")]
}) })

View file

@ -2,9 +2,10 @@ const { tiktok } = require('#api');
const { TIKTOK_VOICES_SPANISH } = require('#constants'); const { TIKTOK_VOICES_SPANISH } = require('#constants');
const { createEmbed } = require('#utils/embed'); const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown'); const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = [] let voices = []
for(const k of Object.keys(TIKTOK_VOICES_SPANISH)) voices.unshift({ for(const k of Object.keys(TIKTOK_VOICES_SPANISH)) voices.unshift({
@ -28,12 +29,18 @@ module.exports = {
description: 'Voice to use', description: 'Voice to use',
choices: voices, choices: voices,
required: true required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
} }
], ],
run: async (context, args) => { run: async (context, args) => {
await acknowledge(context, args.incognito);
try { try {
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
if(args.text.length >= 101) return await context.editOrRespond({ if(args.text.length >= 101) return await context.editOrRespond({
embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")] embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")]
}) })

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 { basecamp } = require("../logging")
const { createEmbed } = require("./embed") const { createEmbed } = require("./embed")
@ -10,6 +10,15 @@ module.exports.editOrReply = function(context, message, disableReference = false
// Disable mentions // Disable mentions
if(!message.allowedMentions) message.allowedMentions = {parse: [], repliedUser: false} 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 // you can figure out what this does on your own time
message.nonce = Math.floor(Math.random() * 9999 + 1000) message.nonce = Math.floor(Math.random() * 9999 + 1000)
@ -32,7 +41,8 @@ module.exports.editOrReply = function(context, message, disableReference = false
allowedMentions: { parse: [], repliedUser: false }, allowedMentions: { parse: [], repliedUser: false },
embeds: [ embeds: [
embedResponse embedResponse
] ],
flags
}) })
}catch(e){ }catch(e){
/* /*