Reputation: 41
I want the bot to reply with "You can't warn the owner!", but I can't seem to get the right code. Here is a snippet of my code:
let id = '328248785933434881'
let ownerID = client.users.fetch(id);
if (message.mentions.has(ownerID))
return message.channel.reply(`<@${message.author.id}>, you can\'t warn the owner...`);
Upvotes: 0
Views: 247
Reputation: 41
Found the solution. Works the same as what I was asking for, except it only works for single / personal servers instead of global bots.
const ownerID = 'OWNERS ID'
if (message.mentions.has(ownerID)) return (message.channel.send(`You aren't allowed to warn <@${ownerID}>!`))
Upvotes: 0
Reputation: 1056
You can get the owner of a server by searching the guild by the ID, like this:
let guild = client.guilds.cache.get('GuildID');
console.log(guild.ownerID);
But if you want to skip extracting the ID from the mention and comparing it to ownerID
then you can compare users like this:
let guild = client.guilds.cache.get('GuildID');
if (message.mentions.has(guild.owner))
return message.channel.send(`<@${message.author.id}>, you can\'t warn the owner...`);
Upvotes: 1