README
@distube/soundcloud
SoundCloud extractor plugin for DisTube.js.org. Required DisTube version >= 3.0.0.
Feature
- Using SoundCloud API
- Support tracks, playlist
- Search tracks/playlists
- Faster than
youtube-dl
extractor
Installation
npm install @distube/soundcloud
Documentation
new SoundCloudPlugin()
Create a DisTube's ExtractorPlugin
static
and class
method)
SoundCloudPlugin.search(query, [type], [limit]) (Both Searches for the given query on SoundCloud.
Parameters
query
[string] Search query.type
[string]: Type of results (track
orplaylist
). Default istrack
.limit
[integer]: Limit the results. Default is10
.
Returns a
Promise<Song[]|Playlist[]>
- Returns a
Promise<Song[]>
iftype
parameter istrack
- Returns a
Promise<Playlist[]>
iftype
parameter isplaylist
- Returns a
Usage
Plugin
const Discord = require("discord.js");
const DisTube = require("distube");
const { SoundCloudPlugin } = require("@distube/soundcloud");
const client = new Discord.Client();
const distube = new DisTube(client, {
searchSongs: 10,
emitNewSongOnly: true,
plugins: [new SoundCloudPlugin()],
});
// Now distube.play can play soundcloud url.
client.on("message", message => {
if (message.author.bot) return;
if (!message.content.startsWith(config.prefix)) return;
const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
const command = args.shift();
if (command === "play") distube.play(message, args.join(" "));
});
Search
const { SoundCloudPlugin } = require("@distube/soundcloud");
SoundCloudPlugin.search("A SoundCloud Track"); // static method
// Returns an array of 10 DisTube's Songs
const scPlugin = new SoundCloudPlugin();
scPlugin.search("A SoundCloud Playlist", "playlist", 3); // class method
// Returns an array of 3 DisTube's Playlist