a bunch of things also deepai

This commit is contained in:
derpystuff 2022-05-25 21:26:57 +02:00
parent aec828beb5
commit 0c4e48bd39
9 changed files with 219 additions and 6 deletions

View file

@ -51,6 +51,7 @@ function createCommandPage(context, prefix, command){
const categories = {
"core": `${icon("house")} Core Commands`,
"info": `${icon("info")} Information Commands`,
"image": `${icon("image")} Image Commands`,
"mod": `${icon("moderation")} Moderation Commands`,
"search": `${icon("search")} Search Commands`
}

View file

@ -0,0 +1,39 @@
const { getRecentImage } = require("../../../../labscore/utils/attachment");
const { createEmbed } = require("../../../../labscore/utils/embed");
const { editOrReply } = require("../../../../labscore/utils/message");
const { deepdream } = require('../../../../labscore/api')
module.exports = {
name: 'deepdream',
aliases: ['dd'],
metadata: {
description: 'deepdream',
examples: ['deepdream'],
category: 'image',
usage: 'deepdream <image>'
},
run: async (context, args) => {
context.triggerTyping();
try{
let image = await getRecentImage(context, 50)
if(!image) return editOrReply(context, { embeds: [createEmbed("warning", context, "No images found.")] })
let res = await deepdream(context, image)
if(res.response.body.status == 1) return editOrReply(context, {embeds:[createEmbed("warning", context, res.response.body.errors[0])]})
return editOrReply(context, {embeds:[createEmbed("default", context, {
image: {
url: res.response.body.image
},
footer: {
iconUrl: `https://cdn.discordapp.com/avatars/${context.application.id}/${context.application.icon}.png?size=256`,
text: `${context.application.name} • Took ${res.timings}s`
}
})]})
}catch(e){
console.log(e)
return editOrReply(context, {embeds:[createEmbed("error", context, `Unable to modify image.`)]})
}
},
};

View file

@ -0,0 +1,39 @@
const { getRecentImage } = require("../../../../labscore/utils/attachment");
const { createEmbed } = require("../../../../labscore/utils/embed");
const { editOrReply } = require("../../../../labscore/utils/message");
const { superresolution } = require('../../../../labscore/api')
module.exports = {
name: 'superresolution',
aliases: ['sr'],
metadata: {
description: 'superresolution',
examples: ['superresolution'],
category: 'image',
usage: 'superresolution <image>'
},
run: async (context, args) => {
context.triggerTyping();
try{
let image = await getRecentImage(context, 50)
if(!image) return editOrReply(context, { embeds: [createEmbed("warning", context, "No images found.")] })
let res = await superresolution(context, image)
if(res.response.body.status == 1) return editOrReply(context, {embeds:[createEmbed("warning", context, res.response.body.errors[0])]})
return editOrReply(context, {embeds:[createEmbed("default", context, {
image: {
url: res.response.body.image
},
footer: {
iconUrl: `https://cdn.discordapp.com/avatars/${context.application.id}/${context.application.icon}.png?size=256`,
text: `${context.application.name} • Took ${res.timings}s`
}
})]})
}catch(e){
console.log(e)
return editOrReply(context, {embeds:[createEmbed("error", context, `Unable to modify image.`)]})
}
},
};

View file

@ -0,0 +1,39 @@
const { getRecentImage } = require("../../../../labscore/utils/attachment");
const { createEmbed } = require("../../../../labscore/utils/embed");
const { editOrReply } = require("../../../../labscore/utils/message");
const { waifu2x } = require('../../../../labscore/api')
module.exports = {
name: 'waifu2x',
aliases: ['2x'],
metadata: {
description: 'waifu2x',
examples: ['waifu2x'],
category: 'image',
usage: 'waifu2x <image>'
},
run: async (context, args) => {
context.triggerTyping();
try{
let image = await getRecentImage(context, 50)
if(!image) return editOrReply(context, { embeds: [createEmbed("warning", context, "No images found.")] })
let res = await waifu2x(context, image)
if(res.response.body.status == 1) return editOrReply(context, {embeds:[createEmbed("warning", context, res.response.body.errors[0])]})
return editOrReply(context, {embeds:[createEmbed("default", context, {
image: {
url: res.response.body.image
},
footer: {
iconUrl: `https://cdn.discordapp.com/avatars/${context.application.id}/${context.application.icon}.png?size=256`,
text: `${context.application.name} • Took ${res.timings}s`
}
})]})
}catch(e){
console.log(e)
return editOrReply(context, {embeds:[createEmbed("error", context, `Unable to modify image.`)]})
}
},
};

View file

@ -14,12 +14,12 @@ module.exports = {
},
run: async (context, args) => {
context.triggerTyping();
let u;
if(!args.user) { u = context.user } else { u = await getUser(context, args.user) }
if(!u) return editOrReply(context, { embeds: [createEmbed("warning", context, "No users found.")] })
let u = {};
if(!args.user) { u.user = context.user } else { u = await getUser(context, args.user) }
if(!u.user) return editOrReply(context, { embeds: [createEmbed("warning", context, "No users found.")] })
return editOrReply(context, { embeds: [createEmbed("default", context, {
image: {
url: u.avatarUrl + '?size=4096'
url: u.user.avatarUrl + '?size=4096'
}
})] })
},

View file

@ -0,0 +1,60 @@
const { createEmbed, formatPaginationEmbeds } = require('../../../labscore/utils/embed')
const { link } = require('../../../labscore/utils/markdown')
const { editOrReply } = require('../../../labscore/utils/message')
const { STATICS } = require('../../../labscore/utils/statics')
const { paginator } = require('../../../labscore/client');
const { youtube } = require('../../../labscore/api');
function createYoutubePage(context, result){
let res = {
"embeds": [
createEmbed("default", context, {
description: `**${link(result.url, result.name)}**\n${result.description}`,
thumbnail: {
url: result.image
},
footer: {
iconUrl: STATICS.youtube,
text: `YouTube • ${context.application.name}`
}
})
]
}
return res;
}
module.exports = {
name: 'youtube',
label: 'query',
aliases: ['yt'],
metadata: {
description: 'youtube search',
examples: ['youtube Google'],
category: 'search',
usage: 'youtube <query>'
},
run: async (context, args) => {
context.triggerTyping();
if(!args.query) return editOrReply(context, {embeds:[createEmbed("warning", context, `Missing Parameter (query).`)]})
try{
let search = await youtube(context, args.query)
search = search.response
let pages = []
for(const res of search.body.results){
pages.push(createYoutubePage(context, res))
}
pages = formatPaginationEmbeds(pages)
const message = context.message
const paging = await paginator.createPaginator({
message,
pages
});
}catch(e){
console.log(e)
return editOrReply(context, {embeds:[createEmbed("error", context, `Unable to perform google search.`)]})
}
},
};