-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
112 lines (112 loc) · 3.29 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
const {
Client,
GatewayIntentBits
} = require('discord.js');
const {
token,
port,
tweetParser,
instaParser,
tiktokParser
} = require('./config.json');
const http = require('http');
// Create a new client instance
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});
http.createServer((req, res) => {
res.writeHead(200, {
'Content-type': 'text/plain'
});
res.write('Hey');
res.end();
}).listen(port);
// When the client is ready, run this code (only once)
client.once('ready', () => {
console.log('Ready!');
});
// Response
client.on('messageCreate', async message => {
if (message.content.startsWith('https://twitter.com/')) {
const tweetURL = message.content.substring(20, message.content.length);
message.suppressEmbeds(true);
const newmsg = tweetParser + tweetURL;
message.reply({
content: newmsg,
allowedMentions: {
repliedUser: false
}
});
}
});
client.on('messageCreate', async message => {
if (message.content.startsWith('https://mobile.twitter.com/')) {
const mobiletweetURL = message.content.substring(27, message.content.length);
message.suppressEmbeds(true);
const newmsg = tweetParser + mobiletweetURL;
message.reply({
content: newmsg,
allowedMentions: {
repliedUser: false
}
});
}
});
client.on('messageCreate', async message => {
if (message.content.startsWith('https://instagram.com/')) {
const instaURL = message.content.substring(22, message.content.length);
message.suppressEmbeds(true);
const newmsg = instaParser + instaURL;
message.reply({
content: newmsg,
allowedMentions: {
repliedUser: false
}
});
}
});
client.on('messageCreate', async message => {
if (message.content.startsWith('https://www.instagram.com/')) {
const instaURL2 = message.content.substring(26, message.content.length);
message.suppressEmbeds(true);
const newmsg = instaParser + instaURL2;
message.reply({
content: newmsg,
allowedMentions: {
repliedUser: false
}
});
}
});
client.on('messageCreate', async message => {
if (message.content.startsWith('https://tiktok.com/')) {
const tiktokURL = message.content.substring(19, message.content.length);
message.suppressEmbeds(true);
const newmsg = tiktokParser + tiktokURL;
message.reply({
content: newmsg,
allowedMentions: {
repliedUser: false
}
});
}
});
client.on('messageCreate', async message => {
if (message.content.startsWith('https://www.tiktok.com/')) {
const tiktokURL2 = message.content.substring(23, message.content.length);
message.suppressEmbeds(true);
const newmsg = tiktokParser + tiktokURL2;
message.reply({
content: newmsg,
allowedMentions: {
repliedUser: false
}
});
}
});
// Login to Discord with your client's token
client.login(token);