I'm trying to write an announce command which when used sends an announcement to the announcements channel, but only if you have a certain role, that works, but it shows an error in my console.
The error is TypeError: client.fetchGuild is not a function
if (await client.fetchGuild(message.guild.id).fetchMember(message.author.id).hasPermission("MENTION_EVERYONE") && message.content.startsWith(adminPrefix + 'announce')) {
const trueMessage = message.content.substr(10)
client.channels.get('545343689216491541').send('@everyone, ' + trueMessage)
}
How do I make it send no errors
P.s. I'm new to this, very new.
答案 0 :(得分:0)
fetchGuild
不是功能。使用
client.guilds.get(id)
或
message.guild
因为您已经将公会附加到消息对象上
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get
https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=guilds