MediaFixer/index.js

37 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-12-27 20:13:22 +01:00
// Require the necessary discord.js classes
const { Client, GatewayIntentBits } = require('discord.js');
const { token, tweetParser } = 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
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) => {
res.writeHead(200, { 'Content-type': 'text/plain' });
res.write('Hey');
res.end();
2021-12-27 20:18:07 +01:00
}).listen(4000);
2021-12-27 20:13:22 +01:00
// When the client is ready, run this code (only once)
client.once('ready', () => {
console.log('Ready!');
2021-12-27 20:13:22 +01:00
});
// 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);
2021-12-27 20:13:22 +01:00
const newmsg = tweetParser + tweetURL;
message.reply({ content: newmsg, allowedMentions: { repliedUser: false } });
}
2021-12-27 20:13:22 +01:00
});
// Login to Discord with your client's token
client.login(token);