Add loop, shuffle, auto leave
All checks were successful
Subsonics - Pipeline/pipeline/head This commit looks good
All checks were successful
Subsonics - Pipeline/pipeline/head This commit looks good
This commit is contained in:
parent
c4fbc3338a
commit
87787abff7
80
src/commands/loop.js
Normal file
80
src/commands/loop.js
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName("loop")
|
||||||
|
.setDescription("Active ou désactive la répétition de la liste de lecture !"),
|
||||||
|
|
||||||
|
async execute(client, interaction) {
|
||||||
|
|
||||||
|
if(client.dictator == true ) {
|
||||||
|
|
||||||
|
if((interaction.member._roles.includes("397725956598530050") == true | interaction.member.user.id == "486943594893017119")) {
|
||||||
|
|
||||||
|
makeAction()
|
||||||
|
} else {
|
||||||
|
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setColor(0xff0303)
|
||||||
|
.setTitle('Mode Dictateur')
|
||||||
|
.setTimestamp();
|
||||||
|
const song_show = {name: "Le mode dictateur est actif !", value: "Demande au grand roi !"}
|
||||||
|
|
||||||
|
embed.addFields(song_show)
|
||||||
|
interaction.reply({embeds: [embed]})
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
makeAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function makeAction() {
|
||||||
|
|
||||||
|
if(!interaction.member.voice.channel) return interaction.reply({content:"Vous devez rejoindre un salon vocal !", ephemeral: true})
|
||||||
|
|
||||||
|
let player = client.manager.players.get(interaction.guild.id)
|
||||||
|
|
||||||
|
if(player) {
|
||||||
|
|
||||||
|
if(player.queueRepeat == false) {
|
||||||
|
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setColor(0xfff200)
|
||||||
|
.setTitle('Loop Actif!')
|
||||||
|
.setDescription("On recommence !")
|
||||||
|
.setTimestamp();
|
||||||
|
|
||||||
|
|
||||||
|
interaction.reply({embeds: [embed]})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
player.setQueueRepeat(true)
|
||||||
|
} else {
|
||||||
|
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setColor(0x3b3b3b)
|
||||||
|
.setTitle('Loop inactif!')
|
||||||
|
.setDescription("Ca suffit ! Terminez votre concert !")
|
||||||
|
.setTimestamp();
|
||||||
|
|
||||||
|
|
||||||
|
interaction.reply({embeds: [embed]})
|
||||||
|
|
||||||
|
|
||||||
|
player.setQueueRepeat(false)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
|
||||||
|
interaction.reply("**Aucune musique n'est actuellement jouée !**")
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
76
src/commands/seek.js
Normal file
76
src/commands/seek.js
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName("seek")
|
||||||
|
.setDescription("Définie la position du player dans la musique !")
|
||||||
|
.addIntegerOption(option => option.setName("duration").setDescription("En seconde")),
|
||||||
|
|
||||||
|
async execute(client, interaction) {
|
||||||
|
|
||||||
|
if(client.dictator == true ) {
|
||||||
|
|
||||||
|
if((interaction.member._roles.includes("397725956598530050") == true | interaction.member.user.id == "486943594893017119")) {
|
||||||
|
|
||||||
|
makeAction()
|
||||||
|
} else {
|
||||||
|
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setColor(0xff0303)
|
||||||
|
.setTitle('Mode Dictateur')
|
||||||
|
.setTimestamp();
|
||||||
|
const song_show = {name: "Le mode dictateur est actif !", value: "Demande au grand roi !"}
|
||||||
|
|
||||||
|
embed.addFields(song_show)
|
||||||
|
interaction.reply({embeds: [embed]})
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
makeAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function makeAction() {
|
||||||
|
|
||||||
|
if(!interaction.member.voice.channel) return interaction.reply({content:"Vous devez rejoindre un salon vocal !", ephemeral: true})
|
||||||
|
|
||||||
|
let player = client.manager.players.get(interaction.guild.id)
|
||||||
|
let duration = interaction.options.getInteger("duration")
|
||||||
|
|
||||||
|
if(player) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setColor(0xfff200)
|
||||||
|
.setTitle('On avance ou recule ?')
|
||||||
|
.setTimestamp();
|
||||||
|
|
||||||
|
|
||||||
|
interaction.reply({embeds: [embed]})
|
||||||
|
|
||||||
|
duration = duration ** 3
|
||||||
|
player.seek(duration)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
|
||||||
|
console.log(error)
|
||||||
|
interaction.reply("**Aucune musique n'est actuellement jouée !**")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
|
||||||
|
interaction.reply("**Aucune musique n'est actuellement jouée !**")
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
66
src/commands/shuffle.js
Normal file
66
src/commands/shuffle.js
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName("mix")
|
||||||
|
.setDescription("Mélange la liste de lecture !"),
|
||||||
|
|
||||||
|
async execute(client, interaction) {
|
||||||
|
|
||||||
|
if(client.dictator == true ) {
|
||||||
|
|
||||||
|
if((interaction.member._roles.includes("397725956598530050") == true | interaction.member.user.id == "486943594893017119")) {
|
||||||
|
|
||||||
|
makeAction()
|
||||||
|
} else {
|
||||||
|
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setColor(0xff0303)
|
||||||
|
.setTitle('Mode Dictateur')
|
||||||
|
.setTimestamp();
|
||||||
|
const song_show = {name: "Le mode dictateur est actif !", value: "Demande au grand roi !"}
|
||||||
|
|
||||||
|
embed.addFields(song_show)
|
||||||
|
interaction.reply({embeds: [embed]})
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
makeAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function makeAction() {
|
||||||
|
|
||||||
|
if(!interaction.member.voice.channel) return interaction.reply({content:"Vous devez rejoindre un salon vocal !", ephemeral: true})
|
||||||
|
|
||||||
|
let player = client.manager.players.get(interaction.guild.id)
|
||||||
|
|
||||||
|
if(player) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setColor(0xfff200)
|
||||||
|
.setTitle('On mélange !')
|
||||||
|
.setDescription("Toutes les musiques de la liste de lecture ont été mélangés !")
|
||||||
|
.setTimestamp();
|
||||||
|
|
||||||
|
|
||||||
|
interaction.reply({embeds: [embed]})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
player.queue.shuffle()
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
|
||||||
|
interaction.reply("**Aucune musique n'est actuellement jouée !**")
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
17
src/main.js
17
src/main.js
@ -1,3 +1,5 @@
|
|||||||
|
const { channel } = require("node:diagnostics_channel");
|
||||||
|
|
||||||
let tryTime = 0;
|
let tryTime = 0;
|
||||||
|
|
||||||
if ("ENV" in process.env) {
|
if ("ENV" in process.env) {
|
||||||
@ -70,6 +72,7 @@ const rest = new REST().setToken(config.token);
|
|||||||
client.once("ready", () => {
|
client.once("ready", () => {
|
||||||
|
|
||||||
console.log("Le meilleur groupe de musique est prêt !")
|
console.log("Le meilleur groupe de musique est prêt !")
|
||||||
|
client.user.setActivity(`beaucoup de choses !`, { type: "LISTENING" })
|
||||||
client.manager.init(client.user.id);
|
client.manager.init(client.user.id);
|
||||||
|
|
||||||
const commandManager = client.application.commands;
|
const commandManager = client.application.commands;
|
||||||
@ -85,8 +88,18 @@ client.once("ready", () => {
|
|||||||
|
|
||||||
client.on("voiceStateUpdate", (oldMember, newMember) => {
|
client.on("voiceStateUpdate", (oldMember, newMember) => {
|
||||||
|
|
||||||
console.log(oldMember, newMember)
|
let player = client.manager.players.get(oldMember.guild.id)
|
||||||
|
|
||||||
|
if(player) {
|
||||||
|
|
||||||
|
client.channels.fetch(player.options.voiceChannel).then(channel => {
|
||||||
|
|
||||||
|
if(channel.members.size <= 1) {
|
||||||
|
|
||||||
|
player.destroy()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
client.on("interactionCreate", (interaction) => {
|
client.on("interactionCreate", (interaction) => {
|
||||||
@ -145,6 +158,8 @@ client.on("raw", d => client.manager.updateVoiceState(d));
|
|||||||
|
|
||||||
// Client Manager
|
// Client Manager
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
client.login(config.token)
|
client.login(config.token)
|
||||||
|
|
||||||
tryTime = 0
|
tryTime = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user