2021-12-27 20:13:22 +01:00
|
|
|
// Require the necessary discord.js classes
|
2022-09-24 01:51:13 +02:00
|
|
|
const { Client, GatewayIntentBits } = require('discord.js');
|
2022-09-24 16:18:10 +02:00
|
|
|
const { token, port, tweetParser, instaParser } = 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({
|
|
|
|
intents: [
|
|
|
|
GatewayIntentBits.Guilds,
|
|
|
|
GatewayIntentBits.GuildMessages,
|
|
|
|
GatewayIntentBits.MessageContent,
|
|
|
|
],
|
|
|
|
});
|
2021-12-27 20:13:22 +01:00
|
|
|
|
2021-12-27 20:18:07 +01:00
|
|
|
http.createServer((req, res) => {
|
2022-09-24 01:51:13 +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:18:07 +01:00
|
|
|
|
2021-12-27 20:13:22 +01:00
|
|
|
// When the client is ready, run this code (only once)
|
|
|
|
client.once('ready', () => {
|
2022-09-24 01:51:13 +02:00
|
|
|
console.log('Ready!');
|
2021-12-27 20:13:22 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// Response
|
|
|
|
client.on('messageCreate', async message => {
|
2022-09-24 01:51:13 +02:00
|
|
|
if (message.content.startsWith('https://twitter.com/')) {
|
|
|
|
const tweetURL = message.content.substring(20, message.content.length);
|
|
|
|
message.suppressEmbeds(true);
|
2021-12-27 20:13:22 +01:00
|
|
|
|
2022-09-24 01:51:13 +02:00
|
|
|
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 => {
|
|
|
|
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 } });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-12-27 20:13:22 +01:00
|
|
|
// Login to Discord with your client's token
|
2022-09-24 01:51:13 +02:00
|
|
|
client.login(token);
|