2022-09-26 17:33:10 +02:00
|
|
|
const {
|
2022-09-26 18:03:47 +02:00
|
|
|
Client,
|
|
|
|
GatewayIntentBits
|
2022-09-26 17:43:48 +02:00
|
|
|
} = require('discord.js');
|
|
|
|
const {
|
2022-09-26 18:03:47 +02:00
|
|
|
token,
|
|
|
|
port,
|
|
|
|
tweetParser,
|
|
|
|
instaParser,
|
|
|
|
tiktokParser
|
2022-09-26 17:33:10 +02:00
|
|
|
} = require('./config.json');
|
2021-12-27 20:18:07 +01:00
|
|
|
const http = require('http');
|
2021-12-27 20:13:22 +01:00
|
|
|
// Create a new client instance
|
2022-09-24 01:51:13 +02:00
|
|
|
const client = new Client({
|
2022-09-26 18:03:47 +02:00
|
|
|
intents: [
|
|
|
|
GatewayIntentBits.Guilds,
|
|
|
|
GatewayIntentBits.GuildMessages,
|
|
|
|
GatewayIntentBits.MessageContent,
|
|
|
|
],
|
2022-09-24 01:51:13 +02:00
|
|
|
});
|
2021-12-27 20:18:07 +01:00
|
|
|
http.createServer((req, res) => {
|
2022-09-26 18:03:47 +02:00
|
|
|
res.writeHead(200, {
|
|
|
|
'Content-type': 'text/plain'
|
|
|
|
});
|
|
|
|
res.write('Hey');
|
|
|
|
res.end();
|
2022-09-24 16:18:10 +02:00
|
|
|
}).listen(port);
|
2021-12-27 20:13:22 +01:00
|
|
|
// When the client is ready, run this code (only once)
|
|
|
|
client.once('ready', () => {
|
2022-09-26 18:03:47 +02:00
|
|
|
console.log('Ready!');
|
2021-12-27 20:13:22 +01:00
|
|
|
});
|
|
|
|
// Response
|
|
|
|
client.on('messageCreate', async message => {
|
2022-09-26 18:03:47 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2021-12-27 20:13:22 +01:00
|
|
|
});
|
2022-09-24 15:29:31 +02:00
|
|
|
client.on('messageCreate', async message => {
|
2022-09-26 18:03:47 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-09-24 15:29:31 +02:00
|
|
|
});
|
|
|
|
client.on('messageCreate', async message => {
|
2022-09-26 18:03:47 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-09-24 15:29:31 +02:00
|
|
|
});
|
|
|
|
client.on('messageCreate', async message => {
|
2022-09-26 18:03:47 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-09-24 15:29:31 +02:00
|
|
|
});
|
2022-09-26 17:33:10 +02:00
|
|
|
client.on('messageCreate', async message => {
|
2022-09-26 18:03:47 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-09-26 17:33:10 +02:00
|
|
|
});
|
|
|
|
client.on('messageCreate', async message => {
|
2022-09-26 18:03:47 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-09-26 17:33:10 +02:00
|
|
|
});
|
2021-12-27 20:13:22 +01:00
|
|
|
// Login to Discord with your client's token
|
2022-09-26 17:33:10 +02:00
|
|
|
client.login(token);
|