Discord.js setGame()不再工作了 [英] Discord.js setGame() not working anymore

查看:100
本文介绍了Discord.js setGame()不再工作了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Discord.JS编码了我的Discord机器人大约2个月了,我刚刚注意到我的机器人并没有说它正在播放我所说的内容。当我第一次编写机器人直到最近它工作得很好。现在我有3个不和谐的机器人没有显示他们的游戏。

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. When I first coded the bot up until recently it worked just fine. Now the 3 discord bots I have aren't showing their games.

这是我正在使用的代码:

This is the code I'm using:

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


推荐答案

.setGame ()现在已弃用,但你可以使用 .setPresence(),或者你可以使用 .setActivity() .setGame()的内容和格式相同。
Ex。

.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'.

这篇关于Discord.js setGame()不再工作了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆