Answer the question
In order to leave comments, you need to log in
How to fix this Discord.js error?
const Discord = require('discord.js');
const strftime = require('strftime');
module.exports = {
name: 'profile',
description: 'Get the profile of the tagged user, or your own profile.',
execute(message) {
const member = message.mentions.users.first(); // Тут ошибка
let argsUser
if (!member) argsUser = message.author
else argsUser = member.user
let statuses = {
online: 'Онлайн',
idle: 'Не активен',
dnd: 'Не беспокоить',
offline: 'Оффлайн'
}
let game
if(!argsUser.presence.game) game = `**${statuses[argsUser.presence.status]}**`
else if (argsUser.presence.game.type == 0) game = `Играет в **${argsUser.presence.game.name}**`
else if (argsUser.presence.game.type == 1) game = `Стримит [**${argsUser.presence.game.name}**](${argsUser.presence.game.url})`
else if (argsUser.presence.game.type == 2) game = `Слушает **${argsUser.presence.game.name}**`
else if (argsUser.presence.game.type == 3) game = `Смотрит **${argsUser.presence.game.name}**`
let day = 1000 * 60 * 60 * 24
let date1 = new Date(message.createdTimestamp)
let date2 = new Date(argsUser.createdTimestamp)
let date3 = new Date(message.guild.member(argsUser).joinedTimestamp)
let diff1 = Math.round(Math.abs((date1.getTime() - date2.getTime()) / day)) // С момента регистрации
let diff2 = Math.round(Math.abs((date1.getTime() - date3.getTime()) / day)) // С момента вступления на сервер
let pembed = new Discord.MessageEmbed()
.setTitle('Профиль участника ' + argsUser.username)
.addField('Статус:', game)
.addField('ID:', argsUser.id)
.addField('Дата регистрации:', `${strftime('%d.%m.%Y', new Date(argsUser.createdTimestamp))}\n(${diff1} дн. назад)`, true)
.addField('Дата вступления:', `${strftime('%d.%m.%Y', new Date(message.guild.member(argsUser).joinedTimestamp))}\n(${diff2} дн. назад)`, true)
.addField('Роли:', message.guild.member(argsUser).roles.cache.filter(r => r.id !== message.guild.id).map(r => r).join(", ") || 'Нет')
.setColor(message.guild.member(argsUser).displayHexColor)
.setTimestamp()
.setThumbnail(argsUser.avatarURL())
message.channel.send(pembed)
},
};
Answer the question
In order to leave comments, you need to log in
I can advise you to change it. It should work, because I myself often use something like this code. If my answer satisfied you, please mark it with a tick.
execute(message, member) {
let любое_другое_имя_переменной = message.guild.member(message.mentions.users.first());
//и дальше ваш код
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question