mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-07 21:53:07 -04:00
add ingest
This commit is contained in:
parent
3e4d5258ae
commit
4c8d717e9a
4 changed files with 30 additions and 2 deletions
|
@ -8,6 +8,7 @@ const { icon, pill, iconPill, highlight, timestamp } = require("../../../../labs
|
||||||
const { editOrReply } = require("../../../../labscore/utils/message");
|
const { editOrReply } = require("../../../../labscore/utils/message");
|
||||||
const { STATICS } = require("../../../../labscore/utils/statics");
|
const { STATICS } = require("../../../../labscore/utils/statics");
|
||||||
const { Components, Snowflake } = require("detritus-client/lib/utils");
|
const { Components, Snowflake } = require("detritus-client/lib/utils");
|
||||||
|
const { ingest } = require("../../../../labscore/logging");
|
||||||
|
|
||||||
const onlyEmoji = require('emoji-aware').onlyEmoji;
|
const onlyEmoji = require('emoji-aware').onlyEmoji;
|
||||||
|
|
||||||
|
@ -34,6 +35,9 @@ function toCodePoint(unicodeSurrogates, sep) {
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'emoji',
|
name: 'emoji',
|
||||||
description: 'Turn emoji into images. Supports both built-in and custom emoji.',
|
description: 'Turn emoji into images. Supports both built-in and custom emoji.',
|
||||||
|
metadata: {
|
||||||
|
use_custom_ingest: true
|
||||||
|
},
|
||||||
contexts: [
|
contexts: [
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
|
@ -59,6 +63,7 @@ module.exports = {
|
||||||
);
|
);
|
||||||
embeds = []
|
embeds = []
|
||||||
if (matches.length) {
|
if (matches.length) {
|
||||||
|
ingest("emoji_enlarge", "slash_command_ran");
|
||||||
let form = '.png'
|
let form = '.png'
|
||||||
if(matches[0].animated) form = '.gif'
|
if(matches[0].animated) form = '.gif'
|
||||||
|
|
||||||
|
@ -83,6 +88,7 @@ module.exports = {
|
||||||
|
|
||||||
// Emoji Mixing
|
// Emoji Mixing
|
||||||
if(emoji.length >= 2){
|
if(emoji.length >= 2){
|
||||||
|
ingest("emoji_emojikitchen", "slash_command_ran");
|
||||||
try{
|
try{
|
||||||
let em = await emojiKitchen(emoji)
|
let em = await emojiKitchen(emoji)
|
||||||
if(!em.body.results[0]){
|
if(!em.body.results[0]){
|
||||||
|
@ -105,6 +111,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regular Emoji Handling
|
// Regular Emoji Handling
|
||||||
|
ingest("emoji_enlarge", "slash_command_ran");
|
||||||
if(emoji.length == 0) return await editOrReply(context, createEmbed("warning", context, "You need to specify an emoji to enlarge."))
|
if(emoji.length == 0) return await editOrReply(context, createEmbed("warning", context, "You need to specify an emoji to enlarge."))
|
||||||
|
|
||||||
let res;
|
let res;
|
||||||
|
|
|
@ -9,6 +9,7 @@ const { editOrReply } = require("../../../labscore/utils/message");
|
||||||
const { STATICS } = require("../../../labscore/utils/statics");
|
const { STATICS } = require("../../../labscore/utils/statics");
|
||||||
const { Components, Snowflake } = require("detritus-client/lib/utils");
|
const { Components, Snowflake } = require("detritus-client/lib/utils");
|
||||||
const { bold } = require("detritus-client/lib/utils/markup");
|
const { bold } = require("detritus-client/lib/utils/markup");
|
||||||
|
const { ingest } = require("../../../labscore/logging");
|
||||||
|
|
||||||
const onlyEmoji = require('emoji-aware').onlyEmoji;
|
const onlyEmoji = require('emoji-aware').onlyEmoji;
|
||||||
|
|
||||||
|
@ -41,7 +42,8 @@ module.exports = {
|
||||||
description_short: 'Get emoji/sticker source images, mix two emoji together.',
|
description_short: 'Get emoji/sticker source images, mix two emoji together.',
|
||||||
examples: ['e 😀', 'emojimix 🐱 🍞'],
|
examples: ['e 😀', 'emojimix 🐱 🍞'],
|
||||||
category: 'utils',
|
category: 'utils',
|
||||||
usage: 'emoji <emoji> [<emoji to mix>]'
|
usage: 'emoji <emoji> [<emoji to mix>]',
|
||||||
|
use_custom_ingest: true
|
||||||
},
|
},
|
||||||
args: [
|
args: [
|
||||||
{name: 'type', default: 'twitter', type: 'string', help: `Emoji platform type`}
|
{name: 'type', default: 'twitter', type: 'string', help: `Emoji platform type`}
|
||||||
|
@ -57,6 +59,7 @@ module.exports = {
|
||||||
|
|
||||||
// Stickers
|
// Stickers
|
||||||
if(msg.stickerItems.length){
|
if(msg.stickerItems.length){
|
||||||
|
ingest("emoji_sticker", "command_ran");
|
||||||
let s = msg.stickerItems.first()
|
let s = msg.stickerItems.first()
|
||||||
if(s.formatType == 3) return editOrReply(context, createEmbed("default", context, {
|
if(s.formatType == 3) return editOrReply(context, createEmbed("default", context, {
|
||||||
description: `${iconPill("sticker", s.name)} ${highlight(`(${s.id})`)}\nhttps://cdn.discordapp.com/stickers/${s.id}.json`,
|
description: `${iconPill("sticker", s.name)} ${highlight(`(${s.id})`)}\nhttps://cdn.discordapp.com/stickers/${s.id}.json`,
|
||||||
|
@ -76,6 +79,7 @@ module.exports = {
|
||||||
);
|
);
|
||||||
embeds = []
|
embeds = []
|
||||||
if (matches.length) {
|
if (matches.length) {
|
||||||
|
ingest("emoji_enlarge", "command_ran");
|
||||||
let form = '.png'
|
let form = '.png'
|
||||||
if(matches[0].animated) form = '.gif'
|
if(matches[0].animated) form = '.gif'
|
||||||
|
|
||||||
|
@ -102,6 +106,7 @@ module.exports = {
|
||||||
// Emoji Mixing
|
// Emoji Mixing
|
||||||
if(emoji.length >= 2){
|
if(emoji.length >= 2){
|
||||||
try{
|
try{
|
||||||
|
ingest("emoji_emojikitchen", "command_ran");
|
||||||
let em = await emojiKitchen(emoji)
|
let em = await emojiKitchen(emoji)
|
||||||
if(!em.body.results[0]){
|
if(!em.body.results[0]){
|
||||||
for(const em of emoji){
|
for(const em of emoji){
|
||||||
|
@ -120,6 +125,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ingest("emoji_enlarge", "command_ran");
|
||||||
// Regular Emoji Handling
|
// Regular Emoji Handling
|
||||||
if(emoji.length == 0) return await editOrReply(context, createEmbed("warning", context, "You need to specify an emoji to enlarge."))
|
if(emoji.length == 0) return await editOrReply(context, createEmbed("warning", context, "You need to specify an emoji to enlarge."))
|
||||||
|
|
||||||
|
|
|
@ -57,11 +57,16 @@ const interactionClient = new InteractionCommandClient(cluster, {
|
||||||
useClusterClient: true
|
useClusterClient: true
|
||||||
})
|
})
|
||||||
|
|
||||||
const { maintower, basecamp } = require('./logging');
|
const { maintower, basecamp, ingest } = require('./logging');
|
||||||
const { icon, highlight } = require('./utils/markdown');
|
const { icon, highlight } = require('./utils/markdown');
|
||||||
const { editOrReply } = require('./utils/message');
|
const { editOrReply } = require('./utils/message');
|
||||||
|
|
||||||
const { createEmbed } = require('./utils/embed');
|
const { createEmbed } = require('./utils/embed');
|
||||||
|
const superagent = require('superagent');
|
||||||
|
|
||||||
|
// Analytics
|
||||||
|
commandClient.on('commandRan', ({ context, command }) => { if(!command.metadata.use_custom_ingest) ingest(command.name, "slash_command_ran")} )
|
||||||
|
interactionClient.on('commandRan', ({ context, command }) => { if(!command.metadata.use_custom_ingest) ingest(command.name, "slash_command_ran")} )
|
||||||
|
|
||||||
// Handle missing permission errors
|
// Handle missing permission errors
|
||||||
commandClient.on('commandPermissionsFailClient', ({context, permissions}) => {
|
commandClient.on('commandPermissionsFailClient', ({context, permissions}) => {
|
||||||
|
|
|
@ -38,4 +38,14 @@ module.exports.basecamp = async function (log, content = ""){
|
||||||
console.log(e)
|
console.log(e)
|
||||||
throw "Basecamp request failed."
|
throw "Basecamp request failed."
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.ingest = async function (event, type = "generic"){
|
||||||
|
try{
|
||||||
|
let r = await superagent.get(`${process.env.INGEST_SERVICE_HOST}/d/${type}/${event}`)
|
||||||
|
.set("x-ingest-client", process.env.INGEST_SERVICE_CLIENT)
|
||||||
|
}catch(e){
|
||||||
|
console.log(e)
|
||||||
|
console.log("ingest failed")
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue