mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-25 06:17:02 -04:00
forked!!
This commit is contained in:
parent
538b87062a
commit
ea7451bcdc
326 changed files with 24876 additions and 2280 deletions
31
src/equicordplugins/cleanChannelName/index.ts
Normal file
31
src/equicordplugins/cleanChannelName/index.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2023 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { Channel } from "discord-types/general";
|
||||
|
||||
export default definePlugin({
|
||||
name: "CleanChannelName",
|
||||
authors: [Devs.AutumnVN],
|
||||
description: "remove all emoji and decor shit from channel names",
|
||||
patches: [
|
||||
{
|
||||
find: "loadAllGuildAndPrivateChannelsFromDisk(){",
|
||||
replacement: {
|
||||
match: /(?<=getChannel\(\i\)\{if\(null!=\i\)return )\i\(\i\)/,
|
||||
replace: "$self.cleanChannelName($&)",
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
cleanChannelName(channel?: Channel) {
|
||||
if (channel) {
|
||||
channel.name = channel.name.normalize("NFKC").replace(/[^\u0020-\u007E]?\p{Extended_Pictographic}[^\u0020-\u007E]?/ug, "").replace(/-?[^\p{Letter}\u0020-\u007E]-?/ug, [2, 4].includes(channel.type) ? " " : "-").replace(/(^-|-$)/g, "");
|
||||
}
|
||||
return channel;
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue