mirror of
https://github.com/LeviSnoot/MediaFixer.git
synced 2024-12-02 18:00:02 +01:00
TikTok support
This commit is contained in:
parent
c7e9f1ba5b
commit
bb33055946
3 changed files with 114 additions and 97 deletions
|
@ -46,11 +46,12 @@ Example:
|
||||||
|
|
||||||
"port": "4000",
|
"port": "4000",
|
||||||
|
|
||||||
You can change which service to use for parsing Twitter and Instagram links. By default fxtwitter and ddinstagram are used, but you can change this to any of your choosing.
|
You can change which service to use for parsing links, simply edit the corresponding values with a service that offers the functionality.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
"tweetParser": "https://twittpr.com/",
|
"tweetParser": "https://twittpr.com/",
|
||||||
"instaParser": "https://ddinstagram.com/"
|
"instaParser": "https://ddinstagram.com/",
|
||||||
|
"tiktokParser": "https://www.vxtiktok.com/"
|
||||||
|
|
||||||
It's important the full base url is in the string, like the example above, otherwise you may run into issues.
|
It's important the full base url is in the string, like the example above, otherwise you may run into issues.
|
||||||
|
|
152
index.js
152
index.js
|
@ -1,92 +1,112 @@
|
||||||
const { Client, GatewayIntentBits } = require('discord.js');
|
|
||||||
const {
|
const {
|
||||||
token,
|
Client,
|
||||||
port,
|
GatewayIntentBits
|
||||||
tweetParser,
|
} = require('discord.js');
|
||||||
instaParser,
|
const {
|
||||||
tiktokParser,
|
token,
|
||||||
|
port,
|
||||||
|
tweetParser,
|
||||||
|
instaParser,
|
||||||
|
tiktokParser,
|
||||||
} = require('./config.json');
|
} = require('./config.json');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
// Create a new client instance
|
// Create a new client instance
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
intents: [
|
intents: [
|
||||||
GatewayIntentBits.Guilds,
|
GatewayIntentBits.Guilds,
|
||||||
GatewayIntentBits.GuildMessages,
|
GatewayIntentBits.GuildMessages,
|
||||||
GatewayIntentBits.MessageContent,
|
GatewayIntentBits.MessageContent,
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
http.createServer((req, res) => {
|
http.createServer((req, res) => {
|
||||||
res.writeHead(200, { 'Content-type': 'text/plain' });
|
res.writeHead(200, {
|
||||||
res.write('Hey');
|
'Content-type': 'text/plain'
|
||||||
res.end();
|
});
|
||||||
|
res.write('Hey');
|
||||||
|
res.end();
|
||||||
}).listen(port);
|
}).listen(port);
|
||||||
|
|
||||||
// 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!');
|
||||||
});
|
});
|
||||||
|
|
||||||
// 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/')) {
|
||||||
const tweetURL = message.content.substring(20, message.content.length);
|
const tweetURL = message.content.substring(20, message.content.length);
|
||||||
message.suppressEmbeds(true);
|
message.suppressEmbeds(true);
|
||||||
|
const newmsg = tweetParser + tweetURL;
|
||||||
const newmsg = tweetParser + tweetURL;
|
message.reply({
|
||||||
message.reply({ content: newmsg, allowedMentions: { repliedUser: false } });
|
content: newmsg,
|
||||||
}
|
allowedMentions: {
|
||||||
|
repliedUser: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('messageCreate', async message => {
|
client.on('messageCreate', async message => {
|
||||||
if (message.content.startsWith('https://mobile.twitter.com/')) {
|
if(message.content.startsWith('https://mobile.twitter.com/')) {
|
||||||
const mobiletweetURL = message.content.substring(27, message.content.length);
|
const mobiletweetURL = message.content.substring(27, message.content.length);
|
||||||
message.suppressEmbeds(true);
|
message.suppressEmbeds(true);
|
||||||
|
const newmsg = tweetParser + mobiletweetURL;
|
||||||
const newmsg = tweetParser + mobiletweetURL;
|
message.reply({
|
||||||
message.reply({ content: newmsg, allowedMentions: { repliedUser: false } });
|
content: newmsg,
|
||||||
}
|
allowedMentions: {
|
||||||
|
repliedUser: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('messageCreate', async message => {
|
client.on('messageCreate', async message => {
|
||||||
if (message.content.startsWith('https://instagram.com/')) {
|
if(message.content.startsWith('https://instagram.com/')) {
|
||||||
const instaURL = message.content.substring(22, message.content.length);
|
const instaURL = message.content.substring(22, message.content.length);
|
||||||
message.suppressEmbeds(true);
|
message.suppressEmbeds(true);
|
||||||
|
const newmsg = instaParser + instaURL;
|
||||||
const newmsg = instaParser + instaURL;
|
message.reply({
|
||||||
message.reply({ content: newmsg, allowedMentions: { repliedUser: false } });
|
content: newmsg,
|
||||||
}
|
allowedMentions: {
|
||||||
|
repliedUser: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('messageCreate', async message => {
|
client.on('messageCreate', async message => {
|
||||||
if (message.content.startsWith('https://www.instagram.com/')) {
|
if(message.content.startsWith('https://www.instagram.com/')) {
|
||||||
const instaURL2 = message.content.substring(26, message.content.length);
|
const instaURL2 = message.content.substring(26, message.content.length);
|
||||||
message.suppressEmbeds(true);
|
message.suppressEmbeds(true);
|
||||||
|
const newmsg = instaParser + instaURL2;
|
||||||
const newmsg = instaParser + instaURL2;
|
message.reply({
|
||||||
message.reply({ content: newmsg, allowedMentions: { repliedUser: false } });
|
content: newmsg,
|
||||||
}
|
allowedMentions: {
|
||||||
|
repliedUser: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('messageCreate', async message => {
|
client.on('messageCreate', async message => {
|
||||||
if (message.content.startsWith('https://tiktok.com/')) {
|
if(message.content.startsWith('https://tiktok.com/')) {
|
||||||
const tiktokURL = message.content.substring(19, message.content.length);
|
const tiktokURL = message.content.substring(19, message.content.length);
|
||||||
message.suppressEmbeds(true);
|
message.suppressEmbeds(true);
|
||||||
|
const newmsg = tiktokParser + tiktokURL;
|
||||||
const newmsg = tiktokParser + tiktokURL;
|
message.reply({
|
||||||
message.reply({ content: newmsg, allowedMentions: { repliedUser: false } });
|
content: newmsg,
|
||||||
}
|
allowedMentions: {
|
||||||
|
repliedUser: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('messageCreate', async message => {
|
client.on('messageCreate', async message => {
|
||||||
if (message.content.startsWith('https://www.tiktok.com/')) {
|
if(message.content.startsWith('https://www.tiktok.com/')) {
|
||||||
const tiktokURL2 = message.content.substring(23, message.content.length);
|
const tiktokURL2 = message.content.substring(23, message.content.length);
|
||||||
message.suppressEmbeds(true);
|
message.suppressEmbeds(true);
|
||||||
|
const newmsg = tiktokParser + tiktokURL2;
|
||||||
const newmsg = tiktokParser + tiktokURL2;
|
message.reply({
|
||||||
message.reply({ content: newmsg, allowedMentions: { repliedUser: false } });
|
content: newmsg,
|
||||||
}
|
allowedMentions: {
|
||||||
|
repliedUser: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Login to Discord with your client's token
|
// Login to Discord with your client's token
|
||||||
client.login(token);
|
client.login(token);
|
54
package.json
54
package.json
|
@ -1,30 +1,26 @@
|
||||||
{
|
{
|
||||||
"name": "mediafixer",
|
"name": "mediafixer",
|
||||||
"version": "1.2.5",
|
"version": "1.2.5",
|
||||||
"description": "Fixes broken twitter embeds by replying with a reformatted link.",
|
"description": "Fixes broken twitter embeds by replying with a reformatted link.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/LeviSnoot/MediaFixer.git"
|
"url": "git+https://github.com/LeviSnoot/MediaFixer.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": ["discord", "twitter", "embeds"],
|
||||||
"discord",
|
"author": "Yber0 & LeviSnoot",
|
||||||
"twitter",
|
"license": "ISC",
|
||||||
"embeds"
|
"dependencies": {
|
||||||
],
|
"discord.js": "^14.4.0"
|
||||||
"author": "Yber0 & LeviSnoot",
|
},
|
||||||
"license": "ISC",
|
"bugs": {
|
||||||
"dependencies": {
|
"url": "https://github.com/LeviSnoot/MediaFixer/issues"
|
||||||
"discord.js": "^14.4.0"
|
},
|
||||||
},
|
"homepage": "https://github.com/LeviSnoot/MediaFixer#readme",
|
||||||
"bugs": {
|
"devDependencies": {
|
||||||
"url": "https://github.com/LeviSnoot/MediaFixer/issues"
|
"eslint": "^8.23.1"
|
||||||
},
|
}
|
||||||
"homepage": "https://github.com/LeviSnoot/MediaFixer#readme",
|
}
|
||||||
"devDependencies": {
|
|
||||||
"eslint": "^8.23.1"
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue