【发布时间】:2020-04-13 21:53:44
【问题描述】:
所以我有这个命令来设置机器人的“播放”状态:
const commando = require('discord.js-commando');
const { RichEmbed } = require('discord.js');
class sets extends commando.Command {
constructor(client) {
super(client, {
name: 'setgame',
group: 'owner',
memberName: 'setgame',
description: 'Sets the Bots\' activity',
examples: ['Playing __on many servers!__'],
args: [
{
key: "game",
prompt: "What do you want to set my game as?",
type: "string"
}
]
});
}
async run(message, { game } ) {
if (message.author.id !== "442918106378010635"){
message.channel.send("That's for TheRSC only!");
}
else {
this.client.bot.setActivity(game)
const embed = new RichEmbed()
.setColor(0x00AE86)
.setDescription("Game set!");
message.channel.send({embed});;
}
}
}
module.exports = sets;;
我之前遇到过一些错误并设法修复它们,但这一个让我难过。无论我如何编码,我都会不断收到:TypeError: Cannot read property 'setActivity' of undefined
我已经尝试了一些事情,在运行中定义了 text,将 args.game 放入 .setActivity() 并且它不断地吐出那个错误。我尝试了拆分 args 方法,但这也不起作用。有任何想法吗? (附带说明一下,如果可能的话,我还想把它变成一个 .setPresence 命令。)
注意:我是编码的初学者,所以我可能会做一些普通编码员不会做的事情。
【问题讨论】:
标签: javascript node.js discord.js