This repository has been archived by the owner on Sep 27, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const { ContextMenuInteraction, MessageEmbed } = require('discord.js'); | ||
|
||
module.exports = { | ||
name: "Context | Stop", | ||
type: 3, | ||
/** | ||
* @param {ContextMenuInteraction} interaction | ||
*/ | ||
run: async (interaction, client, user, language) => { | ||
await interaction.deferReply({ ephemeral: false }); | ||
const msg = await interaction.editReply(`${client.i18n.get(language, "music", "leave_loading")}`); | ||
|
||
const player = client.manager.get(interaction.guild.id); | ||
if (!player) return msg.edit(`${client.i18n.get(language, "noplayer", "no_player")}`); | ||
const { channel } = interaction.member.voice; | ||
if (!channel || interaction.member.voice.channel !== interaction.guild.me.voice.channel) return msg.edit(`${client.i18n.get(language, "noplayer", "no_voice")}`); | ||
|
||
await player.destroy(); | ||
|
||
const embed = new MessageEmbed() | ||
.setDescription(`${client.i18n.get(language, "music", "leave_msg", { | ||
channel: channel.name | ||
})}`) | ||
.setColor(client.color); | ||
|
||
msg.edit({ content: " ", embeds: [embed] }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const { ContextMenuInteraction, MessageEmbed } = require('discord.js'); | ||
|
||
module.exports = { | ||
name: "Context | Loop", | ||
type: 3, | ||
/** | ||
* @param {ContextMenuInteraction} interaction | ||
*/ | ||
run: async (interaction, client, user, language) => { | ||
await interaction.deferReply({ ephemeral: false }); | ||
const msg = await interaction.editReply(`${client.i18n.get(language, "music", "loopall_loading")}`); | ||
|
||
const player = client.manager.get(interaction.guild.id); | ||
if (!player) return msg.edit(`${client.i18n.get(language, "noplayer", "no_player")}`); | ||
const { channel } = interaction.member.voice; | ||
if (!channel || interaction.member.voice.channel !== interaction.guild.me.voice.channel) return msg.edit(`${client.i18n.get(language, "noplayer", "no_voice")}`); | ||
|
||
if (player.queueRepeat === true) { | ||
player.setQueueRepeat(false) | ||
|
||
const unloopall = new MessageEmbed() | ||
.setDescription(`${client.i18n.get(language, "music", "unloopall")}`) | ||
.setColor(client.color); | ||
|
||
return msg.edit({ content: ' ', embeds: [unloopall] }); | ||
} | ||
else { | ||
player.setQueueRepeat(true); | ||
|
||
const loopall = new MessageEmbed() | ||
.setDescription(`${client.i18n.get(language, "music", "loopall")}`) | ||
.setColor(client.color); | ||
|
||
return msg.edit({ content: ' ', embeds: [loopall] }); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
const { ContextMenuInteraction, MessageEmbed, Permissions } = require('discord.js'); | ||
const { convertTime } = require("../../structures/convert.js"); | ||
|
||
module.exports = { | ||
name: "Context | Play", | ||
type: 3, | ||
/** | ||
* @param {ContextMenuInteraction} interaction | ||
*/ | ||
run: async (interaction, client, user, language) => { | ||
await interaction.deferReply({ ephemeral: false }); | ||
|
||
const value = (interaction.channel.messages.cache.get(interaction.targetId).content ?? await interaction.channel.messages.fetch(interaction.targetId)); | ||
if (!value.startsWith('https')) return interaction.editReply(`${client.i18n.get(language, "music", "play_startwith")}`); | ||
|
||
const msg = await interaction.editReply(`${client.i18n.get(language, "music", "play_loading")}`); | ||
|
||
const { channel } = interaction.member.voice; | ||
if (!channel) return msg.edit(`${client.i18n.get(language, "music", "play_invoice")}`); | ||
if (!channel.permissionsFor(interaction.guild.me).has(Permissions.FLAGS.CONNECT)) return msg.edit(`${client.i18n.get(language, "music", "play_join")}`); | ||
if (!channel.permissionsFor(interaction.guild.me).has(Permissions.FLAGS.SPEAK)) return msg.edit(`${client.i18n.get(language, "music", "play_speak")}`); | ||
|
||
const player = await client.manager.create({ | ||
guild: interaction.guild.id, | ||
voiceChannel: interaction.member.voice.channel.id, | ||
textChannel: interaction.channel.id, | ||
selfDeafen: true, | ||
}); | ||
|
||
const state = player.state; | ||
if (state != "CONNECTED") await player.connect(); | ||
const res = await client.manager.search(value, interaction.user); | ||
if(res.loadType != "NO_MATCHES") { | ||
if(res.loadType == "TRACK_LOADED") { | ||
player.queue.add(res.tracks[0]); | ||
const embed = new MessageEmbed() | ||
.setDescription(`${client.i18n.get(language, "music", "play_track", { | ||
title: res.tracks[0].title, | ||
url: res.tracks[0].uri, | ||
duration: convertTime(res.tracks[0].duration, true), | ||
request: res.tracks[0].requester | ||
})}`) | ||
.setColor(client.color) | ||
msg.edit({ content: " ", embeds: [embed] }); | ||
if(!player.playing) player.play(); | ||
} | ||
else if(res.loadType == "PLAYLIST_LOADED") { | ||
player.queue.add(res.tracks) | ||
const embed = new MessageEmbed() | ||
.setDescription(`${client.i18n.get(language, "music", "play_playlist", { | ||
title: res.playlist.name, | ||
url: value, | ||
duration: convertTime(res.playlist.duration), | ||
songs: res.tracks.length, | ||
request: res.tracks[0].requester | ||
})}`) | ||
.setColor(client.color) | ||
msg.edit({ content: " ", embeds: [embed] }); | ||
if(!player.playing) player.play(); | ||
} | ||
else if(res.loadType == "SEARCH_RESULT") { | ||
player.queue.add(res.tracks[0]); | ||
const embed = new MessageEmbed() | ||
.setDescription(`${client.i18n.get(language, "music", "play_result", { | ||
title: res.tracks[0].title, | ||
url: res.tracks[0].uri, | ||
duration: convertTime(res.tracks[0].duration, true), | ||
request: res.tracks[0].requester | ||
})}`) | ||
.setColor(client.color) | ||
msg.edit({ content: " ", embeds: [embed] }); | ||
if(!player.playing) player.play(); | ||
} | ||
else if(res.loadType == "LOAD_FAILED") { | ||
msg.edit(`${client.i18n.get(language, "music", "play_fail")}`); | ||
player.destroy(); | ||
} | ||
} | ||
else { | ||
msg.edit(`${client.i18n.get(language, "music", "play_match")}`); | ||
player.destroy(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const { ContextMenuInteraction, MessageEmbed } = require('discord.js'); | ||
|
||
module.exports = { | ||
name: "Context | Shuffle", | ||
type: 3, | ||
/** | ||
* @param {ContextMenuInteraction} interaction | ||
*/ | ||
run: async (interaction, client, user, language) => { | ||
await interaction.deferReply({ ephemeral: false }); | ||
const msg = await interaction.editReply(`${client.i18n.get(language, "music", "shuffle_loading")}`); | ||
|
||
const player = client.manager.get(interaction.guild.id); | ||
if (!player) return msg.edit(`${client.i18n.get(language, "noplayer", "no_player")}`); | ||
const { channel } = interaction.member.voice; | ||
if (!channel || interaction.member.voice.channel !== interaction.guild.me.voice.channel) return msg.edit(`${client.i18n.get(language, "noplayer", "no_voice")}`); | ||
|
||
await player.queue.shuffle(); | ||
|
||
const shuffle = new MessageEmbed() | ||
.setDescription(`${client.i18n.get(language, "music", "shuffle_msg")}`) | ||
.setColor(client.color); | ||
|
||
msg.edit({ content: " ", embeds: [shuffle] }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const { ContextMenuInteraction, MessageEmbed } = require('discord.js'); | ||
|
||
module.exports = { | ||
name: "Context | Skip", | ||
type: 3, | ||
/** | ||
* @param {ContextMenuInteraction} interaction | ||
*/ | ||
run: async (interaction, client, user, language) => { | ||
await interaction.deferReply({ ephemeral: false }); | ||
const msg = await interaction.editReply(`${client.i18n.get(language, "music", "skip_loading")}`); | ||
|
||
const player = client.manager.get(interaction.guild.id); | ||
if (!player) return msg.edit(`${client.i18n.get(language, "noplayer", "no_player")}`); | ||
const { channel } = interaction.member.voice; | ||
if (!channel || interaction.member.voice.channel !== interaction.guild.me.voice.channel) return msg.edit(`${client.i18n.get(language, "noplayer", "no_voice")}`); | ||
|
||
await player.stop(); | ||
|
||
const skipped = new MessageEmbed() | ||
.setDescription(`${client.i18n.get(language, "music", "skip_msg")}`) | ||
.setColor(client.color); | ||
|
||
msg.edit({ content: " ", embeds: [skipped] }); | ||
} | ||
} |