問題描述
我已經使用 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() 不再工作的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!