Discord.js setGame() not working anymore

醉酒当歌 提交于 2019-12-01 21:02:55

.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();
client.user.setActivity('YouTube', { type: 'WATCHING' });

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

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

Pruina Tempestatis

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!