Skip to content

Commit

Permalink
Replace deprecated embed property.
Browse files Browse the repository at this point in the history
  • Loading branch information
retrixe committed Oct 16, 2021
1 parent 84e440a commit 5879290
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/commands/admin/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/'
Expand Down
4 changes: 2 additions & 2 deletions src/commands/admin/emoji.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}` }
}
}]
}
}
}
8 changes: 4 additions & 4 deletions src/commands/admin/warn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.**`
Expand Down Expand Up @@ -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',
Expand All @@ -108,7 +108,7 @@ export const handleWarnings: Command = {
**| ID:** ${warning._id} **| Date:** ${moment(warning.date).format(format)}`
}
})
}
}]
}
}
}
Expand Down
46 changes: 23 additions & 23 deletions src/commands/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand All @@ -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()}.` }
}
Expand Down Expand Up @@ -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}`
}
Expand All @@ -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 <robot, monster, head, cat, human> <text to robohash>', error: true }
Expand Down Expand Up @@ -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) {
Expand All @@ -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}` }
}
Expand Down Expand Up @@ -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}` }
Expand All @@ -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}` }
}
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 => ({
Expand All @@ -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 } }
Expand Down Expand Up @@ -426,15 +426,15 @@ 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',
fields: [{
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.
Expand Down Expand Up @@ -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}`,
Expand Down Expand Up @@ -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
}]
}
}]
}
}
}
Expand Down Expand Up @@ -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 } }
Expand Down
4 changes: 2 additions & 2 deletions src/commands/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <command>.' }
}
}]
})
return 'newbie, help has been direct messaged to you ✅'
} catch {
Expand Down
6 changes: 3 additions & 3 deletions src/commands/trivia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -71,7 +71,7 @@ export class TriviaSession {
inline: true
}))
}
return { embed }
return { embeds: [embed] }
}

async endGame (): Promise<void> {
Expand Down Expand Up @@ -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]
Expand Down
20 changes: 10 additions & 10 deletions src/commands/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -94,7 +94,7 @@ export const handleServerinfo: Command = {
},
{ name: 'Roles', inline: true, value: guild.roles.size.toString() }
]
}
}]
}
}
}
Expand Down Expand Up @@ -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)' : ''),
Expand Down Expand Up @@ -160,7 +160,7 @@ export const handleUserinfo: Command = {
{ name: 'Permissions', value: member ? 'Run `/perms <user>` to get their permissions!' : 'N/A' }
],
footer: { text: 'User ID: ' + user.id }
}
}]
}
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -238,7 +238,7 @@ export const handlePermissions: Command = {
: { name: '', value: '' }
].filter(e => !!e.value),
footer: { text: 'User ID: ' + user.id }
}
}]
}
}
}
Expand Down Expand Up @@ -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',
Expand All @@ -479,7 +479,7 @@ export const handleReminderlist: Command = {
**Channel:** <#${reminder.target}>
**Message:** ${reminder.message.substring(1, reminder.message.lastIndexOf('\n')).trim()}`
}))
}
}]
}
}
}
Expand All @@ -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
}
}]
}
}
}
Expand Down

0 comments on commit 5879290

Please sign in to comment.