mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-21 12:27:02 -04:00
forked!!
This commit is contained in:
parent
538b87062a
commit
ea7451bcdc
326 changed files with 24876 additions and 2280 deletions
47
src/equicordplugins/questionMarkReplacement/index.tsx
Normal file
47
src/equicordplugins/questionMarkReplacement/index.tsx
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { addPreSendListener, removePreSendListener } from "@api/MessageEvents";
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
|
||||
const settings = definePluginSettings({
|
||||
replace: {
|
||||
type: OptionType.STRING,
|
||||
description: "Replace with",
|
||||
default: ":face_with_monocle:"
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
function replaceQuestionMarks(content: string): string {
|
||||
const allQuestionMarks = content.split("").every(char => char === "?");
|
||||
|
||||
if (allQuestionMarks) {
|
||||
return content.replace(/\?/g, settings.store.replace);
|
||||
} else {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
export default definePlugin({
|
||||
name: "QuestionMarkReplace",
|
||||
description: "Replace all question marks with chosen string, if message only contains question marks.",
|
||||
authors: [Devs.nyx],
|
||||
|
||||
settings,
|
||||
|
||||
start() {
|
||||
this.preSend = addPreSendListener((_, msg) => {
|
||||
msg.content = replaceQuestionMarks(msg.content);
|
||||
});
|
||||
},
|
||||
|
||||
stop() {
|
||||
removePreSendListener(this.preSend);
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue