mirror of
https://github.com/SrIzan10/femboybot.git
synced 2026-06-06 00:56:50 +00:00
feat: easier way to download tiktok vids
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
FROM node:lts
|
||||
FROM node:lts-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt update && apt install chromium -y
|
||||
|
||||
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
|
||||
|
||||
COPY package.json ./
|
||||
|
||||
RUN npm i
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { EventType, eventModule } from "@sern/handler";
|
||||
import { Client, Message } from "discord.js";
|
||||
import tiktok from 'tiktok-scraper-ts'
|
||||
import { ActionRowBuilder, AttachmentBuilder, ButtonBuilder, Client, Message } from "discord.js";
|
||||
import axios from 'axios'
|
||||
|
||||
export default eventModule({
|
||||
@@ -20,12 +19,14 @@ export default eventModule({
|
||||
link = message.content.substring(index, endIndex);
|
||||
}
|
||||
|
||||
const scrap = await tiktok.fetchVideo(link) as tiktok.Video
|
||||
|
||||
const shorten = await axios.get(`https://cutt.ly/api/api.php?key=${process.env.CUTTLY}&short=${scrap.playURL}`).then(res => res.data)
|
||||
const scrap = await axios.get(`https://www.tikwm.com/api/?url=${link}`).then(res => res.data)
|
||||
const shorten = await axios.get(`http://chilp.it/api.php?url=${scrap.data.play}`).then(res => res.data)
|
||||
const audio = await axios.get(scrap.data.music, { responseType: 'arraybuffer' }).then(res => res.data)
|
||||
const audioAttachment = new AttachmentBuilder(audio, { name: 'audio.mp3' })
|
||||
|
||||
await message.reply({
|
||||
content: `Ok, tengo el enlace al vídeo: ${shorten.url.shortLink}`
|
||||
content: `Vídeo: ${shorten}`,
|
||||
files: [audioAttachment]
|
||||
})
|
||||
} catch {
|
||||
message.react('❌')
|
||||
|
||||
@@ -20,8 +20,7 @@
|
||||
"axios": "^0.27.2",
|
||||
"discord.js": "^14.2.0",
|
||||
"dotenv": "^16.0.3",
|
||||
"mongoose": "^6.7.2",
|
||||
"tiktok-scraper-ts": "^1.4.1"
|
||||
"mongoose": "^6.7.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^17.0.25",
|
||||
|
||||
Reference in New Issue
Block a user