Add support for silent pings in notifications (#679)
This commit is contained in:
parent
aaf6fa82d6
commit
26d920aa47
1 changed files with 8 additions and 0 deletions
|
|
@ -22,6 +22,8 @@ interface IMessageCreate {
|
|||
message: Message;
|
||||
}
|
||||
|
||||
const SILENT_PING_FLAG = 1 << 12;
|
||||
|
||||
function Icon(enabled?: boolean): JSX.Element {
|
||||
return <svg
|
||||
width="18"
|
||||
|
|
@ -122,6 +124,11 @@ const settings = definePluginSettings({
|
|||
description: "Whether the notification sound should be played",
|
||||
default: true,
|
||||
},
|
||||
respectSilentPings: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Respect silent pings (@silent / suppress notifications)",
|
||||
default: true
|
||||
},
|
||||
statusToUse: {
|
||||
type: OptionType.SELECT,
|
||||
description: "Status to use for whitelist",
|
||||
|
|
@ -161,6 +168,7 @@ export default definePlugin({
|
|||
if (message.state === "SENDING" || message.content === "" || message.author.id === currentUser.id || (channelId === currentChannelId && WindowStore.isFocused()) || userStatus !== settings.store.statusToUse) {
|
||||
return;
|
||||
}
|
||||
if (settings.store.respectSilentPings && (message.flags & SILENT_PING_FLAG)) {return;}
|
||||
const mentioned = MessageStore.getMessage(channelId, message.id)?.mentioned;
|
||||
if ((settings.store.guilds.split(", ").includes(guildId) || settings.store.channels.split(", ").includes(channelId)) && mentioned) {
|
||||
await showNotification(message, guildId);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue