mirror of
https://github.com/LeviSnoot/MediaFixer.git
synced 2024-12-03 18:20:02 +01:00
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.
This commit is contained in:
parent
800933b3b9
commit
20a80a3c63
1 changed files with 20 additions and 24 deletions
44
index.js
44
index.js
|
@ -1,40 +1,36 @@
|
||||||
const mySecret = process.env['TOKEN']
|
|
||||||
// Require the necessary discord.js classes
|
// Require the necessary discord.js classes
|
||||||
const { Client, Intents } = require('discord.js');
|
const { Client, GatewayIntentBits } = require('discord.js');
|
||||||
|
const { token, tweetParser } = require('./config.json');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
require('discord-reply'); // IMPORTANT: put this before your discord.Client()
|
|
||||||
// Create a new client instance
|
// Create a new client instance
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
intents: [
|
intents: [
|
||||||
Intents.FLAGS.GUILDS,
|
GatewayIntentBits.Guilds,
|
||||||
Intents.FLAGS.GUILD_MESSAGES
|
GatewayIntentBits.GuildMessages,
|
||||||
]
|
GatewayIntentBits.MessageContent,
|
||||||
});
|
],
|
||||||
|
});
|
||||||
|
|
||||||
http.createServer((req, res) => {
|
http.createServer((req, res) => {
|
||||||
res.writeHead(200, {
|
res.writeHead(200, { 'Content-type': 'text/plain' });
|
||||||
'Content-type': 'text/plain'
|
res.write('Hey');
|
||||||
});
|
res.end();
|
||||||
res.write('Hey');
|
|
||||||
res.end();
|
|
||||||
}).listen(4000);
|
}).listen(4000);
|
||||||
|
|
||||||
// When the client is ready, run this code (only once)
|
// When the client is ready, run this code (only once)
|
||||||
client.once('ready', () => {
|
client.once('ready', () => {
|
||||||
console.log('Ready!');
|
console.log('Ready!');
|
||||||
console.log()
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Response
|
// Response
|
||||||
client.on('messageCreate', async message => {
|
client.on('messageCreate', async message => {
|
||||||
if (message.content.startsWith("https://twitter.com/")) {
|
if (message.content.startsWith('https://twitter.com/')) {
|
||||||
var tweetURL = message.content.substring(20, message.content.length);
|
const tweetURL = message.content.substring(20, message.content.length);
|
||||||
message.delete();
|
message.suppressEmbeds(true);
|
||||||
|
|
||||||
var newmsg = "https://fxtwitter.com/" + tweetURL;
|
const newmsg = tweetParser + tweetURL;
|
||||||
message.channel.send(newmsg);
|
message.reply({ content: newmsg, allowedMentions: { repliedUser: false } });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Login to Discord with your client's token
|
// Login to Discord with your client's token
|
||||||
client.login(mySecret);
|
client.login(token);
|
||||||
|
|
Loading…
Reference in a new issue