admin管理员组

文章数量:1392068

I am having trouble figuring out how to send a message silently using discord.js as all my previous attempts have failed and I couldn't find any documentation online about sending silent messages with bots.

I have tried

var msg = await channel.send("@silent message");

which results in this along with

var msg = await channel.send({
  content: "message",
  silent: true,
  is_silent: true,
  ephemeral: true
});

which results in this

I even looked through the MessageFlagsBitField enum and I did not find anything indicating a silent message.

I am having trouble figuring out how to send a message silently using discord.js as all my previous attempts have failed and I couldn't find any documentation online about sending silent messages with bots.

I have tried

var msg = await channel.send("@silent message");

which results in this along with

var msg = await channel.send({
  content: "message",
  silent: true,
  is_silent: true,
  ephemeral: true
});

which results in this

I even looked through the MessageFlagsBitField enum and I did not find anything indicating a silent message.

Share Improve this question edited Jun 20, 2023 at 18:42 DragonFire7z asked Jun 20, 2023 at 18:42 DragonFire7zDragonFire7z 811 silver badge5 bronze badges 4
  • What do you expect a silent message to do? From my research, they don't send a notification or sound, but still trigger the unread/mentions indicator. Is that what you're wanting? – Samathingamajig Commented Jun 20, 2023 at 18:46
  • 1 I don't believe silent messages are available in the api, so discordjs wouldn't have an implementation for it. If your goal is to mention a member without sending them a notification as Samathingamajig, put it inside an embed. – Blair Commented Jun 20, 2023 at 18:52
  • Please explain what do you mean by slient messages – Vaibhav Naik Commented Jun 21, 2023 at 14:02
  • By silent message, I mean one without a notification, as a Discord user you can usually make a silent message by typing '@silent' at the beginning of your message. – DragonFire7z Commented Jun 21, 2023 at 19:40
Add a ment  | 

1 Answer 1

Reset to default 8

Nevermind, I figured it out.

After console logging sent silent messages and paring them to regular messages I noticed that silent messages had flags: MessageFlagsBitField { bitfield: 4096 } while regular messages had flags: MessageFlagsBitField { bitfield: 0 }

After a bit of messing with the code I ended up with:

var msg = await channel.send({
  content: "message",
  flags: [ 4096 ]
});

which actually results in a silent message!

Though I did manage to find a solution, I still wonder if there is a more official way of doing this.

本文标签: javascriptHow to send a silent message with discordjsStack Overflow