Browse Source

Fix non-string message types

Discord.js's update led to MessageEmbed's classifying non-string fields
(e.g. booleans) as empty, which is unallowed and would cause errors.
master
Abheek Dhawan 3 years ago
parent
commit
b524a5c1ca
  1. 8
      bot.js
  2. 4
      package.json

8
bot.js

@ -615,7 +615,7 @@ async function roleInfo(message) {
.setTitle(`Role \`${role.name}\` Info`) .setTitle(`Role \`${role.name}\` Info`)
.setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true, size: 1024 })) .setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true, size: 1024 }))
.addField("Permissions", role.permissions.toArray().map(p => `\`${p}\``.toLowerCase()).join(' • ')) .addField("Permissions", role.permissions.toArray().map(p => `\`${p}\``.toLowerCase()).join(' • '))
.addField("Mentionable", role.mentionable) .addField("Mentionable", `${role.mentionable}`)
.setFooter("Role ID: " + role.id) .setFooter("Role ID: " + role.id)
.setThumbnail(message.author.displayAvatarURL({ dynamic: true, size: 1024 })) .setThumbnail(message.author.displayAvatarURL({ dynamic: true, size: 1024 }))
.setTimestamp() .setTimestamp()
@ -1098,7 +1098,7 @@ client.on('messageDeleteBulk', messages => {
const messagesChannel = messages.array()[0].channel; const messagesChannel = messages.array()[0].channel;
const bulkDeleteEmbed = new Discord.MessageEmbed() const bulkDeleteEmbed = new Discord.MessageEmbed()
.setTitle(`${numMessages} Messages Bulk Deleted`) .setTitle(`${numMessages} Messages Bulk Deleted`)
.addField(`Channel`, messagesChannel) .addField(`Channel`, `<#${messagesChannel.id}>`)
.setFooter("Channel ID: " + messagesChannel.id) .setFooter("Channel ID: " + messagesChannel.id)
.setTimestamp() .setTimestamp()
.setColor('e7778b'); .setColor('e7778b');
@ -1166,7 +1166,7 @@ client.on('channelCreate', channel => {
} }
const channelCreateEmbed = new Discord.MessageEmbed() const channelCreateEmbed = new Discord.MessageEmbed()
.setTitle("Channel Created") .setTitle("Channel Created")
.addField("Name", channel) .addField("Name", `<#${channel.id}>`)
.addField("Type", channelType) .addField("Type", channelType)
.addField("Category", channelCategory) .addField("Category", channelCategory)
.setFooter("ID: " + channelID) .setFooter("ID: " + channelID)
@ -1432,7 +1432,7 @@ client.on('roleCreate', role => {
.setTitle("Role Added") .setTitle("Role Added")
.addField("Name", role.name) .addField("Name", role.name)
.addField("Permissions", role.permissions.toArray().map(p => `\`${p}\``.toLowerCase()).join(' • ')) .addField("Permissions", role.permissions.toArray().map(p => `\`${p}\``.toLowerCase()).join(' • '))
.addField("Mentionable", role.mentionable) .addField("Mentionable", `${role.mentionable}`)
.setFooter("Role ID: " + role.id) .setFooter("Role ID: " + role.id)
.setTimestamp() .setTimestamp()
.setColor('00aaff'); .setColor('00aaff');

4
package.json

@ -4,9 +4,9 @@
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"prod": "node index.js", "prod": "pm2 start index.js",
"test": "node index.js", "test": "node index.js",
"dev": "nodemon index.js" "dev": "index.js"
}, },
"author": "Abheek", "author": "Abheek",
"license": "Apache-2.0", "license": "Apache-2.0",

Loading…
Cancel
Save