From 5879290a3384dc1a38bc7ef029ed1bb48bd6ad2f Mon Sep 17 00:00:00 2001 From: Ibrahim Ansari Date: Sun, 17 Oct 2021 01:40:49 +0530 Subject: [PATCH] Replace deprecated embed property. --- src/commands/admin/channels.ts | 2 +- src/commands/admin/emoji.ts | 4 +-- src/commands/admin/warn.ts | 8 +++--- src/commands/api.ts | 46 +++++++++++++++++----------------- src/commands/help.ts | 4 +-- src/commands/trivia.ts | 6 ++--- src/commands/utilities.ts | 20 +++++++-------- 7 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/commands/admin/channels.ts b/src/commands/admin/channels.ts index 0e239d0..29751b8 100644 --- a/src/commands/admin/channels.ts +++ b/src/commands/admin/channels.ts @@ -96,7 +96,7 @@ export const handleEditchannel: Command = { if (failedOps.length > 0) { return { content: 'Some operations failed to execute..', - embed: { color: 0x696969, fields: failedOps } + embeds: [{ color: 0x696969, fields: failedOps }] } } return '✅ All operations executed successfully \\o/' diff --git a/src/commands/admin/emoji.ts b/src/commands/admin/emoji.ts index 4e55989..dd76b72 100644 --- a/src/commands/admin/emoji.ts +++ b/src/commands/admin/emoji.ts @@ -154,12 +154,12 @@ export const handleEmojiimage: Command = { // Return emoji. return { content: '<:tom:402567029963489281> **| Emoji image:**', - embed: { + embeds: [{ color: 0x696969, author: { name: found ? found.name : args[0].split(':')[1] }, description: `**[Link](https://cdn.discordapp.com/emojis/${emoji}.${ext})**`, image: { url: `https://cdn.discordapp.com/emojis/${emoji}.${ext}` } - } + }] } } } diff --git a/src/commands/admin/warn.ts b/src/commands/admin/warn.ts index 337187e..c78a660 100644 --- a/src/commands/admin/warn.ts +++ b/src/commands/admin/warn.ts @@ -44,14 +44,14 @@ export const handleWarn: Command = { if (message.member.guild.id === '402423671551164416') { client.createMessage('402435742925848578', { content: `**${user.username}#${user.discriminator}** has been warned:`, - embed: { + embeds: [{ color: 0x00AE86, // type: 'rich', title: 'Information', description: ` *| Moderator:** ${message.author.username}#${message.author.discriminator} **| Reason:** ${args.join(' ')} *| Date:** ${moment(new Date().toUTCString()).format('dddd, MMMM Do YYYY, h:mm:ss A')}` - } + }] }).catch(() => {}) // Ignore error. } return `**${user.username}#${user.discriminator}** has been warned. **lol.**` @@ -93,7 +93,7 @@ export const handleWarnings: Command = { const format = 'dddd, MMMM Do YYYY, h:mm:ss A' // Date format. return { content: `🛃 **Warnings for ${user.username}#${user.discriminator}:**`, - embed: { + embeds: [{ color: 0x00AE86, type: 'rich', title: 'Warnings', @@ -108,7 +108,7 @@ export const handleWarnings: Command = { **| ID:** ${warning._id} **| Date:** ${moment(warning.date).format(format)}` } }) - } + }] } } } diff --git a/src/commands/api.ts b/src/commands/api.ts index 5d6d183..3fe6b46 100644 --- a/src/commands/api.ts +++ b/src/commands/api.ts @@ -75,7 +75,7 @@ export const handleOcr: Command = { ? `🤔 **Text recognition result uploaded to paste.gg${!useHastebin ? ' due to length' : ''}:** https://paste.gg/p/anonymous/${hastebin} (use this key to delete: \`${deletionKey}\`)` : `🤔 **Text recognition result:**\n${text}`, - embed: { + embeds: [{ color: 0x666666, author: { name: `${message.author.username}#${message.author.discriminator}'s Image`, @@ -88,7 +88,7 @@ https://paste.gg/p/anonymous/${hastebin} (use this key to delete: \`${deletionKe 'favicons/onecloud/favicon.ico' }, timestamp: new Date(message.timestamp).toISOString() - } + }] } } catch (e) { return `Invalid image URL, you ${getInsult()}.` } } @@ -156,7 +156,7 @@ export const handleCat: Command = { // Fetch a cat and process it (this sounds funny to me idk why) const { file } = await (await fetch('http://aws.random.cat/meow')).json() // Send it. - return { embed: { image: { url: file }, color: 0x123456 }, content: '🐱' } + return { embeds: [{ image: { url: file }, color: 0x123456 }], content: '🐱' } } catch (e) { return `Something went wrong 👾 Error: ${e}` } @@ -180,23 +180,23 @@ export const handleRobohash: Command = { const color = 0xcf1c1c if (target === 'robot') { return { - embed: { image: { url: `https://robohash.org/${text}.png` }, color }, content: '🤖' + embeds: [{ image: { url: `https://robohash.org/${text}.png` }, color }], content: '🤖' } } else if (target === 'monster') { return { - embed: { image: { url: `https://robohash.org/${text}.png?set=set2` }, color }, content: '👾' + embeds: [{ image: { url: `https://robohash.org/${text}.png?set=set2` }, color }], content: '👾' } } else if (target === 'head') { return { - embed: { image: { url: `https://robohash.org/${text}.png?set=set3` }, color } + embeds: [{ image: { url: `https://robohash.org/${text}.png?set=set3` }, color }] } } else if (target === 'cat') { return { - embed: { image: { url: `https://robohash.org/${text}.png?set=set4` }, color } + embeds: [{ image: { url: `https://robohash.org/${text}.png?set=set4` }, color }] } } else if (target === 'human') { return { - embed: { image: { url: `https://robohash.org/${text}.png?set=set5` }, color }, content: '🤔' + embeds: [{ image: { url: `https://robohash.org/${text}.png?set=set5` }, color }], content: '🤔' } } else { return { content: 'Correct usage: /robohash ', error: true } @@ -239,7 +239,7 @@ export const handleApod: Command = { ? `**${title}**\n${explanation}\n${url.split('embed/').join('watch?v=')}` : { content: `**${title}**\n${explanation}`, - embed: { image: { url }, color: 0x2361BE } + embeds: [{ image: { url }, color: 0x2361BE }] } } catch (err) { return `Something went wrong 👾 Error: ${err}` } } else if (args.length > 0) { @@ -254,7 +254,7 @@ export const handleApod: Command = { ? `**${title}**\n${explanation}\n${url.split('embed/').join('watch?v=')}` : { content: `**${title}**\n${explanation}`, - embed: { image: { url: hdurl }, color: 0x2361BE } + embeds: [{ image: { url: hdurl }, color: 0x2361BE }] } } catch (err) { return `Something went wrong 👾 Error: ${err}` } } @@ -294,7 +294,7 @@ export const handleDog: Command = { } if (!message || message.includes('Breed not found')) return { content: 'This breed/sub-breed does not exist!', error: true } return { - embed: { image: { url: message }, color: 0x654321 }, + embeds: [{ image: { url: message }, color: 0x654321 }], content: `🐕 ${args[0]} ${args[1]}` } } catch (err) { return `Something went wrong 👾 Error: ${err}` } @@ -305,13 +305,13 @@ export const handleDog: Command = { `http://dog.ceo/api/breed/${args[0].toLowerCase()}/images/random` )).json() if (!message || message.includes('Breed not found')) return 'This breed does not exist!' - return { embed: { image: { url: message }, color: 0x654321 }, content: '🐕 ' + args[0] } + return { embeds: [{ image: { url: message }, color: 0x654321 }], content: '🐕 ' + args[0] } } catch (err) { return `Something went wrong 👾 Error: ${err}` } } // Fetch a random picture. try { const { message } = await (await fetch('http://dog.ceo/api/breeds/image/random')).json() - return { embed: { image: { url: message }, color: 0x654321 }, content: '🐕' } + return { embeds: [{ image: { url: message }, color: 0x654321 }], content: '🐕' } } catch (err) { return `Something went wrong 👾 Error: ${err}` } } } @@ -342,12 +342,12 @@ export const handleUrban: Command = { } return { content: `**🍸 Definition of ${args.join(' ')}:**`, - embed: { + embeds: [{ color: 0x555555, description: response, footer: { text: 'Do not trust Urban Dictionary.' }, title: args.join(' ') - } + }] } // Else, there will be an exception thrown. } catch (err) { @@ -384,7 +384,7 @@ export const handleNamemc: Command = { )).json() return { content: `**Minecraft history and skin for ${name}:**`, - embed: { + embeds: [{ color: 0x00AE86, title: 'Skin and Name History', fields: [...names.map(object => ({ @@ -396,7 +396,7 @@ export const handleNamemc: Command = { description: '**Name History**\n', image: { url: `https://mc-heads.net/body/${id}`, height: 216, width: 90 }, footer: { text: 'Skin is recovered through https://mc-heads.net' } - } + }] } } catch (err) { return `Something went wrong 👾 Error: ${err}` } } catch (e) { return { content: 'Enter a valid Minecraft username (account must be premium)', error: true } } @@ -426,7 +426,7 @@ export const handleCurrency: Command = { if (args.length === 1 && args[0].toLowerCase() === 'list') { return { content: '**List of symbols:**', - embed: { + embeds: [{ description: Object.keys(currency.rates).toString().split(',').join(', '), color: 0x666666, title: '💲 Currency symbols', @@ -434,7 +434,7 @@ export const handleCurrency: Command = { name: 'Tip', value: 'Symbols are usually (but NOT ALWAYS) the country 2 \ letter code + the first letter of the currency name.' }] - } + }] } } // Calculate the currencies to conver from and to, as well as the amount. @@ -505,7 +505,7 @@ export const handleWeather: Command = { // We generate the entire embed. return { content: `**🌇🌃🌁🌆 The weather for ${args.join(', ')}:**`, - embed: { + embeds: [{ title: 'Weather at ' + args.join(', '), color: 0x6D6BEA, description: `**Description:** ${weather.weather[0].main} - ${weather.weather[0].description}`, @@ -548,7 +548,7 @@ ${weather.main.temp}${temp}/${weather.main.temp_max}${temp}/${weather.main.temp_ value: weather.snow ? `${weather.snow['3h']}mm` : 'N/A', inline: true }] - } + }] } } } @@ -630,13 +630,13 @@ export const handleDefine: Command = { } return { content: `📕 **|** Definition of **${args.join(' ')}**:`, - embed: { + embeds: [{ color: 0x7289DA, type: 'rich', title: results[0].word, footer: { text: 'Powered by Oxford Dictionary \\o/' }, fields - } + }] } } catch (err) { return `Something went wrong 👾 Error: ${err}` } } catch (e) { return { content: 'Did you enter a valid word? 👾', error: true } } diff --git a/src/commands/help.ts b/src/commands/help.ts index ced0bb8..e2719f2 100644 --- a/src/commands/help.ts +++ b/src/commands/help.ts @@ -152,13 +152,13 @@ export const handleHelp: IveBotCommand = { await channel.createMessage({ content: `**IveBot's dashboard**: ${rootURL || 'https://ivebot.now.sh'}/ (Manage Server required to manage a server)`, - embed: { + embeds: [{ color: 0x00AE86, // type: 'rich', title: 'Help', ...generalHelp, footer: { text: 'For help on a specific command or aliases, run /help .' } - } + }] }) return 'newbie, help has been direct messaged to you ✅' } catch { diff --git a/src/commands/trivia.ts b/src/commands/trivia.ts index 3eb6783..b7cb59d 100644 --- a/src/commands/trivia.ts +++ b/src/commands/trivia.ts @@ -38,7 +38,7 @@ export class TriviaSession { this.client = client } - getScores (addMedals = false): { embed: EmbedOptions } { + getScores (addMedals = false): { embeds: EmbedOptions[] } { const currentScores = Object.entries(this.scores).sort(([, a], [, b]) => b - a) const medals: { [id: string]: string } = {} if (addMedals) { @@ -71,7 +71,7 @@ export class TriviaSession { inline: true })) } - return { embed } + return { embeds: [embed] } } async endGame (): Promise { @@ -235,7 +235,7 @@ export const handleTrivia: Command = { : 0 return { content: '❔ **Available trivia topics:**', - embed: { color, description: lists.map(name => `**${name.replace('.txt', '')}**`).join(', ') } + embeds: [{ color, description: lists.map(name => `**${name.replace('.txt', '')}**`).join(', ') }] } } else if (args.length === 1 && (args[0] === 'stop' || args[0] === 'end')) { const session = tempDB.trivia[message.channel.id] diff --git a/src/commands/utilities.ts b/src/commands/utilities.ts index 90a1331..7242944 100644 --- a/src/commands/utilities.ts +++ b/src/commands/utilities.ts @@ -50,7 +50,7 @@ export const handleServerinfo: Command = { // Display information. return { content: `⌨ **Server info on ${guild.name}:**`, - embed: { + embeds: [{ author: { name: guild.name, icon_url: guild.iconURL }, thumbnail: { url: guild.iconURL }, color: Math.floor(Math.random() * 1000000 - 1), @@ -94,7 +94,7 @@ export const handleServerinfo: Command = { }, { name: 'Roles', inline: true, value: guild.roles.size.toString() } ] - } + }] } } } @@ -127,7 +127,7 @@ export const handleUserinfo: Command = { : 0 return { content: `👥 **Userinfo on ${user.username}:**`, - embed: { + embeds: [{ author: { name: 'User info', icon_url: user.avatarURL }, title: `${user.username}#${user.discriminator}` + (user.bot ? ' (Bot account)' : ''), description: user.mention + (member && member.pending ? ' (pending guild screening)' : ''), @@ -160,7 +160,7 @@ export const handleUserinfo: Command = { { name: 'Permissions', value: member ? 'Run `/perms ` to get their permissions!' : 'N/A' } ], footer: { text: 'User ID: ' + user.id } - } + }] } } } @@ -199,7 +199,7 @@ export const handlePermissions: Command = { const channelPerm = (message.channel as GuildTextableChannel).permissionsOf(user.id) return { content: `✅ **Permissions of ${user.username}:**`, - embed: { + embeds: [{ author: { name: `${user.username}#${user.discriminator}'s permissions`, icon_url: user.avatarURL @@ -238,7 +238,7 @@ export const handlePermissions: Command = { : { name: '', value: '' } ].filter(e => !!e.value), footer: { text: 'User ID: ' + user.id } - } + }] } } } @@ -468,7 +468,7 @@ export const handleReminderlist: Command = { const format = 'dddd, MMMM Do YYYY, h:mm:ss A' // Date format. return { content: `⏰ **Reminders for ${user.username}#${user.discriminator}:**`, - embed: { + embeds: [{ color: 0x00AE86, type: 'rich', title: 'Reminders', @@ -479,7 +479,7 @@ export const handleReminderlist: Command = { **Channel:** <#${reminder.target}> **Message:** ${reminder.message.substring(1, reminder.message.lastIndexOf('\n')).trim()}` })) - } + }] } } } @@ -501,14 +501,14 @@ export const handleAvatar: Command = { const format = user.avatar && user.avatar.startsWith('a_') ? 'gif' : 'png' return { content: '**Avatar:**', - embed: { + embeds: [{ author: { name: `${user.username}#${user.discriminator}`, icon_url: user.avatarURL }, image: { url: user.dynamicAvatarURL(format, 2048) }, description: `**[Link](${user.dynamicAvatarURL(format, 2048)})**`, color: member.roles.map(i => member.guild.roles.get(i)).sort( (a, b) => a.position > b.position ? -1 : 1 ).shift().color - } + }] } } }