(Organization)
This commit is contained in:
Inbestigator 2024-03-09 12:57:10 -08:00
parent fd9f7aafcf
commit e483584eff

View file

@ -28,6 +28,21 @@ function icon(enabled?: boolean) {
</svg>;
}
function processIds(value) {
return value.replace(/\s/g, "").split(",").filter(id => id.trim() !== "").join(", ");
}
async function showNotification(message: Message, guildId?: string): Promise<void> {
await Notifications.showNotification({
title: `${message.author.globalName ?? message.author.username} ${guildId ? `sent a message in ${ChannelStore.getChannel(message.channel_id)?.name}` : "sent a message in a DM"}`,
body: message.content,
icon: UserStore.getUser(message.author.id).getAvatarURL(undefined, undefined, false),
onClick: function () {
NavigationRouter.transitionTo(`/channels/${guildId ?? "@me"}/${message.channel_id}/${message.id}`);
}
});
}
function ContextCallback(name: "guild" | "user" | "channel"): NavContextMenuPatchCallback {
return (children, props) => {
const type = props[name];
@ -58,21 +73,21 @@ const settings = definePluginSettings({
description: "Guilds to let bypass (notified when pinged anywhere in guild)",
default: "",
placeholder: "Separate with commas",
onChange: value => settings.store.guilds = value.replace(/\s/g, "").split(",").filter(id => id.trim() !== "").join(", ")
onChange: value => settings.store.guilds = processIds(value)
},
channels: {
type: OptionType.STRING,
description: "Channels to let bypass (notified when pinged in that channel)",
default: "",
placeholder: "Separate with commas",
onChange: value => settings.store.channels = value.replace(/\s/g, "").split(",").filter(id => id.trim() !== "").join(", ")
onChange: value => settings.store.channels = processIds(value)
},
users: {
type: OptionType.STRING,
description: "Users to let bypass (notified for all messages sent in DMs)",
default: "",
placeholder: "Separate with commas",
onChange: value => settings.store.users = value.replace(/\s/g, "").split(",").filter(id => id.trim() !== "").join(", ")
onChange: value => settings.store.users = processIds(value)
},
allowOutsideOfDms: {
type: OptionType.BOOLEAN,
@ -80,17 +95,6 @@ const settings = definePluginSettings({
}
});
async function showNotification(message: Message, guildId?: string): Promise<void> {
await Notifications.showNotification({
title: `${message.author.globalName ?? message.author.username} ${guildId ? `sent a message in ${ChannelStore.getChannel(message.channel_id)?.name}` : "sent a message in a DM"}`,
body: message.content,
icon: UserStore.getUser(message.author.id).getAvatarURL(undefined, undefined, false),
onClick: function () {
NavigationRouter.transitionTo(`/channels/${guildId ?? "@me"}/${message.channel_id}/${message.id}`);
}
});
}
export default definePlugin({
name: "BypassDND",
description: "Still get notifications from specific sources when in do not disturb mode. Right-click on users/channels/guilds to set them to bypass do not disturb mode.",