aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authormegumin <megumin.bakaretsurie@gmail.com>2022-11-11 22:50:09 +0000
committerGitHub <noreply@github.com>2022-11-11 23:50:09 +0100
commit30ca4f1cf9cc1a4179f5c7ef5cfb47eaff83f56a (patch)
tree8ee2a9e7f83ba8c3c2441636e5d122de3aa663b4 /src/plugins
parent62e0787cf25a76881fac79b5f3df0ebda706bb21 (diff)
downloadVencord-30ca4f1cf9cc1a4179f5c7ef5cfb47eaff83f56a.tar.gz
Vencord-30ca4f1cf9cc1a4179f5c7ef5cfb47eaff83f56a.tar.bz2
Vencord-30ca4f1cf9cc1a4179f5c7ef5cfb47eaff83f56a.zip
feat: Badge API (#206)
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/apiBadges.tsx70
-rw-r--r--src/plugins/banger.ts8
-rw-r--r--src/plugins/clearURLs/index.ts8
-rw-r--r--src/plugins/experiments.tsx2
-rw-r--r--src/plugins/iLoveSpam.ts5
-rw-r--r--src/plugins/moarKaomojis.ts10
-rw-r--r--src/plugins/moreCommands.ts9
-rw-r--r--src/plugins/nitroBypass.ts6
-rw-r--r--src/plugins/noCanaryMessageLinks.ts5
-rw-r--r--src/plugins/noReplyMention.ts6
-rw-r--r--src/plugins/pronoundb/index.ts6
-rw-r--r--src/plugins/showHiddenChannels.tsx12
-rw-r--r--src/plugins/spotifyControls/index.tsx12
-rw-r--r--src/plugins/uwuify.ts6
-rw-r--r--src/plugins/vcDoubleClick.ts5
15 files changed, 90 insertions, 80 deletions
diff --git a/src/plugins/apiBadges.tsx b/src/plugins/apiBadges.tsx
new file mode 100644
index 0000000..e26a7a1
--- /dev/null
+++ b/src/plugins/apiBadges.tsx
@@ -0,0 +1,70 @@
+/*
+ * 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/>.
+*/
+
+import { BadgePosition, ProfileBadge } from "../api/Badges";
+import { Devs } from "../utils/constants";
+import IpcEvents from "../utils/IpcEvents";
+import definePlugin from "../utils/types";
+
+const CONTRIBUTOR_BADGE = "https://media.discordapp.net/stickers/1026517526106087454.webp";
+
+/** List of vencord contributor IDs */
+const contributorIds: string[] = Object.values(Devs).map(d => d.id.toString());
+
+const ContributorBadge: ProfileBadge = {
+ tooltip: "Vencord Contributor",
+ image: CONTRIBUTOR_BADGE,
+ position: BadgePosition.START,
+ props: {
+ style: {
+ borderRadius: "50%",
+ transform: "scale(0.9)" // The image is a bit too big compared to default badges
+ }
+ },
+ shouldShow: ({ user }) => contributorIds.includes(user.id),
+ onClick: () => VencordNative.ipc.invoke(IpcEvents.OPEN_EXTERNAL, "https://github.com/Vendicated/Vencord")
+};
+
+export default definePlugin({
+ name: "BadgeAPI",
+ description: "API to add badges to users.",
+ authors: [Devs.Megu],
+ required: true,
+ patches: [
+ /* Patch the badges array */
+ {
+ find: "PREMIUM_GUILD_SUBSCRIPTION_TOOLTIP.format({date:",
+ replacement: {
+ match: /&&((\w{1,3})\.push\({tooltip:\w{1,3}\.\w{1,3}\.Messages\.PREMIUM_GUILD_SUBSCRIPTION_TOOLTIP\.format.+?;)(?:return\s\w{1,3};?})/,
+ replace: (_, m, badgeArray) => `&&${m} return Vencord.Api.Badges.inject(${badgeArray}, arguments[0]);}`,
+ }
+ },
+ /* Patch the badge list component on user profiles */
+ {
+ find: "Messages.PROFILE_USER_BADGES,role:",
+ replacement: {
+ match: /src:(\w{1,3})\[(\w{1,3})\.key\],/,
+ // <img src={badge.image ?? imageMap[badge.key]} {...badge.props} />
+ replace: (_, imageMap, badge) => `src: ${badge}.image ?? ${imageMap}[${badge}.key], ...${badge}.props,`
+ }
+ }
+ ],
+ start() {
+ Vencord.Api.Badges.addBadge(ContributorBadge);
+ },
+});
diff --git a/src/plugins/banger.ts b/src/plugins/banger.ts
index 59d9b42..6263224 100644
--- a/src/plugins/banger.ts
+++ b/src/plugins/banger.ts
@@ -22,13 +22,7 @@ import definePlugin, { OptionType } from "../utils/types";
export default definePlugin({
name: "BANger",
description: "Replaces the GIF in the ban dialogue with a custom one.",
- authors: [
- {
- name: "Xinto",
- id: 423915768191647755n
- },
- Devs.Glitch
- ],
+ authors: [Devs.Xinto, Devs.Glitch],
patches: [
{
find: "BAN_CONFIRM_TITLE.",
diff --git a/src/plugins/clearURLs/index.ts b/src/plugins/clearURLs/index.ts
index be0b802..b01faed 100644
--- a/src/plugins/clearURLs/index.ts
+++ b/src/plugins/clearURLs/index.ts
@@ -23,6 +23,7 @@ import {
removePreEditListener,
removePreSendListener,
} from "../../api/MessageEvents";
+import { Devs } from "../../utils/constants";
import definePlugin from "../../utils/types";
import { defaultRules } from "./defaultRules";
@@ -33,12 +34,7 @@ const reHasRegExpChar = RegExp(reRegExpChar.source);
export default definePlugin({
name: "clearURLs",
description: "Removes tracking garbage from URLs",
- authors: [
- {
- name: "adryd",
- id: 0n,
- },
- ],
+ authors: [Devs.adryd],
dependencies: ["MessageEventsAPI"],
escapeRegExp(str: string) {
diff --git a/src/plugins/experiments.tsx b/src/plugins/experiments.tsx
index 861bb05..4f83c5a 100644
--- a/src/plugins/experiments.tsx
+++ b/src/plugins/experiments.tsx
@@ -31,7 +31,7 @@ export default definePlugin({
Devs.Megu,
Devs.Ven,
Devs.Nickyux,
- { name: "BanTheNons", id: 460478012794863637n },
+ Devs.BanTheNons
],
description: "Enable Access to Experiments in Discord!",
patches: [{
diff --git a/src/plugins/iLoveSpam.ts b/src/plugins/iLoveSpam.ts
index 1775326..7f390f3 100644
--- a/src/plugins/iLoveSpam.ts
+++ b/src/plugins/iLoveSpam.ts
@@ -22,10 +22,7 @@ import definePlugin from "../utils/types";
export default definePlugin({
name: "iLoveSpam",
description: "Do not hide messages from 'likely spammers'",
- authors: [
- Devs.botato,
- Devs.Animal,
- ],
+ authors: [Devs.botato, Devs.Animal],
patches: [
{
find: "),{hasFlag:",
diff --git a/src/plugins/moarKaomojis.ts b/src/plugins/moarKaomojis.ts
index 839be6a..8b3c0c5 100644
--- a/src/plugins/moarKaomojis.ts
+++ b/src/plugins/moarKaomojis.ts
@@ -16,18 +16,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-import { findOption,OptionalMessageOption } from "../api/Commands";
+import { findOption, OptionalMessageOption } from "../api/Commands";
+import { Devs } from "../utils/constants";
import definePlugin from "../utils/types";
export default definePlugin({
name: "moarKaomojis",
description: "Adds more Kaomojis to discord. ヽ(´▽`)/",
- authors: [
- {
- name: "Jacob.Tm",
- id: 302872992097107991n
- }
- ],
+ authors: [Devs.JacobTm],
dependencies: ["CommandsAPI"],
commands: [
{ name: "dissatisfaction", description: " >﹏<" },
diff --git a/src/plugins/moreCommands.ts b/src/plugins/moreCommands.ts
index 074e715..0a23aaf 100644
--- a/src/plugins/moreCommands.ts
+++ b/src/plugins/moreCommands.ts
@@ -32,14 +32,7 @@ function mock(input: string): string {
export default definePlugin({
name: "MoreCommands",
description: "echo, lenny, mock",
- authors: [
- Devs.Arjix,
- Devs.echo,
- {
- name: "ICodeInAssembly",
- id: 702973430449832038n
- }
- ],
+ authors: [Devs.Arjix, Devs.echo, Devs.Samu],
dependencies: ["CommandsAPI"],
commands: [
{
diff --git a/src/plugins/nitroBypass.ts b/src/plugins/nitroBypass.ts
index 937b8d0..dfdfe9d 100644
--- a/src/plugins/nitroBypass.ts
+++ b/src/plugins/nitroBypass.ts
@@ -52,11 +52,7 @@ interface StickerPack {
export default definePlugin({
name: "NitroBypass",
- authors: [
- Devs.Arjix,
- Devs.D3SOX,
- Devs.Ven
- ],
+ authors: [Devs.Arjix, Devs.D3SOX, Devs.Ven],
description: "Allows you to stream in nitro quality and send fake emojis/stickers.",
dependencies: ["MessageEventsAPI"],
diff --git a/src/plugins/noCanaryMessageLinks.ts b/src/plugins/noCanaryMessageLinks.ts
index 807c864..67c9176 100644
--- a/src/plugins/noCanaryMessageLinks.ts
+++ b/src/plugins/noCanaryMessageLinks.ts
@@ -24,10 +24,7 @@ import { Settings } from "../Vencord";
export default definePlugin({
name: "NoCanaryMessageLinks",
description: "Allows you to change/remove the subdomain of discord message and channel links",
- authors: [
- Devs.Samu,
- Devs.nea,
- ],
+ authors: [Devs.Samu, Devs.nea],
options: {
linkPrefix: {
description: "The subdomain for your discord message links",
diff --git a/src/plugins/noReplyMention.ts b/src/plugins/noReplyMention.ts
index d516450..2e5e969 100644
--- a/src/plugins/noReplyMention.ts
+++ b/src/plugins/noReplyMention.ts
@@ -16,15 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+import { Devs } from "../utils/constants";
import definePlugin from "../utils/types";
export default definePlugin({
name: "NoReplyMention",
description: "Disables reply pings by default",
- authors: [{
- name: "DustyAngel47",
- id: 714583473804935238n
- }],
+ authors: [Devs.DustyAngel47],
patches: [
{
find: "CREATE_PENDING_REPLY:function",
diff --git a/src/plugins/pronoundb/index.ts b/src/plugins/pronoundb/index.ts
index 802ede9..39637e2 100644
--- a/src/plugins/pronoundb/index.ts
+++ b/src/plugins/pronoundb/index.ts
@@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+import { Devs } from "../../utils/constants";
import definePlugin, { OptionType } from "../../utils/types";
import PronounsAboutComponent from "./components/PronounsAboutComponent";
import PronounsChatComponent from "./components/PronounsChatComponent";
@@ -28,10 +29,7 @@ export enum PronounsFormat {
export default definePlugin({
name: "PronounDB",
- authors: [{
- name: "Tyman",
- id: 487443883127472129n
- }],
+ authors: [Devs.Tyman],
description: "Adds pronouns to user messages using pronoundb",
patches: [
// Patch the chat timestamp element
diff --git a/src/plugins/showHiddenChannels.tsx b/src/plugins/showHiddenChannels.tsx
index 7f2c4b8..8dc92bf 100644
--- a/src/plugins/showHiddenChannels.tsx
+++ b/src/plugins/showHiddenChannels.tsx
@@ -34,17 +34,7 @@ waitFor(m => m.can && m.initialize, m => ({ can } = m));
export default definePlugin({
name: "ShowHiddenChannels",
description: "Show hidden channels",
- authors: [
- {
- name: "BigDuck",
- id: 1024588272623681609n
- },
- {
- name: "Average React Enjoyer",
- id: 1004904120056029256n
- },
- Devs.D3SOX,
- ],
+ authors: [Devs.BigDuck, Devs.AverageReactEnjoyer, Devs.D3SOX],
options: {
hideUnreads: {
description: "Hide unreads",
diff --git a/src/plugins/spotifyControls/index.tsx b/src/plugins/spotifyControls/index.tsx
index 6bf6625..e8b5370 100644
--- a/src/plugins/spotifyControls/index.tsx
+++ b/src/plugins/spotifyControls/index.tsx
@@ -23,17 +23,7 @@ import { Player } from "./PlayerComponent";
export default definePlugin({
name: "SpotifyControls",
description: "Spotify Controls",
- authors: [
- Devs.Ven,
- {
- id: 420043923822608384n,
- name: "afn",
- },
- {
- id: 379304073515499530n,
- name: "KraXen72"
- }
- ],
+ authors: [Devs.Ven, Devs.afn, Devs.KraXen72],
dependencies: ["MenuItemDeobfuscatorApi"],
patches: [
{
diff --git a/src/plugins/uwuify.ts b/src/plugins/uwuify.ts
index 9f4ac7e..804c741 100644
--- a/src/plugins/uwuify.ts
+++ b/src/plugins/uwuify.ts
@@ -17,6 +17,7 @@
*/
import { findOption, RequiredMessageOption } from "../api/Commands";
+import { Devs } from "../utils/constants";
import definePlugin from "../utils/types";
const endings = [
@@ -109,10 +110,7 @@ function uwuify(message: string): string {
export default definePlugin({
name: "UwUifier",
description: "Simply uwuify commands",
- authors: [{
- name: "ECHO",
- id: 712639419785412668n
- }],
+ authors: [Devs.echo],
dependencies: ["CommandsAPI"],
commands: [
diff --git a/src/plugins/vcDoubleClick.ts b/src/plugins/vcDoubleClick.ts
index 554b31a..b1a0558 100644
--- a/src/plugins/vcDoubleClick.ts
+++ b/src/plugins/vcDoubleClick.ts
@@ -28,10 +28,7 @@ const timers = {} as Record<string, {
export default definePlugin({
name: "vcDoubleClick",
description: "Join VCs via DoubleClick instead of single click",
- authors: [
- Devs.Ven,
- Devs.D3SOX,
- ],
+ authors: [Devs.Ven, Devs.D3SOX],
patches: [
{
find: "VoiceChannel.renderPopout",