Trying to disable @everyone , @here and role pings in say command

I am trying to disable @everyone, @here and other role pings in my say command.

Basically when someone tries doing {prefix}say @everyone hi bot will reply everyone-ping hi and won’t ping everyone
(replacing @everyone with everyone-ping

Here’s my code

const response = args.slice(0).join(" ")
message.channel.send(response)

i tried something like

response.splice(’@everyone’, 1, ‘everyone-ping’)

but didn’t work

https://discord.js.org/#/docs/main/stable/class/Util?scrollTo=s-removeMentions

3 Likes

Hey @umutplus,

Before you send the message, you can look for the everyone ping and change it’s value using .indexOf.

let everyoneping = (args.indexOf("@everyone") > -1);

if (everyoneping === true) {
   let index = args.indexOf("@everyone");
   response[index] = "everyoneping";
}

Use this code before the response = args.slice(0).join(" ") line.

This code is untested, so I’m not sure this might work. However, let me know if it doesn’t work.

Hope this helps!

2 Likes

Simply just use this:

message.content = message.content.replace(/@(everyone)/gi, "everyone").replace(/@(here)/gi, "here");
2 Likes

You could also use the one built into discordjs

1 Like

Oh! Didn’t know Discord.js had that!

1 Like

I sent the link above, also removes role pings

2 Likes

The meta tags made it look like you just sent the docs and not a specific function
https://discord.js.org/#/docs/main/stable/class/Util?scrollTo=s-removeMentions
You can put <>s around a URL and it will just show as a URL, not a card, like above ^^^

3 Likes