Version 0.4.0-alpha1
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "chopin-backend",
|
"name": "chopin-backend",
|
||||||
"version": "0.3.0",
|
"version": "0.4.0",
|
||||||
"description": "Discord Bot for music - Fetching everywhere !",
|
"description": "Discord Bot for music - Fetching everywhere !",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"nodemonConfig": {
|
"nodemonConfig": {
|
||||||
|
@@ -13,6 +13,8 @@ async function play(instance, song) {
|
|||||||
inputType: StreamType.Arbitrary
|
inputType: StreamType.Arbitrary
|
||||||
}) // Remplace par ton fichier audio
|
}) // Remplace par ton fichier audio
|
||||||
|
|
||||||
|
|
||||||
|
instance.setCurrentResource(resource)
|
||||||
player.play(resource);
|
player.play(resource);
|
||||||
instance.connection.subscribe(player);
|
instance.connection.subscribe(player);
|
||||||
clog.log(`GUILD : ${instance.guildId} - Lecture de la musique (Media): ${song.title} - id : ${song.id}`)
|
clog.log(`GUILD : ${instance.guildId} - Lecture de la musique (Media): ${song.title} - id : ${song.id}`)
|
||||||
|
@@ -15,7 +15,7 @@ async function play(instance, song) {
|
|||||||
|
|
||||||
const stream = await soundcloud.util.streamTrack(song.url)
|
const stream = await soundcloud.util.streamTrack(song.url)
|
||||||
var resource = await createAudioResource(stream)
|
var resource = await createAudioResource(stream)
|
||||||
|
instance.setCurrentResource(resource)
|
||||||
player.play(resource);
|
player.play(resource);
|
||||||
instance.connection.subscribe(player);
|
instance.connection.subscribe(player);
|
||||||
clog.log(`GUILD : ${instance.guildId} - Lecture de la musique (Soundcloud): ${song.title} - id : ${song.id}`)
|
clog.log(`GUILD : ${instance.guildId} - Lecture de la musique (Soundcloud): ${song.title} - id : ${song.id}`)
|
||||||
|
@@ -22,7 +22,7 @@ async function play(instance, song) {
|
|||||||
// Add compressor to the audio resource
|
// Add compressor to the audio resource
|
||||||
var resource = createAudioResource(stream);
|
var resource = createAudioResource(stream);
|
||||||
|
|
||||||
|
instance.setCurrentResource(resource)
|
||||||
|
|
||||||
player.play(resource);
|
player.play(resource);
|
||||||
instance.connection.subscribe(player);
|
instance.connection.subscribe(player);
|
||||||
|
@@ -17,6 +17,7 @@ class Player {
|
|||||||
guildId;
|
guildId;
|
||||||
channelId;
|
channelId;
|
||||||
queue;
|
queue;
|
||||||
|
currentResource;
|
||||||
constructor(guildId) {
|
constructor(guildId) {
|
||||||
if(this.guildId === null) {
|
if(this.guildId === null) {
|
||||||
clog.error("Impossible de créer un Player, car guildId est null")
|
clog.error("Impossible de créer un Player, car guildId est null")
|
||||||
@@ -177,6 +178,23 @@ class Player {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setDuration(duration) {
|
||||||
|
if(this.checkConnection()) return
|
||||||
|
if(this.queue.current == null) return
|
||||||
|
if(this.currentResource == null) return
|
||||||
|
var maxduration = this.queue.current.duration
|
||||||
|
if(duration > maxduration) return
|
||||||
|
this.player.stop(); // Arrête la lecture actuelle
|
||||||
|
this.player.play(this.currentResource, {
|
||||||
|
startTime: duration * 1000 // Convertit le timecode en millisecondes
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
setCurrentResource(value) {
|
||||||
|
this.currentResource = value;
|
||||||
|
}
|
||||||
|
|
||||||
async skip() {
|
async skip() {
|
||||||
|
|
||||||
if(this.checkConnection()) return "no_music"
|
if(this.checkConnection()) return "no_music"
|
||||||
|
Reference in New Issue
Block a user