Plugin

VoiceDownload

Adds a download to voice messages. (Opens a new browser tab)

Voice Media
index.tsx
Download

Source

src/plugins/voiceDownload/index.tsx
1import "./style.css";
2
3import { Devs } from "@utils/constants";
4import definePlugin from "@utils/types";
5
6export default definePlugin({
7 name: "VoiceDownload",
8 description: "Adds a download to voice messages. (Opens a new browser tab)",
9 tags: ["Voice", "Media"],
10 authors: [Devs.puv],
11 patches: [
12 {
13 find: "#{intl::VOICE_MESSAGES_PLAYBACK_RATE_LABEL}",
14 replacement: {
15 match: /(?<=onVolumeHide:\i\}\))/,
16 replace: ",$self.renderDownload(arguments[0].src)"
17 }
18 }
19 ],
20
21 renderDownload(src: string) {
22 return (
23 <a
24 className="vc-voice-download"
25 href={src}
26 onClick={e => e.stopPropagation()}
27 aria-label="Download voice message"
28 {...IS_DISCORD_DESKTOP
29 ? { target: "_blank" } class="ts-cmt">// open externally
30 : { download: "voice-message.ogg" } class="ts-cmt">// download directly (not supported on discord desktop)
31 }
32 >
33 <this.Icon />
34 </a>
35 );
36 },
37
38 Icon: () => (
39 <svg
40 height="24"
41 width="24"
42 viewBox="0 0 24 24"
43 fill="currentColor"
44 >
45 <path
46 d="M12 2a1 1 0 0 1 1 1v10.59l3.3-3.3a1 1 0 1 1 1.4 1.42l-5 5a1 1 0 0 1-1.4 0l-5-5a1 1 0 1 1 1.4-1.42l3.3 3.3V3a1 1 0 0 1 1-1ZM3 20a1 1 0 1 0 0 2h18a1 1 0 1 0 0-2H3Z"
47 />
48 </svg>
49 ),
50});
51