-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
82 lines (58 loc) · 2.54 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
const discord = require("discord.js");
const client = new discord.Client();
client.on("ready", () => {
console.log("[--------------------- R E A D Y ---------------------]");
client.user.setActivity(",h | Added nqn");
})
client.on("message", async (message) => {
if(message.author.bot) return;
let substringArray = get_substrings_between(message.content, ":", ":");
let msg = message.content;
if(!substringArray.length) return;
substringArray.forEach(m => {
let emoji = client.emojis.cache.find(x => x.name === m);
var replace = `:${m}:`;
var rexreplace = new RegExp(replace, 'g');
if(emoji && !msg.split(" ").find(x => x === emoji.toString()) && !msg.includes(`<a${replace}${emoji.id}>`)) msg = msg.replace(rexreplace, emoji.toString());
})
if(msg === message.content) return;
let webhook = await message.channel.fetchWebhooks();
webhook = webhook.find(x => x.name === "NQN2");
if(!webhook) {
webhook = await message.channel.createWebhook(`NQN2`, {
avatar: client.user.displayAvatarURL({dynamic: true})
});
}
await webhook.edit({
name: message.member.nickname ? message.member.nickname : message.author.username,
avatar: message.author.displayAvatarURL({dynamic: true})
})
message.delete().catch(m => {})
webhook.send(msg).catch( m => {});
await webhook.edit({
name: `NQN2`,
avatar: client.user.displayAvatarURL({dynamic:true})
})
})
client.login("Nzc3MDM2MzQ0Mjc4NTE1NzEy.X69lfQ.qUEIez8p3cTdzupyX6jQDUJSApg");
//--------------------------------------------------- F U N C T I O N S --------------------------------------
function get_substrings_between(str, startDelimiter, endDelimiter) {
var contents = [];
var startDelimiterLength = startDelimiter.length;
var endDelimiterLength = endDelimiter.length;
var startFrom = contentStart = contentEnd = 0;
while (false !== (contentStart = strpos(str, startDelimiter, startFrom))) {
contentStart += startDelimiterLength;
contentEnd = strpos(str, endDelimiter, contentStart);
if (false === contentEnd) {
break;
}
contents.push(str.substr(contentStart, contentEnd - contentStart));
startFrom = contentEnd + endDelimiterLength;
}
return contents;
}
function strpos(haystack, needle, offset) {
var i = (haystack + '').indexOf(needle, (offset || 0));
return i === -1 ? false : i;
}