Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

DiscordAPIError: Unknown Message

Writer Matthew Harrington

I have made a freeze command using discord.js and commando, that gives the user a role, and keeps them from talking and chatting. It seems that every time I run it though, it tosses an error:

(node:7352) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Message

I haven't been able to find what it is, but maybe i'm just a nub.

Code:

async run(message, { user }) { message.delete() const member = message.guild.member(user); if (!message.member.hasPermission("MUTE_MEMBERS")) return message.say("Sorry, but you do not have the Mute Members Permission! If you beleive this is a error, contact an owner."); if (!user) return message.say(`Cannot find user!`) if (member.hasPermission("MUTE_MEMBERS")) return message.say("The user you are trying to freeze is either the same, or higher role than you."); let muterole = message.guild.roles.find(`name`, "Frozen"); if (member.roles.has(muterole)) return message.say(`${user.username} is already frozen!`); if (!muterole) { try { muterole = await message.guild.createRole({ name: "Frozen", color: "#000000", permissions: [] }) message.guild.channels.forEach(async(channel, id) => { await channel.overwritePermissions(muterole, { SEND_MESSAGES: false, ADD_REACTIONS: false, SPEAK: false }); }); } catch (e) { console.log(e.stack); } await (member.addRole(muterole.id)) message.say(`**${user.username} has been frozen! To unfreeze them, use the unfreeze command!**`) message.delete(5000) }
}

Any help would be appreciated! Thanks.

1

1 Answer

I think that's caused by the fact that you're deleting the message with message.delete() in the first lines, but at the end you do that again with message.delete(5000). The rest of the code runs fine because even if you deleted the message it's still saved in your message variable, but when you try to delete that again the API isn't able to find it. Try removing one of the message.delete()

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy