【问题标题】:Spotify command for discord.js v12.1.1discord.js v12.1.1 的 Spotify 命令
【发布时间】:2020-07-13 10:09:15
【问题描述】:
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.com/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.com/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!**');
        }
    }
}

在不和谐版本 12.1.1 中,它给了我“(节点:8560)UnhandledPromiseRejectionWarning:TypeError:无法读取未定义的属性'type'”的错误帮助我如何解决这个问题

【问题讨论】:

  • 更改了代码hastebin.com/eqejuhiquc.js——spotify 更新了代码,但它表明用户没有在Spotify 上收听,尽管我是。也没有错误。

标签: javascript discord.js


【解决方案1】:

我做了一个更好的命令,它不仅可以检查用户是否正在玩 Spotify,还可以检查游戏以及用户正在玩的任何其他内容以及自定义状态到这里获取它 ---

https://github.com/FirezzzZ/1SHOT-Bot/tree/glitch

【讨论】:

    【解决方案2】:

    事实上,因为 discord.js v12 游戏已从状态使用中移除:

    user.presence.activities
    

    【讨论】:

    • 更改了代码 hastebin.com/eqejuhiquc.js -- spotify 更新了代码,但它表明用户没有在 Spotify 上收听,尽管我是。也没有错误。
    猜你喜欢
    • 2021-03-31
    • 2020-12-04
    • 2021-06-01
    • 2021-03-29
    • 2022-01-27
    • 2022-01-25
    • 2021-05-20
    • 2021-04-18
    • 2021-06-11
    相关资源
    最近更新 更多