mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-10 23:23:08 -04:00
wip
This commit is contained in:
parent
7195d43c74
commit
6173b085a3
26 changed files with 1112 additions and 91 deletions
68
commands/message/core/help.js
Normal file
68
commands/message/core/help.js
Normal file
|
@ -0,0 +1,68 @@
|
|||
const { codeblock, highlight, icon } = require('../../../labscore/utils/markdown')
|
||||
const { createEmbed, formatPaginationEmbeds } = require('../../../labscore/utils/embed')
|
||||
|
||||
const { paginator } = require('../../../labscore/client');
|
||||
|
||||
function createHelpPage(context, title, contents){
|
||||
return {
|
||||
"embeds": [
|
||||
createEmbed("default", context, {
|
||||
description: `${title}\n` +
|
||||
codeblock("ansi", contents) +
|
||||
`\n${icon("question")} Use ${highlight(`${context.commandClient.prefixes.custom.first()}help <command>`)} to view more information about a command.`
|
||||
})
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
// These categories will be displayed to users, add them in the correct order
|
||||
const categories = {
|
||||
"core": `${icon("house")} Core Commands`,
|
||||
"search": `${icon("search")} Search Commands`,
|
||||
"dev": `${icon("analytics")} Development`
|
||||
}
|
||||
|
||||
const reactions = {
|
||||
previousPage: "⬅️",
|
||||
nextPage: "➡️"
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
name: 'help',
|
||||
label: 'command',
|
||||
metadata: {
|
||||
description: 'Command List',
|
||||
examples: ['help ping'],
|
||||
category: 'core',
|
||||
usage: 'help [<command>]'
|
||||
},
|
||||
run: async (context, args) => {
|
||||
context.triggerTyping();
|
||||
if(args.label){
|
||||
// Detailed command view
|
||||
} else {
|
||||
// Full command list
|
||||
let commands = {
|
||||
}
|
||||
let prefix = context.commandClient.prefixes.custom.first()
|
||||
for(const c of context.commandClient.commands){
|
||||
if(!categories[c.metadata.category]) continue;
|
||||
if(!commands[c.metadata.category]) commands[c.metadata.category] = []
|
||||
commands[c.metadata.category].push(`${prefix}${c.name}`)
|
||||
}
|
||||
|
||||
let pages = []
|
||||
for(const cat of Object.keys(categories)){
|
||||
pages.push(createHelpPage(context, categories[cat], commands[cat]))
|
||||
}
|
||||
|
||||
pages = formatPaginationEmbeds(pages)
|
||||
const message = context.message
|
||||
const paging = await paginator.createReactionPaginator({
|
||||
message,
|
||||
pages,
|
||||
reactions
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
25
commands/message/core/ping.js
Normal file
25
commands/message/core/ping.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
const { format } = require('../../../labscore/utils/ansi')
|
||||
const { codeblock, icon } = require('../../../labscore/utils/markdown')
|
||||
const { createEmbed } = require('../../../labscore/utils/embed')
|
||||
const { editOrReply } = require('../../../labscore/utils/message')
|
||||
|
||||
module.exports = {
|
||||
description: 'ping!',
|
||||
name: 'ping',
|
||||
metadata: {
|
||||
description: 'bot latency',
|
||||
examples: ['ping'],
|
||||
category: 'core',
|
||||
usage: 'ping'
|
||||
},
|
||||
run: async (context) => {
|
||||
context.triggerTyping();
|
||||
ping = await context.client.ping()
|
||||
editOrReply(context, {
|
||||
content: "",
|
||||
embeds: [createEmbed("default", context, {
|
||||
description: `${icon("connection")} **Bot Latency**\n` + codeblock("ansi", [`rest ${format(`${ping.rest}ms`, "m")}`, `gateway ${format(`${ping.gateway}ms`, "m")}`])
|
||||
})]
|
||||
})
|
||||
},
|
||||
};
|
37
commands/message/dev/debug/page.js
Normal file
37
commands/message/dev/debug/page.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
const { Constants } = require('detritus-client');
|
||||
const { paginator } = require('../../../../labscore/client');
|
||||
|
||||
const reactions = {
|
||||
previousPage: "⬅️",
|
||||
nextPage: "➡️"
|
||||
};
|
||||
|
||||
const createEmbedMessage = (title, description) => ({
|
||||
embeds: [{ title, description }]
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
name: 'page',
|
||||
metadata: {
|
||||
description: 'pagination test',
|
||||
examples: ['page'],
|
||||
category: 'dev',
|
||||
usage: 'page'
|
||||
},
|
||||
run: async (context) => {
|
||||
const message = context.message
|
||||
const pages = [
|
||||
createEmbedMessage("Page", "ddd"),
|
||||
createEmbedMessage("Page2", "eee"),
|
||||
createEmbedMessage("Page 3", "h")
|
||||
]
|
||||
const paging = await paginator.createReactionPaginator({
|
||||
// message is the message the user has sent
|
||||
message,
|
||||
// pages is an array of pages (will be passed as parameter in Message#edit)
|
||||
pages,
|
||||
// reactions is an object that includes `previousPage` and `nextPage` emojis (defined above)
|
||||
reactions
|
||||
});
|
||||
},
|
||||
};
|
14
commands/message/dev/debug/test.js
Normal file
14
commands/message/dev/debug/test.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
|
||||
|
||||
module.exports = {
|
||||
name: 'test',
|
||||
metadata: {
|
||||
description: 'test',
|
||||
examples: ['test'],
|
||||
category: 'dev',
|
||||
usage: 'test'
|
||||
},
|
||||
run: async (context) => {
|
||||
return context.editOrReply('test successful.')
|
||||
},
|
||||
};
|
64
commands/message/dev/eval.js
Normal file
64
commands/message/dev/eval.js
Normal file
|
@ -0,0 +1,64 @@
|
|||
const { Constants, Utils } = require("detritus-client");
|
||||
const Permissions = Constants.Permissions;
|
||||
|
||||
const AsyncFunction = Object.getPrototypeOf(async function(){}).constructor;
|
||||
|
||||
// TODO: remake this eventually, copy pasted it from v1 cause lazy
|
||||
|
||||
module.exports = {
|
||||
label: "code",
|
||||
name: "dev",
|
||||
metadata: {
|
||||
description: 'Evaluate code.',
|
||||
examples: ['eval console.log(\'ping\'); -async false'],
|
||||
category: 'dev',
|
||||
usage: 'eval <code> [-async <true|false>] [-noreply <true|false>] [-jsonspacing <integer>]'
|
||||
},
|
||||
args: [
|
||||
{ default: false, name: "noreply", type: "bool" },
|
||||
{ default: 2, name: "jsonspacing", type: "number" },
|
||||
{ default: true, name: "async", type: "bool" }
|
||||
],
|
||||
onBefore: context => context.user.isClientOwner,
|
||||
onCancel: context =>
|
||||
context.reply(
|
||||
`${context.user.mention}, you are lacking the permission \`BOT_OWNER\`.`
|
||||
),
|
||||
run: async (context, args) => {
|
||||
await context.triggerTyping();
|
||||
const { matches } = Utils.regex(
|
||||
Constants.DiscordRegexNames.TEXT_CODEBLOCK,
|
||||
args.code
|
||||
);
|
||||
if (matches.length) {
|
||||
args.code = matches[0].text;
|
||||
}
|
||||
|
||||
let language = "js";
|
||||
let message;
|
||||
try {
|
||||
if(args.async == false){
|
||||
message = await Promise.resolve(eval(args.code));
|
||||
} else {
|
||||
const func = new AsyncFunction('context', args.code);
|
||||
message = await func(context);
|
||||
}
|
||||
if (typeof message === "object") {
|
||||
message = JSON.stringify(message, null, args.jsonspacing);
|
||||
language = "json";
|
||||
}
|
||||
} catch (error) {
|
||||
message = error ? error.stack || error.message : error;
|
||||
}
|
||||
const max = 1990 - language.length;
|
||||
if (!args.noreply) {
|
||||
const reply = ["```" + language, String(message).slice(0, max), "```"].join("\n")
|
||||
return context.editOrReply(
|
||||
reply
|
||||
);
|
||||
}
|
||||
},
|
||||
onError: (context, args, error) => {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
43
commands/message/dev/reload.js
Normal file
43
commands/message/dev/reload.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
const { Constants, Utils } = require("detritus-client");
|
||||
const Permissions = Constants.Permissions;
|
||||
|
||||
// TODO: remake this eventually, copy pasted it from v1 cause lazy
|
||||
|
||||
module.exports = {
|
||||
name: "reload",
|
||||
aliases: ["rl"],
|
||||
metadata: {
|
||||
description: 'Reloads commands on all shards.',
|
||||
examples: ['reload'],
|
||||
category: 'dev',
|
||||
usage: 'reload'
|
||||
},
|
||||
onBefore: context => context.user.isClientOwner,
|
||||
onCancel: context =>
|
||||
context.reply(
|
||||
`${context.user.mention}, you are lacking the permission \`BOT_OWNER\`.`
|
||||
),
|
||||
run: async (context, args) => {
|
||||
await context.triggerTyping();
|
||||
const time = Date.now();
|
||||
console.log(`v2 | command refresh requested @ ${Date.now()} by ${context.user.username}${context.user.discriminator} (${context.user.id})`)
|
||||
const data = await context.manager.broadcastEval(async (cluster) => {
|
||||
let shards = 0
|
||||
if (cluster.commandClient) {
|
||||
const commandClient = cluster.commandClient;
|
||||
commandClient.clear();
|
||||
await commandClient.addMultipleIn('../commands/message/', {subdirectories: true});
|
||||
shards = cluster.shards.length
|
||||
}
|
||||
return shards;
|
||||
});
|
||||
let refreshed = data.map((e)=>{return parseInt(e)}).reduce((a, b) => {return a + b}, 0)
|
||||
let diff = Date.now();
|
||||
if (diff < time) diff.setDate(diff.getDate() + 1);
|
||||
diff = diff - time;
|
||||
if(`${refreshed}` == "NaN"){
|
||||
return context.editOrReply(`Failed to reload all commands after \`${diff}ms\`.`)
|
||||
}
|
||||
return context.editOrReply(` Reloaded commands on \`${refreshed}/${context.manager.cluster.shardCount}\` shards in \`${diff}ms\`.`)
|
||||
}
|
||||
};
|
38
commands/message/image/photofunia/yacht.js
Normal file
38
commands/message/image/photofunia/yacht.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
const { createEmbed } = require('../../../../labscore/utils/embed')
|
||||
const { editOrReply } = require('../../../../labscore/utils/message')
|
||||
const { STATICS } = require('../../../../labscore/utils/statics')
|
||||
|
||||
const { yacht } = require('../../../../labscore/api')
|
||||
|
||||
module.exports = {
|
||||
name: 'yacht',
|
||||
label: 'text',
|
||||
metadata: {
|
||||
description: 'crazy yacht',
|
||||
examples: ['yacht Im on a boat.'],
|
||||
category: 'image',
|
||||
usage: 'yacht <text>'
|
||||
},
|
||||
run: async (context, args) => {
|
||||
context.triggerTyping();
|
||||
if(!args.text) return editOrReply(context, {embeds:[createEmbed("warning", context, `Missing Parameter (text).`)]})
|
||||
if(args.text.length >= 26) return editOrReply(context, {embeds:[createEmbed("warning", context, `Parameter text too long (>25).`)]})
|
||||
try{
|
||||
let res = await yacht(context, args.text)
|
||||
image = res.response.body.data.images[res.response.body.data.best_quality]
|
||||
return editOrReply(context, {embeds:[createEmbed("default", context, {
|
||||
description: `⛵`,
|
||||
image: {
|
||||
url: image
|
||||
},
|
||||
footer: {
|
||||
iconUrl: STATICS.photofunia,
|
||||
text: `PhotoFunia • ${context.application.name} • Took ${res.timings}s`
|
||||
}
|
||||
})]})
|
||||
}catch(e){
|
||||
console.log(e)
|
||||
return editOrReply(context, {embeds:[createEmbed("error", context, `Unable to generate image.`)]})
|
||||
}
|
||||
}
|
||||
};
|
67
commands/message/search/bing-images.js
Normal file
67
commands/message/search/bing-images.js
Normal file
|
@ -0,0 +1,67 @@
|
|||
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 { bingImages } = require('../../../labscore/api');
|
||||
|
||||
function createImageResultPage(context, result){
|
||||
let res = {
|
||||
"embeds": [
|
||||
createEmbed("default", context, {
|
||||
description: `**${link(result.url, result.title)}**`,
|
||||
image: {
|
||||
url: result.image
|
||||
},
|
||||
footer: {
|
||||
iconUrl: STATICS.bing,
|
||||
text: `Microsoft Bing • ${context.application.name}`
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
if(result.thumbnail) res.embeds[0].thumbnail = { url: result.thumbnail };
|
||||
return res;
|
||||
}
|
||||
|
||||
const reactions = {
|
||||
previousPage: "⬅️",
|
||||
nextPage: "➡️"
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
name: 'bingimage',
|
||||
label: 'query',
|
||||
aliases: ['bi', 'img2'],
|
||||
metadata: {
|
||||
description: 'bing image search',
|
||||
examples: ['bing Large Magenta Sphere'],
|
||||
category: 'search',
|
||||
usage: 'bing <query>'
|
||||
},
|
||||
run: async (context, args) => {
|
||||
context.triggerTyping();
|
||||
if(!args.query) return editOrReply(context, {embeds:[createEmbed("warning", context, `Missing Parameter (query).`)]})
|
||||
try{
|
||||
let search = await bingImages(context, args.query)
|
||||
search = search.response
|
||||
|
||||
let pages = []
|
||||
for(const res of search.body.results){
|
||||
pages.push(createImageResultPage(context, res))
|
||||
}
|
||||
|
||||
pages = formatPaginationEmbeds(pages)
|
||||
const message = context.message
|
||||
const paging = await paginator.createReactionPaginator({
|
||||
message,
|
||||
pages,
|
||||
reactions
|
||||
});
|
||||
}catch(e){
|
||||
console.log(e)
|
||||
return editOrReply(context, {embeds:[createEmbed("error", context, `Unable to perform google search.`)]})
|
||||
}
|
||||
},
|
||||
};
|
63
commands/message/search/bing.js
Normal file
63
commands/message/search/bing.js
Normal file
|
@ -0,0 +1,63 @@
|
|||
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 { bing } = require('../../../labscore/api');
|
||||
|
||||
function createSearchResultPage(context, result){
|
||||
let res = {
|
||||
"embeds": [
|
||||
createEmbed("default", context, {
|
||||
description: `**${link(result.url, result.title)}**\n${result.snippet}`,
|
||||
footer: {
|
||||
iconUrl: STATICS.bing,
|
||||
text: `Microsoft Bing • ${context.application.name}`
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
const reactions = {
|
||||
previousPage: "⬅️",
|
||||
nextPage: "➡️"
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
name: 'bing',
|
||||
label: 'query',
|
||||
aliases: ['b', 'search2'],
|
||||
metadata: {
|
||||
description: 'bing search',
|
||||
examples: ['bing Flask'],
|
||||
category: 'search',
|
||||
usage: 'bing <query>'
|
||||
},
|
||||
run: async (context, args) => {
|
||||
context.triggerTyping();
|
||||
if(!args.query) return editOrReply(context, {embeds:[createEmbed("warning", context, `Missing Parameter (query).`)]})
|
||||
try{
|
||||
let search = await bing(context, args.query)
|
||||
search = search.response
|
||||
|
||||
let pages = []
|
||||
for(const res of search.body.results){
|
||||
pages.push(createSearchResultPage(context, res))
|
||||
}
|
||||
|
||||
pages = formatPaginationEmbeds(pages)
|
||||
const message = context.message
|
||||
const paging = await paginator.createReactionPaginator({
|
||||
message,
|
||||
pages,
|
||||
reactions
|
||||
});
|
||||
}catch(e){
|
||||
console.log(e)
|
||||
return editOrReply(context, {embeds:[createEmbed("error", context, `Unable to perform google search.`)]})
|
||||
}
|
||||
},
|
||||
};
|
67
commands/message/search/google-images.js
Normal file
67
commands/message/search/google-images.js
Normal file
|
@ -0,0 +1,67 @@
|
|||
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 { googleImages } = require('../../../labscore/api');
|
||||
|
||||
function createImageResultPage(context, result){
|
||||
let res = {
|
||||
"embeds": [
|
||||
createEmbed("default", context, {
|
||||
description: `**${link(result.url, result.title)}**`,
|
||||
image: {
|
||||
url: result.image
|
||||
},
|
||||
footer: {
|
||||
iconUrl: STATICS.google,
|
||||
text: `Google Images • ${context.application.name}`
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
if(result.thumbnail) res.embeds[0].thumbnail = { url: result.thumbnail };
|
||||
return res;
|
||||
}
|
||||
|
||||
const reactions = {
|
||||
previousPage: "⬅️",
|
||||
nextPage: "➡️"
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
name: 'image',
|
||||
label: 'query',
|
||||
aliases: ['i', 'img'],
|
||||
metadata: {
|
||||
description: 'google image search',
|
||||
examples: ['image Large Magenta Sphere'],
|
||||
category: 'search',
|
||||
usage: 'image <query>'
|
||||
},
|
||||
run: async (context, args) => {
|
||||
context.triggerTyping();
|
||||
if(!args.query) return editOrReply(context, {embeds:[createEmbed("warning", context, `Missing Parameter (query).`)]})
|
||||
try{
|
||||
let search = await googleImages(context, args.query)
|
||||
search = search.response
|
||||
|
||||
let pages = []
|
||||
for(const res of search.body.results){
|
||||
pages.push(createImageResultPage(context, res))
|
||||
}
|
||||
|
||||
pages = formatPaginationEmbeds(pages)
|
||||
const message = context.message
|
||||
const paging = await paginator.createReactionPaginator({
|
||||
message,
|
||||
pages,
|
||||
reactions
|
||||
});
|
||||
}catch(e){
|
||||
console.log(e)
|
||||
return editOrReply(context, {embeds:[createEmbed("error", context, `Unable to perform google search.`)]})
|
||||
}
|
||||
},
|
||||
};
|
64
commands/message/search/google.js
Normal file
64
commands/message/search/google.js
Normal file
|
@ -0,0 +1,64 @@
|
|||
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 { google } = require('../../../labscore/api');
|
||||
|
||||
function createSearchResultPage(context, result){
|
||||
let res = {
|
||||
"embeds": [
|
||||
createEmbed("default", context, {
|
||||
description: `**${link(result.url, result.title)}**\n${result.content}`,
|
||||
footer: {
|
||||
iconUrl: STATICS.google,
|
||||
text: `Google • ${context.application.name}`
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
if(result.thumbnail) res.embeds[0].thumbnail = { url: result.thumbnail };
|
||||
return res;
|
||||
}
|
||||
|
||||
const reactions = {
|
||||
previousPage: "⬅️",
|
||||
nextPage: "➡️"
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
name: 'google',
|
||||
label: 'query',
|
||||
aliases: ['g', 'search'],
|
||||
metadata: {
|
||||
description: 'google search',
|
||||
examples: ['google Flask'],
|
||||
category: 'search',
|
||||
usage: 'google <query>'
|
||||
},
|
||||
run: async (context, args) => {
|
||||
context.triggerTyping();
|
||||
if(!args.query) return editOrReply(context, {embeds:[createEmbed("warning", context, `Missing Parameter (query).`)]})
|
||||
try{
|
||||
let search = await google(context, args.query)
|
||||
search = search.response
|
||||
|
||||
let pages = []
|
||||
for(const res of search.body.results){
|
||||
pages.push(createSearchResultPage(context, res))
|
||||
}
|
||||
|
||||
pages = formatPaginationEmbeds(pages)
|
||||
const message = context.message
|
||||
const paging = await paginator.createReactionPaginator({
|
||||
message,
|
||||
pages,
|
||||
reactions
|
||||
});
|
||||
}catch(e){
|
||||
console.log(e)
|
||||
return editOrReply(context, {embeds:[createEmbed("error", context, `Unable to perform google search.`)]})
|
||||
}
|
||||
},
|
||||
};
|
93
commands/message/search/lyrics.js
Normal file
93
commands/message/search/lyrics.js
Normal file
|
@ -0,0 +1,93 @@
|
|||
const { createEmbed, formatPaginationEmbeds } = require('../../../labscore/utils/embed')
|
||||
const { editOrReply } = require('../../../labscore/utils/message')
|
||||
const { STATICS } = require('../../../labscore/utils/statics')
|
||||
|
||||
const { lyrics } = require('../../../labscore/api');
|
||||
const { paginator } = require('../../../labscore/client');
|
||||
|
||||
const reactions = {
|
||||
previousPage: "⬅️",
|
||||
nextPage: "➡️"
|
||||
};
|
||||
|
||||
function createLyricsPage(context, search, fields){
|
||||
let em= createEmbed("default", context, {
|
||||
description: `**${search.body.song.title}**\n*Released ${search.body.song.release}*\n\n`,
|
||||
fields: fields,
|
||||
footer: {
|
||||
iconUrl: STATICS.genius,
|
||||
text: `Genius • ${context.application.name}`
|
||||
}
|
||||
})
|
||||
if(search.body.song.image) em.thumbnail = { url: search.body.song.image }
|
||||
return em;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'lyrics',
|
||||
label: 'query',
|
||||
metadata: {
|
||||
description: 'Searches for song lyrics on Genius.',
|
||||
examples: ['lyrics desert bloom man'],
|
||||
category: 'search',
|
||||
usage: 'lyrics <query>'
|
||||
},
|
||||
run: async (context, args) => {
|
||||
context.triggerTyping();
|
||||
if(!args.query) return editOrReply(context, {embeds:[createEmbed("warning", context, `Missing Parameter (query).`)]})
|
||||
try{
|
||||
let search = await lyrics(context, args.query)
|
||||
search = search.response
|
||||
|
||||
// Split lyrics into field-sizes chunks
|
||||
let chunks = search.body.lyrics.split(/\[(.*?)\]/) // should give us every chunk
|
||||
let fields = [];
|
||||
let cur = {
|
||||
inline: false
|
||||
};
|
||||
let i = 0;
|
||||
let l = 0;
|
||||
for(const c of chunks){
|
||||
if(c.length == 0) continue;
|
||||
if(i == 0){
|
||||
cur.name = `[${c}]`
|
||||
i += 1
|
||||
continue;
|
||||
}
|
||||
cur.value = c.substr(0,1024) + ``
|
||||
i = 0
|
||||
fields.push(cur)
|
||||
cur = {
|
||||
inline: false
|
||||
}
|
||||
}
|
||||
|
||||
if(fields.length > 3){
|
||||
let pages = []
|
||||
while(fields.length) {
|
||||
pages.push({embeds:[createLyricsPage(context, search, fields.splice(0,3))]})
|
||||
}
|
||||
const message = context.message
|
||||
|
||||
pages = formatPaginationEmbeds(pages)
|
||||
const paging = await paginator.createReactionPaginator({
|
||||
message,
|
||||
pages,
|
||||
reactions
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
return editOrReply(context, {embeds: [createLyricsPage(context, search, fields)]})
|
||||
|
||||
}catch(e){
|
||||
if(e.response?.body?.status){
|
||||
if(e.response.body.status == 2){
|
||||
return editOrReply(context, {embeds:[createEmbed("error", context, `Unable to perform lyrics search.`)]})
|
||||
}
|
||||
}
|
||||
console.log(e)
|
||||
return editOrReply(context, {embeds:[createEmbed("error", context, `Something went wrong.`)]})
|
||||
}
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue