Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 122 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"dependencies": {
"@discordjs/voice": "^0.17.0",
"@distube/ytdl-core": "^4.13.5",
"array-move": "^3.0.1",
"discord.js": "^14.15.3",
"dotenv": "^16.4.5",
Expand Down
9 changes: 6 additions & 3 deletions structs/Song.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { i18n } from "../utils/i18n";
import { videoPattern, isURL } from "../utils/patterns";

const { stream, video_basic_info } = require("play-dl");
import ytdl from "@distube/ytdl-core"

export interface SongData {
url: string;
Expand Down Expand Up @@ -60,18 +61,20 @@ export class Song {
}
}

public async makeResource(): Promise<AudioResource<Song> | void> {
public async makeResource(): Promise<AudioResource | void> {
let playStream;

const source = this.url.includes("youtube") ? "youtube" : "soundcloud";

if (source === "youtube") {
playStream = await stream(this.url);
playStream = ytdl(this.url, { filter: "audioonly", liveBuffer: 0, quality: "lowestaudio" });
}

if (!stream) return;

return createAudioResource(playStream.stream, { metadata: this, inputType: playStream.type, inlineVolume: true });
if (!playStream) throw new Error("No stream found");

return createAudioResource(playStream, { metadata: this, inlineVolume: true });
}

public startMessage() {
Expand Down