0

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.

Foccs
  • 3
  • 4

1 Answers1

0
fetchGuild

is not a function. Use

client.guilds.get(id)

or

message.guild

as you already have the guild attached to the message object

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

Community
  • 1
  • 1
Saddy
  • 1,363
  • 1
  • 8
  • 18