-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
50 lines (44 loc) · 1.53 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* Vencord, a Discord client mod
* Copyright (c) 2023 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { addPreSendListener, removePreSendListener, SendListener } from "@api/MessageEvents";
import { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
const settings = definePluginSettings(
{
blockedWords: {
type: OptionType.STRING,
description: "Strings not to capitilise (seperate with a comma)",
default: "http, https, ok"
}
}
);
const presendObject: SendListener = (_, msg) => {
const sentences = msg.content.split(/(?<=\w\.)\s/);
const blockedWordsArray: string[] = settings.store.blockedWords.split(", ");
msg.content = sentences.map(element => {
if (!blockedWordsArray.some(word => element.toLowerCase().startsWith(word.toLocaleLowerCase()))) {
return element.charAt(0).toUpperCase() + element.slice(1);
} else {
return element;
}
}).join(" ");
};
export default definePlugin({
name: "WriteUpperCase",
description: "Changes the first Letter of each Sentence in Message Inputs to Uppercase",
authors: [Devs.Samwich,
// Import from EquicordDev for Equicord
{ name: "krystalskullofficial", id: 929208515883569182n },
],
settings,
start() {
addPreSendListener(presendObject);
},
stop() {
removePreSendListener(presendObject);
}
});