就像标题所说的那样,我想制作一个错误报告命令,它将向我发送报告。 但是出于某种原因,我一直得到这个:
UnhandledPromiseRejectionWarning: TypeError: client.fetchUser is not a function
这是我的代码:
var lockedList = []; //replace the userID stuff here with the ID's of the users you want to blacklist
const pfix = "h."
const arg = message.content.slice(pfix.length).split(/ +/);
const commnd = arg.shift().toLowerCase();
const person = message.author.username;
const userID = message.author.id;
if (commnd === 'bugreport') {
if (userID == lockedList) {
message.channel.send('***You have abused and f##ked this feature before so you're in our blacklist***')
} else {
let bug = arg.slice(0).join(' ');
if (!bug) {
message.channel.send('Huh?! What and Where's the f##king bug?!')
} else {
client.fetchUser(myID).then((user) => {
user.send(`${person} of ${message.guild.name} (Guild ID: ${message.guild.id}, User ID: ${userID}) reported the bug: ${bug}`);
});
message.reply('**Your bug was reported. If you abuse and f##k this feature, you'll be blacklisted and stopped from using this command.**');
};
};
};
旁注:
此代码位于
client.on('message', async message => {
我有一些代码是从这个代码中复制的,反馈和建议命令。只是这样说,因为它可能与问题有关。
由于不和谐.js v12 删除了fetchUser()
方法。
您应该改用client.users.fetch()
client.users.fetch(myID).then((user) => {
user.send(`${person} of ${message.guild.name} (Guild ID: ${message.guild.id}, User ID: ${userID}) reported the bug: ${bug}`);
})