aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/userVoiceShow/components/VoiceChannelSection.tsx
diff options
context:
space:
mode:
authorLordElias <55048695+LordEliasTM@users.noreply.github.com>2023-04-06 03:22:54 +0200
committerGitHub <noreply@github.com>2023-04-06 03:22:54 +0200
commite261c935639896ad8655f99f835f376cc5028dcc (patch)
tree04675104794ac0334347a16304dbc3d8d715948e /src/plugins/userVoiceShow/components/VoiceChannelSection.tsx
parentdf7357b3574bf87eba5caa41e637c73ba2158ee3 (diff)
downloadVencord-e261c935639896ad8655f99f835f376cc5028dcc.tar.gz
Vencord-e261c935639896ad8655f99f835f376cc5028dcc.tar.bz2
Vencord-e261c935639896ad8655f99f835f376cc5028dcc.zip
feat(plugin): User Voice Show (#694)
Co-authored-by: V <vendicated@riseup.net> Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com>
Diffstat (limited to 'src/plugins/userVoiceShow/components/VoiceChannelSection.tsx')
-rw-r--r--src/plugins/userVoiceShow/components/VoiceChannelSection.tsx61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/plugins/userVoiceShow/components/VoiceChannelSection.tsx b/src/plugins/userVoiceShow/components/VoiceChannelSection.tsx
new file mode 100644
index 0000000..b429f05
--- /dev/null
+++ b/src/plugins/userVoiceShow/components/VoiceChannelSection.tsx
@@ -0,0 +1,61 @@
+/*
+ * Vencord, a modification for Discord's desktop app
+ * Copyright (c) 2023 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 "./VoiceChannelSection.css";
+
+import { findByCodeLazy, findByPropsLazy } from "@webpack";
+import { Button, Forms, PermissionStore, Toasts } from "@webpack/common";
+import { Channel } from "discord-types/general";
+
+const ChannelActions = findByPropsLazy("selectChannel", "selectVoiceChannel");
+const UserPopoutSection = findByCodeLazy(".lastSection", ".children");
+
+const CONNECT = 1n << 20n;
+
+interface VoiceChannelFieldProps {
+ channel: Channel;
+ label: string;
+ showHeader: boolean;
+}
+
+export const VoiceChannelSection = ({ channel, label, showHeader }: VoiceChannelFieldProps) => (
+ <UserPopoutSection>
+ {showHeader && <Forms.FormTitle className="vc-uvs-header">In a voice channel</Forms.FormTitle>}
+ <Button
+ className="vc-uvs-button"
+ color={Button.Colors.TRANSPARENT}
+ size={Button.Sizes.SMALL}
+
+ onClick={() => {
+ if (PermissionStore.can(CONNECT, channel))
+ ChannelActions.selectVoiceChannel(channel.id);
+ else
+ Toasts.show({
+ message: "Insufficient permissions to enter the channel.",
+ id: "user-voice-show-insufficient-permissions",
+ type: Toasts.Type.FAILURE,
+ options: {
+ position: Toasts.Position.BOTTOM,
+ }
+ });
+ }}
+ >
+ {label}
+ </Button>
+ </UserPopoutSection>
+);