discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.47k stars 3.97k forks source link

[11.4.2] bug? or what #2849

Closed bit0r1n closed 6 years ago

bit0r1n commented 6 years ago

i made spotify command, he is working, but when in my status there is nothing, bot is crashing how to fix this? if at all possible

bot.on('message', message => { let msg = message.content.toUpperCase(); if(msg.startsWith(prefix + 'SPOTIFY')){ var user = message.mentions.users.first() || message.author; if(user.bot) return message.channel.send("bots cant listen music :cry:"); if(user.presence.game.type == 2 && user.presence.game.name == 'Spotify') { try { var trackImg = user.presence.game.assets.largeImageURL; var trackUrl = https://open.spotify.com/track/${user.presence.game.syncID}; var trackName = user.presence.game.details; var trackAlbum = user.presence.game.assets.largeText; var trackAuthor = user.presence.game.state; const embed = new Discord.RichEmbed() .setAuthor('Spotify info') .setColor(embedcolor) .setThumbnail(trackImg) .setDescription( \🎵` Track name : `${trackName}` `📀` Album : `${trackAlbum}` `🎤` Author(s) : `${trackAuthor}` `🕐` Start listen at: `${user.presence.game.timestamps.start.getHours()}:${user.presence.game.timestamps.start.getMinutes()}:${user.presence.game.timestamps.start.getSeconds()}` ) .addField('Listen this track :',${trackAuthor} — ${trackName} (Spotify link), false); return message.channel.send(embed); }catch(error){ return message.channel.send(`[Err ❌]`, ${user.username} listen local music); } }else{ message.channel.send(${user.username} dont listen music on Spotify`); } }

});

image

DevYukine commented 6 years ago

The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the Discord server instead of opening an issue – you will get redirected there anyway.