-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
116 lines (103 loc) · 4.43 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import React from 'react';
import { Plugin } from '@vizality/entities';
import { patch, unpatch } from '@vizality/patcher';
import { getModuleByDisplayName, getModule, getModules } from '@vizality/webpack';
import { get } from '@vizality/http';
import { open as openModal } from '@vizality/modal';
import { clipboard } from 'electron';
export default class MentionUtilities extends Plugin {
async start () {
// modules
const menu = await getModule(["MenuItem"]);
const { getGuildId } = await getModule(["getLastSelectedGuildId"]);
const GuildChannelUserContextMenu = await getModule(m => m.default && m.default.displayName === 'GuildChannelUserContextMenu');
const DeveloperContextMenu = await getModule(m => m.default && m.default.displayName === 'DeveloperContextMenu');
const ChannelListVoiceChannelContextMenu = await getModule(m => m.default && m.default.displayName === 'ChannelListVoiceChannelContextMenu');
const ChannelListTextChannelContextMenu = await getModules(m => m.default && m.default.displayName === 'ChannelListTextChannelContextMenu')[2];
// injectors
patch('channel-inject', ChannelListTextChannelContextMenu, "default", (args, res) => {
// quick functions
function push(element){
res.props.children.push(element)
}
// channel copy mention
if (args[0]['channel'] && args[0]['channel']['id']){
var id = args[0]['channel']['id'];
var ele = React.createElement(menu.MenuItem, {
id: "mu-copy-channel-mention",
label: "Copy Channel Mention",
action: async () => {
clipboard.writeText(`<#${id}>`);
}
})
push(ele);
}
return res;
})
patch('voice-channel-inject', ChannelListVoiceChannelContextMenu, "default", (args, res) => {
// quick functions
function push(element){
res.props.children.push(element)
}
// voice channel copy link
if (args[0]['channel'] && args[0]['channel']['id']){
var id = args[0]['channel']['id'];
var gid = getGuildId();
var ele = React.createElement(menu.MenuItem, {
id: "mu-copy-vc-channel-link",
label: "Copy Voice Channel Link",
action: async () => {
clipboard.writeText(`https://discord.com/channels/${gid}/${id}/`);
}
})
push(ele);
}
return res;
})
patch('role-inject', DeveloperContextMenu, "default", (args, res) => {
// quick functions
res.props.children = [res.props.children]
function push(element){
res.props.children.push(element)
}
// role copy mention
if (args[0]['id']){
var id = args[0]['id'];
var ele = React.createElement(menu.MenuItem, {
id: "mu-copy-role-mention",
label: "Copy Role Mention",
action: async () => {
clipboard.writeText(`<@&${id}>`);
}
})
push(ele);
}
return res;
})
patch('menu-inject', GuildChannelUserContextMenu, "default", (args, res) => {
// quick functions
function push(element){
res.props.children.props.children.push(element)
}
// user copy mention
if (args[0]['user'] && args[0]['user']['id']){
var id = args[0]['user']['id'];
var ele = React.createElement(menu.MenuItem, {
id: "mu-copy-user-mention",
label: "Copy User Mention",
action: async () => {
clipboard.writeText(`<@${id}>`);
}
})
push(ele);
}
return res;
});
}
stop () {
unpatch('channel-inject')
unpatch('voice-channel-inject')
unpatch('role-inject')
unpatch('menu-inject')
}
}