admin管理员组文章数量:1026989
const { MessageEmbed } = require('discord.js');
module.exports = {
config: {
name: 'spotify',
category: "fun",
noalias: "No Aliases",
description: "shows stats of the person listening",
usage: "[no mention | mention (optional)]",
accessableby: 'everyone'
},
run: async (bot, message, args) => {
let user = message.mentions.users.first() || message.author;
if(user.presence.game !== null && user.presence.game.type === 2 && user.presence.game.name === 'Spotify' && user.presence.game.assets !== null) {
let trackIMG = `/${user.presence.game.assets.largeImage.slice(8)}`;
let trackURL = `/${user.presence.game.syncID}`;
let trackName = user.presence.game.details;
let trackAuthor = user.presence.game.state;
let trackAlbum = user.presence.game.assets.largeText;
const embed = new MessageEmbed()
.setAuthor('Spotify Track Info', '.png?v=1')
.setColor("GREEN")
.setThumbnail(trackIMG)
.addField('Song Name', trackName, true)
.addField('Album', trackAlbum, true)
.addField('Author', trackAuthor, false)
.addField('Listen to Track', `${trackURL}`, false)
.setFooter(message.member.displayName, message.author.displayAvatarURL())
.setTimestamp()
message.channel.send(embed);
} else {
message.channel.send('**This user isn\'t listening to Spotify!**');
}
}
}
in discord version 12.1.1 it gives me error of "(node:8560) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'type' of undefined" help me how to solve this
const { MessageEmbed } = require('discord.js');
module.exports = {
config: {
name: 'spotify',
category: "fun",
noalias: "No Aliases",
description: "shows stats of the person listening",
usage: "[no mention | mention (optional)]",
accessableby: 'everyone'
},
run: async (bot, message, args) => {
let user = message.mentions.users.first() || message.author;
if(user.presence.game !== null && user.presence.game.type === 2 && user.presence.game.name === 'Spotify' && user.presence.game.assets !== null) {
let trackIMG = `https://i.scdn.co/image/${user.presence.game.assets.largeImage.slice(8)}`;
let trackURL = `https://open.spotify./track/${user.presence.game.syncID}`;
let trackName = user.presence.game.details;
let trackAuthor = user.presence.game.state;
let trackAlbum = user.presence.game.assets.largeText;
const embed = new MessageEmbed()
.setAuthor('Spotify Track Info', 'https://cdn.discordapp./emojis/653135129870336031.png?v=1')
.setColor("GREEN")
.setThumbnail(trackIMG)
.addField('Song Name', trackName, true)
.addField('Album', trackAlbum, true)
.addField('Author', trackAuthor, false)
.addField('Listen to Track', `${trackURL}`, false)
.setFooter(message.member.displayName, message.author.displayAvatarURL())
.setTimestamp()
message.channel.send(embed);
} else {
message.channel.send('**This user isn\'t listening to Spotify!**');
}
}
}
in discord version 12.1.1 it gives me error of "(node:8560) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'type' of undefined" help me how to solve this
Share Improve this question edited Apr 2, 2020 at 11:15 Lauren Yim 14.2k2 gold badges37 silver badges66 bronze badges asked Apr 1, 2020 at 15:32 FirezFirez 931 gold badge3 silver badges8 bronze badges 1- changed the code hastebin./eqejuhiquc.js -- spotify updated code, but it shows that user is not listening on spotify, though i am. also no errors. – Firez Commented Apr 3, 2020 at 4:55
2 Answers
Reset to default 2in fact since discord.js v12 game has been removed from presence use:
user.presence.activities
well i have made a better mand which not only checks if the user is playing spotify or not but also games and whatever else the user is playing along with custom status go here to get it ---
https://github./FirezzzZ/1SHOT-Bot/tree/glitch
const { MessageEmbed } = require('discord.js');
module.exports = {
config: {
name: 'spotify',
category: "fun",
noalias: "No Aliases",
description: "shows stats of the person listening",
usage: "[no mention | mention (optional)]",
accessableby: 'everyone'
},
run: async (bot, message, args) => {
let user = message.mentions.users.first() || message.author;
if(user.presence.game !== null && user.presence.game.type === 2 && user.presence.game.name === 'Spotify' && user.presence.game.assets !== null) {
let trackIMG = `/${user.presence.game.assets.largeImage.slice(8)}`;
let trackURL = `/${user.presence.game.syncID}`;
let trackName = user.presence.game.details;
let trackAuthor = user.presence.game.state;
let trackAlbum = user.presence.game.assets.largeText;
const embed = new MessageEmbed()
.setAuthor('Spotify Track Info', '.png?v=1')
.setColor("GREEN")
.setThumbnail(trackIMG)
.addField('Song Name', trackName, true)
.addField('Album', trackAlbum, true)
.addField('Author', trackAuthor, false)
.addField('Listen to Track', `${trackURL}`, false)
.setFooter(message.member.displayName, message.author.displayAvatarURL())
.setTimestamp()
message.channel.send(embed);
} else {
message.channel.send('**This user isn\'t listening to Spotify!**');
}
}
}
in discord version 12.1.1 it gives me error of "(node:8560) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'type' of undefined" help me how to solve this
const { MessageEmbed } = require('discord.js');
module.exports = {
config: {
name: 'spotify',
category: "fun",
noalias: "No Aliases",
description: "shows stats of the person listening",
usage: "[no mention | mention (optional)]",
accessableby: 'everyone'
},
run: async (bot, message, args) => {
let user = message.mentions.users.first() || message.author;
if(user.presence.game !== null && user.presence.game.type === 2 && user.presence.game.name === 'Spotify' && user.presence.game.assets !== null) {
let trackIMG = `https://i.scdn.co/image/${user.presence.game.assets.largeImage.slice(8)}`;
let trackURL = `https://open.spotify./track/${user.presence.game.syncID}`;
let trackName = user.presence.game.details;
let trackAuthor = user.presence.game.state;
let trackAlbum = user.presence.game.assets.largeText;
const embed = new MessageEmbed()
.setAuthor('Spotify Track Info', 'https://cdn.discordapp./emojis/653135129870336031.png?v=1')
.setColor("GREEN")
.setThumbnail(trackIMG)
.addField('Song Name', trackName, true)
.addField('Album', trackAlbum, true)
.addField('Author', trackAuthor, false)
.addField('Listen to Track', `${trackURL}`, false)
.setFooter(message.member.displayName, message.author.displayAvatarURL())
.setTimestamp()
message.channel.send(embed);
} else {
message.channel.send('**This user isn\'t listening to Spotify!**');
}
}
}
in discord version 12.1.1 it gives me error of "(node:8560) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'type' of undefined" help me how to solve this
Share Improve this question edited Apr 2, 2020 at 11:15 Lauren Yim 14.2k2 gold badges37 silver badges66 bronze badges asked Apr 1, 2020 at 15:32 FirezFirez 931 gold badge3 silver badges8 bronze badges 1- changed the code hastebin./eqejuhiquc.js -- spotify updated code, but it shows that user is not listening on spotify, though i am. also no errors. – Firez Commented Apr 3, 2020 at 4:55
2 Answers
Reset to default 2in fact since discord.js v12 game has been removed from presence use:
user.presence.activities
well i have made a better mand which not only checks if the user is playing spotify or not but also games and whatever else the user is playing along with custom status go here to get it ---
https://github./FirezzzZ/1SHOT-Bot/tree/glitch
本文标签: javascriptSpotify command for discordjs v1211Stack Overflow
版权声明:本文标题:javascript - Spotify command for discord.js v12.1.1 - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745622392a2159654.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论