Skip to content

Commit 555ea1b

Browse files
committed
feat(audio): Support for soundcloud and spotify added
1 parent 2198958 commit 555ea1b

3 files changed

Lines changed: 20 additions & 14 deletions

File tree

src/modules/audio/audio.es6

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
import utils from '../utils.es6';
22

3+
import SoundCloud from './soundcloud.es6';
4+
import Spotify from './spotify.es6';
5+
36
class Audio{
4-
constructor(input,options, embeds){
7+
constructor(input, output, options, embeds) {
58
this.input = input;
9+
this.output = output;
610
this.options = options;
711
this.embeds = embeds;
812
}
913

10-
process(){
11-
let match;
12-
while((match = utils.matches(this.regex, this.input)) !== null){
13-
let text = this.template(match[0]);
14-
this.embeds.push({
15-
text : text,
16-
index : match.index
17-
})
14+
async process(){
15+
try{
16+
let output = this.output;
17+
let embeds = this.embeds;
18+
embeds = utils.ifEmbed(this.options, 'soundcloud') ? await (new SoundCloud(this.input, this.options, embeds).process()) : embeds;
19+
embeds = utils.ifEmbed(this.options, 'spotify') ? await (new Spotify(this.input, this.options, embeds).process()) : embeds;
20+
21+
return [output, embeds];
22+
}catch(error){
23+
console.log(error);
1824
}
19-
return this.embeds;
2025
}
2126
}
2227

2328
module.exports = Audio;
29+

src/modules/audio/soundcloud.es6

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import Audio from './audio.es6';
1+
import Base from '../base.es6';
22

3-
class SoundCloud extends Audio{
3+
class SoundCloud extends Base{
44
constructor(input, options, embeds) {
55
super(input, options, embeds);
66
this.regex = /soundcloud.com\/[a-zA-Z0-9-_]+\/[a-zA-Z0-9-_]+/gi;

src/modules/audio/spotify.es6

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import Audio from './audio.es6';
1+
import Base from '../base.es6';
22

3-
class Spotify extends Audio{
3+
class Spotify extends Base{
44
constructor(input, options, embeds) {
55
super(input, options, embeds);
66
this.regex = /spotify.com\/track\/[a-zA-Z0-9_]+/gi;

0 commit comments

Comments
 (0)