Plugin
ReadAllNotificationsButton
Read all server notifications with a single button click!
1
/*2
* FiveCord — a Discord client mod3
* Copyright (c) 2025 FiveCord4
* SPDX-License-Identifier: GPL-3.0-or-later5
*/6
7
import "./style.css";8
9
import { addServerListElement, removeServerListElement, ServerListRenderPosition } from "@api/ServerList";10
import { TextButton } from "@components/Button";11
import ErrorBoundary from "@components/ErrorBoundary";12
import { Devs } from "@utils/constants";13
import definePlugin from "@utils/types";14
import { ActiveJoinedThreadsStore, FluxDispatcher, GuildChannelStore, GuildStore, React, ReadStateStore } from "@webpack/common";15
16
function onClick() {17
const channels: Array<any> = [];18
19
Object.values(GuildStore.getGuilds()).forEach(guild => {20
GuildChannelStore.getChannels(guild.id).SELECTABLE21
.concat(GuildChannelStore.getChannels(guild.id).VOCAL)22
.concat(23
Object.values(ActiveJoinedThreadsStore.getActiveJoinedThreadsForGuild(guild.id))24
.flatMap(threadChannels => Object.values(threadChannels))25
)26
.forEach((c: { channel: { id: string; }; }) => {27
if (!ReadStateStore.hasUnread(c.channel.id)) return;28
29
channels.push({30
channelId: c.channel.id,31
messageId: ReadStateStore.lastMessageId(c.channel.id),32
readStateType: 033
});34
});35
});36
37
FluxDispatcher.dispatch({38
type: "BULK_ACK",39
context: "APP",40
channels: channels41
});42
}43
44
const ReadAllButton = () => (45
<TextButton46
variant="secondary"47
onClick={onClick}48
className="vc-ranb-button"49
>50
Read All51
</TextButton>52
);53
54
export default definePlugin({55
name: "ReadAllNotificationsButton",56
description: "Read all server notifications with a single button click!",57
tags: ["Notifications", "Shortcuts"],58
authors: [Devs.kemo],59
dependencies: ["ServerListAPI"],60
61
renderReadAllButton: ErrorBoundary.wrap(ReadAllButton, { noop: true }),62
63
start() {64
addServerListElement(ServerListRenderPosition.Above, this.renderReadAllButton);65
},66
67
stop() {68
removeServerListElement(ServerListRenderPosition.Above, this.renderReadAllButton);69
}70
});71