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.
- 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
1 Answer
Reset to default 8Nevermind, 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
版权声明:本文标题:javascript - How to send a silent message with discord.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744781407a2624737.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论