From fae75db44a7c7b52f07a2ca598b6a7c65bf60383 Mon Sep 17 00:00:00 2001 From: Essem Date: Tue, 9 Nov 2021 22:09:10 -0600 Subject: [PATCH] Switched to content.embeds --- commands/fun/ancient.js | 4 +- commands/fun/bird.js | 4 +- commands/fun/cat.js | 5 +-- commands/fun/dog.js | 4 +- commands/fun/xkcd.js | 19 +++++----- commands/general/count.js | 20 +++++----- commands/general/help.js | 68 +++++++++++++++++----------------- commands/general/image.js | 24 ++++++------ commands/general/imagestats.js | 6 +-- commands/general/info.js | 40 ++++++++++---------- commands/general/serverinfo.js | 42 ++++++++++----------- commands/general/stats.js | 4 +- commands/general/sticker.js | 4 +- commands/general/userinfo.js | 34 ++++++++--------- commands/music/nowplaying.js | 30 +++++++-------- commands/music/queue.js | 30 +++++++-------- commands/tags/tags.js | 20 +++++----- events/messageCreate.js | 4 +- utils/soundplayer.js | 30 +++++++-------- 19 files changed, 195 insertions(+), 197 deletions(-) diff --git a/commands/fun/ancient.js b/commands/fun/ancient.js index 9b18efc..07796eb 100644 --- a/commands/fun/ancient.js +++ b/commands/fun/ancient.js @@ -12,12 +12,12 @@ class AncientCommand extends Command { const data = await fetch("https://projectlounge.pw/meme/", { redirect: "manual", signal: controller.signal }); clearTimeout(timeout); return { - embed: { + embeds: [{ color: 16711680, image: { url: data.headers.get("location") } - } + }] }; } catch (e) { if (e.name === "AbortError") { diff --git a/commands/fun/bird.js b/commands/fun/bird.js index ff5ab43..87d9f09 100644 --- a/commands/fun/bird.js +++ b/commands/fun/bird.js @@ -7,12 +7,12 @@ class BirdCommand extends Command { const imageData = await fetch("http://shibe.online/api/birds"); const json = await imageData.json(); return { - embed: { + embeds: [{ color: 16711680, image: { url: json[0] } - } + }] }; } diff --git a/commands/fun/cat.js b/commands/fun/cat.js index 57f5caa..a5e2837 100644 --- a/commands/fun/cat.js +++ b/commands/fun/cat.js @@ -12,13 +12,12 @@ class CatCommand extends Command { const data = await fetch("https://projectlounge.pw/cta/", { redirect: "manual", signal: controller.signal }); clearTimeout(timeout); return { - embed: { + embeds: [{ color: 16711680, - description: "Cat images are sourced from a subset of the [dm4catbot](https://twitter.com/dm4catbot) database.", image: { url: data.headers.get("location") } - } + }] }; } catch (e) { if (e.name === "AbortError") { diff --git a/commands/fun/dog.js b/commands/fun/dog.js index 0d5452d..3837c15 100644 --- a/commands/fun/dog.js +++ b/commands/fun/dog.js @@ -7,12 +7,12 @@ class DogCommand extends Command { const imageData = await fetch("https://dog.ceo/api/breeds/image/random"); const json = await imageData.json(); return { - embed: { + embeds: [{ color: 16711680, image: { url: json.message } - } + }] }; } diff --git a/commands/fun/xkcd.js b/commands/fun/xkcd.js index 8e320b0..c2332dc 100644 --- a/commands/fun/xkcd.js +++ b/commands/fun/xkcd.js @@ -7,18 +7,17 @@ class XKCDCommand extends Command { try { const request = await fetch(url); const json = await request.json(); - const embed = { - "embed": { - "title": json.safe_title, - "url": `https://xkcd.com/${json.num}`, - "color": 16711680, - "description": json.alt, - "image": { - "url": json.img + return { + embeds: [{ + title: json.safe_title, + url: `https://xkcd.com/${json.num}`, + color: 16711680, + description: json.alt, + image: { + url: json.img } - } + }] }; - return embed; } catch { return "I couldn't get that XKCD!"; } diff --git a/commands/general/count.js b/commands/general/count.js index 2945c10..d1137c7 100644 --- a/commands/general/count.js +++ b/commands/general/count.js @@ -25,18 +25,18 @@ class CountCommand extends Command { }); for (const [i, value] of groups.entries()) { embeds.push({ - "embed": { - "title": "Command Usage Counts", - "color": 16711680, - "footer": { - "text": `Page ${i + 1} of ${groups.length}` + embeds: [{ + title: "Command Usage Counts", + color: 16711680, + footer: { + text: `Page ${i + 1} of ${groups.length}` }, - "description": value.join("\n"), - "author": { - "name": this.message.author.username, - "icon_url": this.message.author.avatarURL + description: value.join("\n"), + author: { + name: this.message.author.username, + icon_url: this.message.author.avatarURL } - } + }] }); } return paginator(this.client, this.message, embeds); diff --git a/commands/general/help.js b/commands/general/help.js index 131ed49..93827bc 100644 --- a/commands/general/help.js +++ b/commands/general/help.js @@ -16,35 +16,35 @@ class HelpCommand extends Command { const info = collections.info.get(command); const counts = await database.getCounts(); const embed = { - "embed": { - "author": { - "name": "esmBot Help", - "icon_url": this.client.user.avatarURL + embeds: [{ + author: { + name: "esmBot Help", + icon_url: this.client.user.avatarURL }, - "title": `${this.message.channel.guild ? prefix : ""}${command}`, - "url": "https://projectlounge.pw/esmBot/help.html", - "description": command === "tags" ? "The main tags command. Check the help page for more info: https://projectlounge.pw/esmBot/help.html" : info.description, - "color": 16711680, - "fields": [{ - "name": "Aliases", - "value": info.aliases.length !== 0 ? info.aliases.join(", ") : "None" + title: `${this.message.channel.guild ? prefix : ""}${command}`, + url: "https://projectlounge.pw/esmBot/help.html", + description: command === "tags" ? "The main tags command. Check the help page for more info: https://projectlounge.pw/esmBot/help.html" : info.description, + color: 16711680, + fields: [{ + name: "Aliases", + value: info.aliases.length !== 0 ? info.aliases.join(", ") : "None" }, { - "name": "Times Used", - "value": counts[command], - "inline": true + name: "Times Used", + value: counts[command], + inline: true }, { - "name": "Parameters", - "value": command === "tags" ? "[name]" : (info.params ? (info.params.length !== 0 ? info.params.join(" ") : "None") : "None"), - "inline": true + name: "Parameters", + value: command === "tags" ? "[name]" : (info.params ? (info.params.length !== 0 ? info.params.join(" ") : "None") : "None"), + inline: true }] - } + }] }; if (info.flags.length !== 0) { const flagInfo = []; for (const flag of info.flags) { flagInfo.push(`\`--${flag.name}${flag.type ? `=[${flag.type}]` : ""}\` - ${flag.description}`); } - embed.embed.fields.push({ + embed.embeds[0].fields.push({ "name": "Flags", "value": flagInfo.join("\n") }); @@ -74,25 +74,25 @@ class HelpCommand extends Command { const embeds = []; for (const [i, value] of pages.entries()) { embeds.push({ - "embed": { - "author": { - "name": "esmBot Help", - "icon_url": this.client.user.avatarURL + embeds: [{ + author: { + name: "esmBot Help", + icon_url: this.client.user.avatarURL }, - "title": value.title, - "description": value.page.join("\n"), - "color": 16711680, - "footer": { - "text": `Page ${i + 1} of ${pages.length}` + title: value.title, + description: value.page.join("\n"), + color: 16711680, + footer: { + text: `Page ${i + 1} of ${pages.length}` }, - "fields": [{ - "name": "Prefix", - "value": this.message.channel.guild ? prefix : "N/A" + fields: [{ + name: "Prefix", + value: this.message.channel.guild ? prefix : "N/A" }, { - "name": "Tip", - "value": random(tips) + name: "Tip", + value: random(tips) }] - } + }] }); } return paginator(this.client, this.message, embeds); diff --git a/commands/general/image.js b/commands/general/image.js index 189e791..fe93b43 100644 --- a/commands/general/image.js +++ b/commands/general/image.js @@ -16,21 +16,21 @@ class ImageSearchCommand extends Command { const images = rawImages.results.filter((val) => !val.img_src.startsWith("data:")); for (const [i, value] of images.entries()) { embeds.push({ - "embed": { - "title": "Search Results", - "color": 16711680, - "footer": { - "text": `Page ${i + 1} of ${images.length}` + embeds: [{ + title: "Search Results", + color: 16711680, + footer: { + text: `Page ${i + 1} of ${images.length}` }, - "description": value.title, - "image": { - "url": encodeURI(value.img_src) + description: value.title, + image: { + url: encodeURI(value.img_src) }, - "author": { - "name": this.message.author.username, - "icon_url": this.message.author.avatarURL + author: { + name: this.message.author.username, + icon_url: this.message.author.avatarURL } - } + }] }); } return paginator(this.client, this.message, embeds); diff --git a/commands/general/imagestats.js b/commands/general/imagestats.js index ff99714..eace592 100644 --- a/commands/general/imagestats.js +++ b/commands/general/imagestats.js @@ -5,7 +5,7 @@ class ImageStatsCommand extends Command { await this.client.sendChannelTyping(this.message.channel.id); const servers = await this.ipc.command("image", { type: "stats" }, true); const embed = { - embed: { + embeds: [{ "author": { "name": "esmBot Image Statistics", "icon_url": this.client.user.avatarURL @@ -13,10 +13,10 @@ class ImageStatsCommand extends Command { "color": 16711680, "description": `The bot is currently connected to ${servers.length} image server(s).`, "fields": [] - } + }] }; for (let i = 0; i < servers.length; i++) { - embed.embed.fields.push({ + embed.embeds[0].fields.push({ name: `Server ${i + 1}`, value: `Running Jobs: ${servers[i].runningJobs}\nQueued: ${servers[i].queued}\nMax Jobs: ${servers[i].max}` }); diff --git a/commands/general/info.js b/commands/general/info.js index 12ebf75..655f457 100644 --- a/commands/general/info.js +++ b/commands/general/info.js @@ -10,39 +10,39 @@ class InfoCommand extends Command { const owner = await this.ipc.fetchUser(process.env.OWNER.split(",")[0]); const stats = await this.ipc.getStats(); return { - "embed": { - "color": 16711680, - "author": { - "name": "esmBot Info/Credits", - "icon_url": this.client.user.avatarURL + embeds: [{ + color: 16711680, + author: { + name: "esmBot Info/Credits", + icon_url: this.client.user.avatarURL }, - "description": `This instance is managed by **${owner.username}#${owner.discriminator}**.`, - "fields": [{ - "name": "ℹī¸ Version:", - "value": `v${version}${process.env.NODE_ENV === "development" ? `-dev (${(await exec("git rev-parse HEAD")).stdout.substring(0, 7)})` : ""}` + description: `This instance is managed by **${owner.username}#${owner.discriminator}**.`, + fields: [{ + name: "ℹī¸ Version:", + value: `v${version}${process.env.NODE_ENV === "development" ? `-dev (${(await exec("git rev-parse HEAD")).stdout.substring(0, 7)})` : ""}` }, { - "name": "📝 Credits:", - "value": "Bot by **[Essem](https://essem.space)** and **[various contributors](https://github.com/esmBot/esmBot/graphs/contributors)**\nIcon by **[MintBurrow](https://twitter.com/MintBurrow)**" + name: "📝 Credits:", + value: "Bot by **[Essem](https://essem.space)** and **[various contributors](https://github.com/esmBot/esmBot/graphs/contributors)**\nIcon by **[MintBurrow](https://twitter.com/MintBurrow)**" }, { - "name": "đŸ’Ŧ Total Servers:", - "value": stats && stats.guilds ? stats.guilds : `${this.client.guilds.size} (for this cluster only)` + name: "đŸ’Ŧ Total Servers:", + value: stats && stats.guilds ? stats.guilds : `${this.client.guilds.size} (for this cluster only)` }, { - "name": "✅ Official Server:", - "value": "[Click here!](https://projectlounge.pw/support)" + name: "✅ Official Server:", + value: "[Click here!](https://projectlounge.pw/support)" }, { - "name": "đŸ’ģ Source Code:", - "value": "[Click here!](https://github.com/esmBot/esmBot)" + name: "đŸ’ģ Source Code:", + value: "[Click here!](https://github.com/esmBot/esmBot)" }, { - "name": "đŸĻ Twitter:", - "value": "[Click here!](https://twitter.com/esmBot_)" + name: "đŸĻ Twitter:", + value: "[Click here!](https://twitter.com/esmBot_)" } ] - } + }] }; } diff --git a/commands/general/serverinfo.js b/commands/general/serverinfo.js index 8b07696..d3d8294 100644 --- a/commands/general/serverinfo.js +++ b/commands/general/serverinfo.js @@ -5,43 +5,43 @@ class ServerInfoCommand extends Command { if (!this.message.channel.guild) return "This command only works in servers!"; const owner = await this.message.channel.guild.members.get(this.message.channel.guild.ownerID); return { - "embed": { - "title": this.message.channel.guild.name, - "thumbnail": { - "url": this.message.channel.guild.iconURL + embeds: [{ + title: this.message.channel.guild.name, + thumbnail: { + url: this.message.channel.guild.iconURL }, - "color": 16711680, - "fields": [ + color: 16711680, + fields: [ { - "name": "đŸ”ĸ **ID:**", - "value": this.message.channel.guild.id + name: "đŸ”ĸ **ID:**", + value: this.message.channel.guild.id }, { - "name": "👤 **Owner:**", - "value": owner ? `${owner.user.username}#${owner.user.discriminator}` : this.message.channel.guild.ownerID + name: "👤 **Owner:**", + value: owner ? `${owner.user.username}#${owner.user.discriminator}` : this.message.channel.guild.ownerID }, { - "name": "đŸ—ē **Region:**", - "value": this.message.channel.guild.region + name: "đŸ—ē **Region:**", + value: this.message.channel.guild.region }, { - "name": "🗓 **Created on:**", - "value": `` + name: "🗓 **Created on:**", + value: `` }, { - "name": "đŸ‘Ĩ **Users:**", - "value": this.message.channel.guild.memberCount + name: "đŸ‘Ĩ **Users:**", + value: this.message.channel.guild.memberCount }, { - "name": "đŸ’Ŧ **Channels:**", - "value": this.message.channel.guild.channels.size + name: "đŸ’Ŧ **Channels:**", + value: this.message.channel.guild.channels.size }, { - "name": "😃 **Emojis:**", - "value": this.message.channel.guild.emojis.length + name: "😃 **Emojis:**", + value: this.message.channel.guild.emojis.length } ] - } + }] }; } diff --git a/commands/general/stats.js b/commands/general/stats.js index 82ebd55..afece29 100644 --- a/commands/general/stats.js +++ b/commands/general/stats.js @@ -14,7 +14,7 @@ class StatsCommand extends Command { const owner = await this.ipc.fetchUser(process.env.OWNER.split(",")[0]); const stats = await this.ipc.getStats(); return { - embed: { + embeds: [{ "author": { "name": "esmBot Statistics", "icon_url": this.client.user.avatarURL @@ -74,7 +74,7 @@ class StatsCommand extends Command { "inline": true } ] - } + }] }; } diff --git a/commands/general/sticker.js b/commands/general/sticker.js index bfb3266..8d26214 100644 --- a/commands/general/sticker.js +++ b/commands/general/sticker.js @@ -9,13 +9,13 @@ class StickerCommand extends Command { return `https://cdn.discordapp.com/stickers/${result.id}.png`; } else if (result.format_type === 2) { // APNG return { - embed: { + embeds: [{ color: 16711680, description: `[This sticker is an APNG; however, since Discord doesn't allow displaying APNGs outside of stickers, you'll have to save it or open it in your browser to view it.](https://cdn.discordapp.com/stickers/${result.id}.png)`, image: { url: `https://cdn.discordapp.com/stickers/${result.id}.png` } - } + }] }; } else if (result.format_type === 3) { // Lottie return `I can't display this sticker because it uses the Lottie animation format; however, I can give you the raw JSON link to it: https://cdn.discordapp.com/stickers/${result.id}.json`; diff --git a/commands/general/userinfo.js b/commands/general/userinfo.js index a8d87a3..36fb0a3 100644 --- a/commands/general/userinfo.js +++ b/commands/general/userinfo.js @@ -17,35 +17,35 @@ class UserInfoCommand extends Command { } const member = this.message.channel.guild ? this.message.channel.guild.members.get(user.id) : undefined; return { - "embed": { - "title": `${user.username}#${user.discriminator}`, - "thumbnail": { - "url": user.avatarURL + embeds: [{ + title: `${user.username}#${user.discriminator}`, + thumbnail: { + url: user.avatarURL }, - "color": 16711680, - "fields": [ + color: 16711680, + fields: [ { - "name": "đŸ”ĸ **ID:**", - "value": user.id + name: "đŸ”ĸ **ID:**", + value: user.id }, { - "name": "📛 **Nickname:**", - "value": member ? (member.nick ? member.nick : "None") : "N/A" + name: "📛 **Nickname:**", + value: member ? (member.nick ? member.nick : "None") : "N/A" }, { - "name": "🤖 **Bot:**", - "value": user.bot ? "Yes" : "No" + name: "🤖 **Bot:**", + value: user.bot ? "Yes" : "No" }, { - "name": "🗓ī¸ **Joined Discord on:**", - "value": `` + name: "🗓ī¸ **Joined Discord on:**", + value: `` }, { - "name": "đŸ’Ŧ **Joined this server on:**", - "value": member ? `` : "N/A" + name: "đŸ’Ŧ **Joined this server on:**", + value: member ? `` : "N/A" } ] - } + }] }; } diff --git a/commands/music/nowplaying.js b/commands/music/nowplaying.js index 62d6d4d..04d2948 100644 --- a/commands/music/nowplaying.js +++ b/commands/music/nowplaying.js @@ -12,29 +12,29 @@ class NowPlayingCommand extends MusicCommand { const track = await Rest.decode(player.node, player.track); const parts = Math.floor((player.state.position / track.length) * 10); return { - "embed": { - "color": 16711680, - "author": { - "name": "Now Playing", - "icon_url": this.client.user.avatarURL + embeds: [{ + color: 16711680, + author: { + name: "Now Playing", + icon_url: this.client.user.avatarURL }, - "fields": [{ - "name": "ℹī¸ Title:", - "value": track.title ? track.title : "Unknown" + fields: [{ + name: "ℹī¸ Title:", + value: track.title ? track.title : "Unknown" }, { - "name": "🎤 Artist:", - "value": track.author ? track.author : "Unknown" + name: "🎤 Artist:", + value: track.author ? track.author : "Unknown" }, { - "name": "đŸ’Ŧ Channel:", - "value": this.message.channel.guild.channels.get(this.message.member.voiceState.channelID).name + name: "đŸ’Ŧ Channel:", + value: this.message.channel.guild.channels.get(this.message.member.voiceState.channelID).name }, { - "name": `${"â–Ŧ".repeat(parts)}🔘${"â–Ŧ".repeat(10 - parts)}`, - "value": `${format(player.state.position)}/${track.isStream ? "∞" : format(track.length)}` + name: `${"â–Ŧ".repeat(parts)}🔘${"â–Ŧ".repeat(10 - parts)}`, + value: `${format(player.state.position)}/${track.isStream ? "∞" : format(track.length)}` }] - } + }] }; } diff --git a/commands/music/queue.js b/commands/music/queue.js index 44da305..a112e42 100644 --- a/commands/music/queue.js +++ b/commands/music/queue.js @@ -28,26 +28,26 @@ class QueueCommand extends MusicCommand { if (groups.length === 0) groups.push("del"); for (const [i, value] of groups.entries()) { embeds.push({ - "embed": { - "author": { - "name": "Queue", - "icon_url": this.client.user.avatarURL + embeds: [{ + author: { + name: "Queue", + icon_url: this.client.user.avatarURL }, - "color": 16711680, - "footer": { - "text": `Page ${i + 1} of ${groups.length}` + color: 16711680, + footer: { + text: `Page ${i + 1} of ${groups.length}` }, - "fields": [{ - "name": "đŸŽļ Now Playing", - "value": `${firstTrack.info.author !== "" ? firstTrack.info.author : "(blank)"} - **${firstTrack.info.title !== "" ? firstTrack.info.title : "(blank)"}** (${firstTrack.info.isStream ? "∞" : format(firstTrack.info.length)})` + fields: [{ + name: "đŸŽļ Now Playing", + value: `${firstTrack.info.author !== "" ? firstTrack.info.author : "(blank)"} - **${firstTrack.info.title !== "" ? firstTrack.info.title : "(blank)"}** (${firstTrack.info.isStream ? "∞" : format(firstTrack.info.length)})` }, { - "name": "🔁 Looping?", - "value": player.loop ? "Yes" : "No" + name: "🔁 Looping?", + value: player.loop ? "Yes" : "No" }, { - "name": "🗒ī¸ Queue", - "value": value !== "del" ? value.join("\n") : "There's nothing in the queue!" + name: "🗒ī¸ Queue", + value: value !== "del" ? value.join("\n") : "There's nothing in the queue!" }] - } + }] }); } if (embeds.length === 0) return "There's nothing in the queue!"; diff --git a/commands/tags/tags.js b/commands/tags/tags.js index caa1976..595479a 100644 --- a/commands/tags/tags.js +++ b/commands/tags/tags.js @@ -52,18 +52,18 @@ class TagsCommand extends Command { }); for (const [i, value] of groups.entries()) { embeds.push({ - "embed": { - "title": "Tag List", - "color": 16711680, - "footer": { - "text": `Page ${i + 1} of ${groups.length}` + embeds: [{ + title: "Tag List", + color: 16711680, + footer: { + text: `Page ${i + 1} of ${groups.length}` }, - "description": value.join("\n"), - "author": { - "name": this.message.author.username, - "icon_url": this.message.author.avatarURL + description: value.join("\n"), + author: { + name: this.message.author.username, + icon_url: this.message.author.avatarURL } - } + }] }); } if (embeds.length === 0) return "I couldn't find any tags!"; diff --git a/events/messageCreate.js b/events/messageCreate.js index a065de0..89b2f7b 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -130,7 +130,7 @@ export default async (client, cluster, worker, ipc, message) => { await promises.writeFile(`${process.env.TEMPDIR}/${filename}`, result.file); const imageURL = `${process.env.TMP_DOMAIN == "" ? "https://tmp.projectlounge.pw" : process.env.TMP_DOMAIN}/${filename}`; await client.createMessage(message.channel.id, Object.assign({ - embed: { + embeds: [{ color: 16711680, title: "Here's your image!", url: imageURL, @@ -140,7 +140,7 @@ export default async (client, cluster, worker, ipc, message) => { footer: { text: "The result image was more than 8MB in size, so it was uploaded to an external site instead." }, - } + }] }, reference)); } } else { diff --git a/utils/soundplayer.js b/utils/soundplayer.js index 8e11dab..7c2653e 100644 --- a/utils/soundplayer.js +++ b/utils/soundplayer.js @@ -102,29 +102,29 @@ export async function nextSong(client, message, connection, track, info, music, playingMessage = players.get(voiceChannel.guild.id).playMessage; } else { playingMessage = await client.createMessage(message.channel.id, !music ? "🔊 Playing sound..." : { - "embed": { - "color": 16711680, - "author": { - "name": "Now Playing", - "icon_url": client.user.avatarURL + embeds: [{ + color: 16711680, + author: { + name: "Now Playing", + icon_url: client.user.avatarURL }, - "fields": [{ - "name": "ℹī¸ Title:", - "value": info.title !== "" ? info.title : "(blank)" + fields: [{ + name: "ℹī¸ Title:", + value: info.title !== "" ? info.title : "(blank)" }, { - "name": "🎤 Artist:", - "value": info.author !== "" ? info.author : "(blank)" + name: "🎤 Artist:", + value: info.author !== "" ? info.author : "(blank)" }, { - "name": "đŸ’Ŧ Channel:", - "value": voiceChannel.name + name: "đŸ’Ŧ Channel:", + value: voiceChannel.name }, { - "name": `${"â–Ŧ".repeat(parts)}🔘${"â–Ŧ".repeat(10 - parts)}`, - "value": `0:00/${info.isStream ? "∞" : format(info.length)}` + name: `${"â–Ŧ".repeat(parts)}🔘${"â–Ŧ".repeat(10 - parts)}`, + value: `0:00/${info.isStream ? "∞" : format(info.length)}` }] - } + }] }); } connection.removeAllListeners("error");