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 { 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')
@ -20,7 +21,7 @@ module.exports = {
],
run: async (context, args) => {
try{
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE})
await acknowledge(context);
const { message } = args;

View file

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

View file

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

View file

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

View file

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

View file

@ -1,9 +1,10 @@
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 { InteractionCallbackTypes } = require("detritus-client/lib/constants");
const { ApplicationCommandOptionTypes } = require("detritus-client/lib/constants");
module.exports = {
description: 'Shows a random otter picture.',
@ -16,8 +17,17 @@ module.exports = {
integrationTypes: [
1
],
run: async (context) => {
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE})
options: [
{
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{
const ott = (await otter()).response.body

View file

@ -1,7 +1,8 @@
const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { editOrReply } = require('#utils/message');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require("detritus-client/lib/constants");
const { ApplicationCommandOptionTypes } = require("detritus-client/lib/constants");
module.exports = {
description: 'Get someones avatar.',
@ -20,10 +21,17 @@ module.exports = {
description: 'User to get the avatar from.',
type: ApplicationCommandOptionTypes.USER,
required: false
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
}
],
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, {
image: {

View file

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

View file

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

View file

@ -1,12 +1,13 @@
const { google } = require('#api');
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 { editOrReply } = require('#utils/message')
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
function createSearchResultPage(context, result){
@ -71,10 +72,17 @@ module.exports = {
description: 'Google search query.',
type: ApplicationCommandOptionTypes.TEXT,
required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
}
],
run: async (context, args) => {
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE})
await acknowledge(context, args.incognito);
try{
let search = await google(context, args.query, false) // safe search is always on

View file

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

View file

@ -1,12 +1,13 @@
const { wolframAlpha } = require('#api');
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 { editOrReply } = require('#utils/message')
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) {
let res = page(createEmbed("default", context, {
@ -56,10 +57,17 @@ module.exports = {
description: 'Computational Query.',
type: ApplicationCommandOptionTypes.TEXT,
required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
}
],
run: async (context, args) => {
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE})
await acknowledge(context, args.incognito);
try {
let search = await wolframAlpha(context, args.query)

View file

@ -1,9 +1,10 @@
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 { ApplicationCommandOptionTypes, InteractionCallbackTypes } = require('detritus-client/lib/constants');
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
const superagent = require('superagent')
@ -24,10 +25,17 @@ module.exports = {
description: 'Search query, can be a title, words from the comic, etc.',
type: ApplicationCommandOptionTypes.TEXT,
required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
}
],
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))){
try{

View file

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

View file

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

View file

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

View file

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

View file

@ -1,9 +1,10 @@
const { WebUtilsWebPageScreenshot} = require("#obelisk");
const { createEmbed } = require("#utils/embed");
const { acknowledge } = require("#utils/interactions");
const { editOrReply } = require("#utils/message");
const { ApplicationCommandOptionTypes, InteractionCallbackTypes } = require('detritus-client/lib/constants');
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
module.exports = {
name: 'screenshot',
@ -22,10 +23,17 @@ module.exports = {
description: 'Website URL.',
type: ApplicationCommandOptionTypes.TEXT,
required: true
},
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
}
],
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...`))

View file

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

View file

@ -2,9 +2,10 @@ const { imtranslator } = require('#api');
const { IMTRANSLATOR_VOICES } = require('#constants');
const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
module.exports = {
description: 'Text to Speech with imtranslator voices',
@ -23,12 +24,19 @@ module.exports = {
type: ApplicationCommandOptionTypes.STRING,
required: true,
maxLength: 256
},
{
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{
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 diff = (Date.now() - s)
await context.editOrRespond({

View file

@ -2,9 +2,10 @@ const { sapi4 } = require('#api');
const { MICROSOFT_VOICES, MICROSOFT_VOICE_CONFIG } = require('#constants');
const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
module.exports = {
description: 'Text to Speech with microsoft voices',
@ -23,11 +24,18 @@ module.exports = {
type: ApplicationCommandOptionTypes.STRING,
required: true,
maxLength: 256
},
{
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{
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)
await context.editOrRespond({
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 { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
module.exports = {
description: 'Moonbase Alpha text to speech voices',
@ -16,12 +17,18 @@ module.exports = {
type: ApplicationCommandOptionTypes.STRING,
required: true,
maxLength: 1024
},
{
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 {
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
let audio = await moonbase(context, args.text, args.voice)
await context.editOrRespond({

View file

@ -2,9 +2,10 @@ const { playht } = require('#api');
const { PLAYHT_VOICES } = require('#constants');
const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
module.exports = {
description: 'Text to Speech with playht voices',
@ -23,11 +24,18 @@ module.exports = {
type: ApplicationCommandOptionTypes.STRING,
required: true,
maxLength: 256
},
{
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{
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE})
let audio = await playht(context, args.text, args.voice)
await context.editOrRespond({

View file

@ -2,9 +2,10 @@ const { tiktok } = require('#api');
const { TIKTOK_VOICES_CHARACTERS } = require('#constants');
const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_CHARACTERS)) voices.unshift({
@ -28,12 +29,19 @@ module.exports = {
description: 'Voice to use',
choices: voices,
required: true
},
{
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 {
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
if(args.text.length >= 101) return await context.editOrRespond({
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 { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_FRENCH)) voices.unshift({
@ -28,12 +29,19 @@ module.exports = {
description: 'Voice to use',
choices: voices,
required: true
},
{
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 {
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
if(args.text.length >= 101) return await context.editOrRespond({
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 { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_GERMAN)) voices.unshift({
@ -28,12 +29,19 @@ module.exports = {
description: 'Voice to use',
choices: voices,
required: true
},
{
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 {
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
if(args.text.length >= 101) return await context.editOrRespond({
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 { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_INDONESIAN)) voices.unshift({
@ -28,12 +29,19 @@ module.exports = {
description: 'Voice to use',
choices: voices,
required: true
},
{
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 {
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
if(args.text.length >= 101) return await context.editOrRespond({
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 { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_ITALIAN)) voices.unshift({
@ -28,12 +29,19 @@ module.exports = {
description: 'Voice to use',
choices: voices,
required: true
},
{
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 {
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
if(args.text.length >= 101) return await context.editOrRespond({
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 { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_JAPANESE)) voices.unshift({
@ -28,12 +29,19 @@ module.exports = {
description: 'Voice to use',
choices: voices,
required: true
},
{
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 {
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
if(args.text.length >= 101) return await context.editOrRespond({
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 { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_KOREAN)) voices.unshift({
@ -28,12 +29,19 @@ module.exports = {
description: 'Voice to use',
choices: voices,
required: true
},
{
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 {
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
if(args.text.length >= 101) return await context.editOrRespond({
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 { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_POP_CULTURE)) voices.unshift({
@ -28,12 +29,19 @@ module.exports = {
description: 'Voice to use',
choices: voices,
required: true,
},
{
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 {
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
if(args.text.length >= 101) return await context.editOrRespond({
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 { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_PORTUGESE)) voices.unshift({
@ -28,12 +29,19 @@ module.exports = {
description: 'Voice to use',
choices: voices,
required: true
},
{
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 {
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
if(args.text.length >= 101) return await context.editOrRespond({
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 { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_SONG)) voices.unshift({
@ -28,12 +29,18 @@ module.exports = {
description: 'Voice to use',
choices: voices,
required: true,
},
{
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 {
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
if(args.text.length >= 101) return await context.editOrRespond({
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 { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { icon, highlight } = require('#utils/markdown');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_SPANISH)) voices.unshift({
@ -28,12 +29,18 @@ module.exports = {
description: 'Voice to use',
choices: voices,
required: true
},
{
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 {
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
if(args.text.length >= 101) return await context.editOrRespond({
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 { createEmbed } = require("./embed")
@ -10,6 +10,15 @@ module.exports.editOrReply = function(context, message, disableReference = false
// Disable mentions
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
message.nonce = Math.floor(Math.random() * 9999 + 1000)
@ -32,7 +41,8 @@ module.exports.editOrReply = function(context, message, disableReference = false
allowedMentions: { parse: [], repliedUser: false },
embeds: [
embedResponse
]
],
flags
})
}catch(e){
/*