Discord.js setGame() not working anymore

后端 未结 4 1525
-上瘾入骨i
-上瘾入骨i 2021-01-19 23:20

I have been coding my Discord bot using Discord.JS for about 2 months now and I\'ve just recently noticed that my bot isn\'t saying that it\'s playing what I\'m telling it.

相关标签:
4条回答
  • 2021-01-19 23:35

    setGame() is now deprecated, and discord.js asks you to use setActivity().

    const Discord = require("discord.js");
    const bot = new Discord.Client();
    bot.on("ready", () => {
      console.log("Ready");
      bot.user.setActivity("Type !help");
    })
    

    Hope this helped.

    0 讨论(0)
  • 2021-01-19 23:39

    .setGame() is deprecated now but you could use .setPresence() or you could use the .setActivity() which is the same thing and format as the .setGame(). Ex.

    const Discord = require('discord.js');
    const bot = new Discord.Client();
    bot.user.setActivity('YouTube', { type: 'WATCHING' });
    

    Here is a link to the documentation in case you wanted to change 'Watching' to something else like 'Playing'.

    0 讨论(0)
  • 2021-01-19 23:44

    Here's a short example of using the .setPresence that LW001 linked to:

    var Discord = require('discord.js');
    var bot = new Discord.Client();
    
    bot.on('ready', () => {
        bot.user.setStatus('available') // Can be 'available', 'idle', 'dnd', or 'invisible'
        bot.user.setPresence({
            game: {
                name: 'Type !help',
                type: 0
            }
        });
    });
    

    https://discord.js.org/#/docs/main/stable/class/ClientUser?scrollTo=setGame

    0 讨论(0)
  • 2021-01-19 23:53

    The setGame() Method has stopped working, here's what you can do:

    • update to latest 11.1-dev or
    • use .setPresence({ game: { name: 'nameGoesHere', type: 0 } }); as a workaround instead

    Source: https://github.com/hydrabolt/discord.js/issues/1807#issuecomment-323578919

    0 讨论(0)
提交回复
热议问题