The-SourceCode/Discord.js-Bot-Development

cannot find the property of name of undefined?

swayam-crypto opened this issue · 2 comments

cannot find the property of name of undefined?

var commando = require('discord.js-commando');
var Discord = require('discord.js');

class serverInfo extends commando.Command
{
constructor(client) {
super(client, {
name: 'server-info',
group: 'guild',
memberName: 'server-info',
description: 'Lists information about The Server.',
aliases: ['si', 'serveri', 'sinfo', 'server'],
})
}
async run(client, message, args) {
function checkDays(date) {
let now = new Date();
let diff = now.getTime() - date.getTime();
let days = Math.floor(diff / 86400000);
return days + (days == 1 ? " day" : " days") + " ago";
};
let verifLevels = ["None", "Low", "Medium", "(╯°□°)╯︵ ┻━┻", "┻━┻ミヽ(ಠ益ಠ)ノ彡┻━┻"];
let region = {
"brazil": ":flag_br: Brazil",
"eu-central": ":flag_eu: Central Europe",
"singapore": ":flag_sg: Singapore",
"us-central": ":flag_us: U.S. Central",
"sydney": ":flag_au: Sydney",
"us-east": ":flag_us: U.S. East",
"us-south": ":flag_us: U.S. South",
"us-west": ":flag_us: U.S. West",
"eu-west": ":flag_eu: Western Europe",
"vip-us-east": ":flag_us: VIP U.S. East",
"london": ":flag_gb: London",
"amsterdam": ":flag_nl: Amsterdam",
"hongkong": ":flag_hk: Hong Kong",
"russia": ":flag_ru: Russia",
"southafrica": ":flag_za: South Africa"
};
console.log(message)
const embed = new Discord.MessageEmbed()
.setAuthor(message.guild.name , message.guild.iconURL)
.addField("Name", message.guild.name , true)
.addField("ID", message.guild.id , true)
.addField("Owner", ${message.guild.owner.user.username}#${message.guild.owner.user.discriminator}, true)
.addField("Region", region[message.guild.region], true)
.addField("Total | Humans | Bots", ${message.guild.members.cache.size} | ${message.guild.members.cache.filter(member => !member.user.bot).size} | ${message.guild.members.cache.filter(member => member.user.bot).size}, true)
.addField("Verification Level", message.guild.verificationLevel, true)
.addField("Channels", message.guild.channels.cache.size, true)
.addField("Roles", message.guild.roles.cache.size, true)
.addField("Creation Date", ${message.channel.guild.createdAt.toUTCString().substr(0, 16)} (${checkDays(message.channel.guild.createdAt)}), true)
.setThumbnail(message.guild.iconURL())
message.channel.send({embed});
}
}

module.exports = serverInfo;

How I can fix this error