Switched to content.embeds

This commit is contained in:
Essem 2021-11-09 22:09:10 -06:00
parent ef5023b639
commit fae75db44a
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
19 changed files with 195 additions and 197 deletions

View file

@ -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") {

View file

@ -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]
}
}
}]
};
}

View file

@ -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") {

View file

@ -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
}
}
}]
};
}

View file

@ -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!";
}

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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}`
});

View file

@ -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_)"
}
]
}
}]
};
}

View file

@ -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": `<t:${Math.floor(this.message.channel.guild.createdAt / 1000)}:F>`
name: "🗓 **Created on:**",
value: `<t:${Math.floor(this.message.channel.guild.createdAt / 1000)}:F>`
},
{
"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
}
]
}
}]
};
}

View file

@ -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
}
]
}
}]
};
}

View file

@ -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`;

View file

@ -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": `<t:${Math.floor(user.createdAt / 1000)}:F>`
name: "🗓️ **Joined Discord on:**",
value: `<t:${Math.floor(user.createdAt / 1000)}:F>`
},
{
"name": "💬 **Joined this server on:**",
"value": member ? `<t:${Math.floor(member.joinedAt / 1000)}:F>` : "N/A"
name: "💬 **Joined this server on:**",
value: member ? `<t:${Math.floor(member.joinedAt / 1000)}:F>` : "N/A"
}
]
}
}]
};
}

View file

@ -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)}`
}]
}]
}
};
}

View file

@ -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!";

View file

@ -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!";

View file

@ -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 {

View file

@ -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");