2022-10-25 11:32:05 -04:00
|
|
|
/*
|
|
|
|
* Vencord, a modification for Discord's desktop app
|
|
|
|
* Copyright (c) 2022 Vendicated and contributors
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2022-11-28 07:37:55 -05:00
|
|
|
import { Devs } from "@utils/constants";
|
|
|
|
import definePlugin from "@utils/types";
|
2023-01-13 17:18:12 -05:00
|
|
|
import { GuildStore } from "@webpack/common";
|
2023-10-13 20:38:57 -04:00
|
|
|
import { Channel, User } from "discord-types/general";
|
2022-10-25 11:32:05 -04:00
|
|
|
|
|
|
|
export default definePlugin({
|
|
|
|
name: "ForceOwnerCrown",
|
|
|
|
description: "Force the owner crown next to usernames even if the server is large.",
|
2022-10-31 21:19:07 -04:00
|
|
|
authors: [Devs.D3SOX, Devs.Nickyux],
|
2022-10-25 11:32:05 -04:00
|
|
|
patches: [
|
|
|
|
{
|
2023-10-25 11:26:28 -04:00
|
|
|
find: "AVATAR_DECORATION_PADDING:",
|
2022-10-25 11:32:05 -04:00
|
|
|
replacement: {
|
2023-10-25 11:26:28 -04:00
|
|
|
match: /,isOwner:(\i),/,
|
|
|
|
replace: ",_isOwner:$1=$self.isGuildOwner(e),"
|
2022-10-25 11:32:05 -04:00
|
|
|
}
|
2023-10-07 22:20:36 -04:00
|
|
|
}
|
2022-10-25 11:32:05 -04:00
|
|
|
],
|
2023-10-25 11:26:28 -04:00
|
|
|
isGuildOwner(props: { user: User, channel: Channel, isOwner: boolean, guildId?: string; }) {
|
|
|
|
if (!props?.user?.id) return props.isOwner;
|
2023-10-13 20:38:57 -04:00
|
|
|
if (props.channel?.type === 3 /* GROUP_DM */)
|
2023-10-25 11:26:28 -04:00
|
|
|
return props.isOwner;
|
2022-10-31 21:19:07 -04:00
|
|
|
|
2022-10-25 11:32:05 -04:00
|
|
|
// guild id is in props twice, fallback if the first is undefined
|
2023-10-13 20:38:57 -04:00
|
|
|
const guildId = props.guildId ?? props.channel?.guild_id;
|
|
|
|
const userId = props.user.id;
|
2022-10-25 11:32:05 -04:00
|
|
|
|
2023-10-13 20:38:57 -04:00
|
|
|
return GuildStore.getGuild(guildId)?.ownerId === userId;
|
2022-10-25 11:32:05 -04:00
|
|
|
},
|
|
|
|
});
|