Plugin
ColorMessage
Colors message content with author's role color
1
/*2
* FiveCord — a Discord client mod3
* Copyright (c) 2025 FiveCord4
* SPDX-License-Identifier: GPL-3.0-or-later5
*/6
7
import { definePluginSettings } from "@api/Settings";8
import * as Styles from "@api/Styles";9
import { Devs } from "@utils/constants";10
import definePlugin, { makeRange, OptionType } from "@utils/types";11
import { findByPropsLazy } from "@webpack";12
13
const AuthorStore = findByPropsLazy("useNullableMessageAuthor", "useNullableMessageAuthor");14
15
import style from "./style.css?managed";16
17
export const settings = definePluginSettings({18
saturation: {19
type: OptionType.SLIDER,20
description: "Message color saturation",21
markers: makeRange(0, 100, 10),22
default: 20,23
onChange() {24
updateStyle();25
},26
},27
});28
29
function updateStyle() {30
(Styles.requireStyle(style).dom!.sheet!.cssRules[0] as CSSStyleRule)31
.style.setProperty("--98-message-color-saturation", `${settings.store.saturation}`);32
}33
34
export default definePlugin({35
name: "ColorMessage",36
description: "Colors message content with author039;s role color",37
authors: [Devs.FiveCord],38
settings,39
40
patches: [41
{42
find: 039;default.Messages.MESSAGE_EDITED,")"039;,43
replacement: {44
match: /id:\(0,\w+.getMessageContentId\)\((\w+)\),/,45
replace: 039;$&style:{"--98-message-color":$self.getMessageColor($1)},039;46
}47
},48
],49
50
getMessageColor(messageId: string) {51
return AuthorStore.default(messageId).colorString;52
},53
54
start() {55
Styles.enableStyle(style);56
updateStyle();57
},58
stop() {59
Styles.disableStyle(style);60
},61
});62