bot perms

anyone knows why is this not working? i don't have a handler, its on the start of the code right above the commands
if(!message.guild.me.permissions.has(PermissionsBitField.Flags.EmbedLinks)) return message.channel.send("reply")
if(!message.guild.me.permissions.has(PermissionsBitField.Flags.EmbedLinks)) return message.channel.send("reply")
i have this in client "PermissionsBitField" and other regular perms in commands work, for example
if (!message.member.permissions.has(PermissionsBitField.Flags.ManageMessages)) return message.channel.send('reply')
if (!message.member.permissions.has(PermissionsBitField.Flags.ManageMessages)) return message.channel.send('reply')
this works, and thats why i can't understand why the first line isn't working, they are in the same file and everything the exact error is TypeError: Cannot read properties of undefined (reading 'permissions')
8 Replies
d.js toolkit
d.js toolkit9mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
duck
duck9mo ago
that'd be because <Guild>.me was moved to <Guild>.members.me, therefore <Guild>.me is undefined if you haven't already, consider checking out the v14 update guide https://discordjs.guide/additional-info/changes-in-v14
Ferklen
Ferklen9mo ago
if(!message.guild.members.me.permissions.has(PermissionsBitField.Flags.EmbedLinks)) return message.channel.send("reply")
if(!message.guild.members.me.permissions.has(PermissionsBitField.Flags.EmbedLinks)) return message.channel.send("reply")
so i switched it to this, now there is not an error message but the bot continues working even if it doesn't have the perms, and i confirm it by trying to use an embed it just shows an error in the console, commands with no embed work and it doesn't send the reply it should send
duck
duck9mo ago
is it possible this would be due to permission overwrites? if you were looking to check their perms specifically for the given channel, you could use <GuildChannel>.permissionsFor() or <GuildMember>.permissionsIn()
d.js docs
d.js docs9mo ago
method GuildChannel#permissionsFor() Gets the overall set of permissions for a member or role in this channel, taking into account channel overwrites.
Ferklen
Ferklen9mo ago
like in general, to prevent the errors while sending embeds should i put like message.guild.members.me.message.channel.permissionsFor() ? or message.channel.members
duck
duck9mo ago
well <GuildMember>.message doesn't exist <Message>.channel.permissionsFor() exists not exactly sure what <Message>.channel.members has to do with this
Ferklen
Ferklen9mo ago
im trying to check if the bot has embed perms any1 knows how to do that???