admin管理员组文章数量:1307502
i get this error:
UnhandledPromiseRejectionWarning: TypeError: message.channel.fetchMessages is not a function
on this line
const fetched = await message.channel.fetchMessages({limit: deleteCount});
Anyone know how to fix that? i am not good with the new updates. hehe.
i get this error:
UnhandledPromiseRejectionWarning: TypeError: message.channel.fetchMessages is not a function
on this line
const fetched = await message.channel.fetchMessages({limit: deleteCount});
Anyone know how to fix that? i am not good with the new updates. hehe.
Share Improve this question asked Apr 17, 2020 at 19:52 CrackVibeCrackVibe 211 silver badge2 bronze badges 1-
If you are using discord.js (please add it in your question's tags, btw) there is no
fetchMessages
function. – Seblor Commented Apr 17, 2020 at 19:56
4 Answers
Reset to default 7What you are trying to state no longer is in the Discord v12 code. Or it's just redefined as this:
message.channel.messages.fetch
Without seeing the rest of your code it's a bit tricky to be 100% positive, but as the error message says, you're trying to call (Invoke) a nonexisting function fetchMessages
. Probably fetchMessages
is defined as a property in message.channel
and not as a function.
here is rest of the mand code
if(mand === "purge") {
const deleteCount = parseInt(args[0], 10);
if(!deleteCount || deleteCount < 2 || deleteCount > 100)
return message.reply("Please provide a number between 2 and 100 for the number of messages to delete");
const fetched = await message.channel.fetchMessages({limit: deleteCount});
message.channel.bulkDelete(fetched)
.catch(error => message.reply(`Couldn't delete messages because of: ${error}`));
}
Changing this:
const fetched = await message.channel.fetchMessages({limit: deleteCount});
to this:
const fetched = await message.channel.messages.fetch({limit: deleteCount});
Should do the trick!
本文标签:
版权声明:本文标题:javascript - UnhandledPromiseRejectionWarning: TypeError: message.channel.fetchMessages is not a function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741843610a2400652.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论