This repository was archived by the owner on Mar 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
90 lines (74 loc) · 2.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
const { Plugin } = require("powercord/entities");
const {
getModule,
messages
} = require("powercord/webpack");
const { inject, uninject } = require('powercord/injector');
const { Dispatcher, FluxDispatcher } = require("./modules/dispatcher.js");
const getCurrentUser = getModule(["getCurrentUser", "getUser", "_dispatchToken"], false).getCurrentUser;
const logging = false;
let defaultPremium = null;
Dispatcher.afterLogin(()=> {
defaultPremium = getCurrentUser().premiumType;
});
module.exports = class NitroBypass extends Plugin {
constructor(){
super();
this.injectIDs = {
sendMessage: 'NitroBypass-sendMessage',
editMessage: 'NitroBypass-editMessage'
};
};
setPremiumType(type=Number) {
if(!Dispatcher.isConnected()) {
Dispatcher.afterLogin(()=> {
getCurrentUser().premiumType = type;
});
} else {
getCurrentUser().premiumType = type;
}
};
restorePremiumType() {
getCurrentUser().premiumType = defaultPremium;
};
setEmojiBypass() {
inject(this.injectIDs.sendMessage, messages, 'sendMessage', (args)=> {
const [_channelId, message] = args;
message.validNonShortcutEmojis?.forEach(emoji=> {
if(emoji.url.startsWith("/assets/")) return;
const emojiName = emoji.allNamesString.replace(/~\d/g, "");
const emojiFullDir = `<${emoji.animated? "a":''}${emojiName}${emoji.id}>`;
message.content = message.content.replace(emojiFullDir, emoji.url+`&size=${48}`);
});
return args;
}, true);
inject(this.injectIDs.editMessage, messages, 'editMessage', (args)=> {
const [_guildId, _channelId, message] = args;
const rawEmojiStrings = message.content.match(/<(a)?:(.*)?:\d{18}>/g);
rawEmojiStrings?.forEach(rawEmojiString=> {
const emojiUrl = `https://cdn.discordapp.com/emojis/${rawEmojiString.match(/\d{18}/g)[0]}?size=${48}`;
message.content = message.content.replace(rawEmojiString, emojiUrl);
});
return args;
}, true);
};
restoreEmojiBypass() {
Object.values(this.injectIDs).forEach(injectID=> {
uninject(injectID);
});
};
startPlugin() {
if(logging) {
this.check_isConnected = setInterval(function(){
console.log(Dispatcher.isConnected());
}, 1000);
}
this.setPremiumType(2);
this.setEmojiBypass();
};
pluginWillUnload() {
if(logging) clearInterval(this.check_isConnected);
this.restorePremiumType();
this.restoreEmojiBypass();
};
};