MediaFixer/index.js
Levi 20a80a3c63
Major rewrite
- Remove discord-reply dependency, discord.js supports inline replies now.
- Refer to token in config file for ease of use
- Add ability for user to select any twitter embed link parser of their choice using the tweetParser property in the config file.
- Various rewrites for discord.js v14.4.0
- Changes behavior from removing original messsage to just removing the embed in the original message. This is more user friendly.
2022-09-24 01:51:13 +02:00

36 lines
1.2 KiB
JavaScript

// Require the necessary discord.js classes
const { Client, GatewayIntentBits } = require('discord.js');
const { token, tweetParser } = 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(4000);
// 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 } });
}
});
// Login to Discord with your client's token
client.login(token);