-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.js
71 lines (54 loc) · 2.02 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
const { Client, Discord } = require("discord.js");
const chalk = require("chalk");
const client = new Client({
intents: 32767,
});
const { token } = require("./config.json")
client.on("ready", () => {
(console.log(
chalk.cyan("[Information] ") + chalk.blue(`Bot Started`))
)
client.user.setActivity("CODED BY RECOLXY");
})
client.on("messageCreate", async (messageCreate) => {
if(messageCreate.content.includes(`<Your Bot ID>`)) {
await message.channel.send("Hi there, I am nqn V3");
}
if (messageCreate.author.bot) return;
let msg = messageCreate.content;
let emojis = msg.match(/(?<=:)([^:\s]+)(?=:)/g)
if (!emojis) return;
emojis.forEach(m => {
let emoji = client.emojis.cache.find(x => x.name === m)
if (!emoji) return;
let temp = emoji.toString()
if (new RegExp(temp, "g").test(msg)) msg = msg.replace(new RegExp(temp, "g"), emoji.toString())
else msg = msg.replace(new RegExp(":" + m + ":", "g"), emoji.toString());
})
if (msg === messageCreate.content) return;
let webhook = await messageCreate.channel.fetchWebhooks();
let number = randomNumber(1, 2);
webhook = webhook.find(x => x.name === "NQN" + number);
if (!webhook) {
webhook = await messageCreate.channel.createWebhook(`NQN` + number, {
avatar: client.user.displayAvatarURL({ dynamic: true })
});
}
await webhook.edit({
name: messageCreate.member.nickname ? messageCreate.member.nickname : messageCreate.author.username,
avatar: messageCreate.author.displayAvatarURL({ dynamic: true })
})
messageCreate.delete().catch(err => { })
webhook.send(msg).catch(err => { })
await webhook.edit({
name: `NQN` + number,
avatar: client.user.displayAvatarURL({ dynamic: true })
})
})
client.login(token);
//--------------------------------------------------- F U N C T I O N S --------------------------------------
function randomNumber(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}