Discord.js setGame() 不再工作

Discord.js setGame() not working anymore(Discord.js setGame() 不再工作)
本文介绍了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() 的内容和格式相同.例如.

.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' });

这里是一个链接如果您想将 'Watching' 更改为 'Playing' 之类的其他内容,请参阅文档.

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

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Discord.js Arguments With Spaces(Discord.js 带空格的参数)
DiscordJS fetching more then 100 messages(DiscordJS 获取超过 100 条消息)
my discord.js bot doesn#39;t reply to a user message even if there isn#39;t any error(即使没有任何错误,我的 discord.js 机器人也不会回复用户消息)
Make a bot wait for some time before continuing the code(在继续代码之前让机器人等待一段时间)
Invalid Form Body in Discord.js ban command(Discord.js 禁止命令中的无效表单正文)
Set Discord Bot Activity to the number of Online users. Discord.js(将 Discord Bot 活动设置为在线用户数.不和谐.js)