Plugin

ReadAllNotificationsButton

Read all server notifications with a single button click!

Notifications Shortcuts
index.tsx
Download

Source

src/plugins/readAllNotificationsButton/index.tsx
1/*
2 * FiveCord — a Discord client mod
3 * Copyright (c) 2025 FiveCord
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
7import "./style.css";
8
9import { addServerListElement, removeServerListElement, ServerListRenderPosition } from "@api/ServerList";
10import { TextButton } from "@components/Button";
11import ErrorBoundary from "@components/ErrorBoundary";
12import { Devs } from "@utils/constants";
13import definePlugin from "@utils/types";
14import { ActiveJoinedThreadsStore, FluxDispatcher, GuildChannelStore, GuildStore, React, ReadStateStore } from "@webpack/common";
15
16function onClick() {
17 const channels: Array<any> = [];
18
19 Object.values(GuildStore.getGuilds()).forEach(guild => {
20 GuildChannelStore.getChannels(guild.id).SELECTABLE
21 .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: 0
33 });
34 });
35 });
36
37 FluxDispatcher.dispatch({
38 type: "BULK_ACK",
39 context: "APP",
40 channels: channels
41 });
42}
43
44const ReadAllButton = () => (
45 <TextButton
46 variant="secondary"
47 onClick={onClick}
48 className="vc-ranb-button"
49 >
50 Read All
51 </TextButton>
52);
53
54export 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