Skip to content
This repository was archived by the owner on Sep 28, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions commands/Music/loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ module.exports = {
async execute(interaction, client, locale) {
if (!interaction.member.voice.channel) return await interaction.reply({ embeds: [new EmbedBuilder().setColor(Colors.Yellow).setTitle(locale.getLocaleString("command.join.userNotInVoiceChannel"))] });

let player = client.moon.players.create({
let player = client.moon.createPlayer({
guildId: interaction.guild.id,
voiceChannel: interaction.member.voice.channel.id,
textChannel: interaction.channel.id,
autoLeave: true
voiceChannelId: interaction.member.voice.channel.id,
textChannelId: interaction.channel.id,
autoLeave: true,
autoPlay: true
});

if (!player.connected) {
Expand Down
9 changes: 5 additions & 4 deletions commands/Music/pause.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ module.exports = {
async execute(interaction, client, locale) {
if (!interaction.member.voice.channel) return await interaction.reply({ embeds: [new EmbedBuilder().setColor(Colors.Yellow).setTitle(locale.getLocaleString("command.join.userNotInVoiceChannel"))] });

let player = client.moon.players.create({
let player = client.moon.createPlayer({
guildId: interaction.guild.id,
voiceChannel: interaction.member.voice.channel.id,
textChannel: interaction.channel.id,
autoLeave: true
voiceChannelId: interaction.member.voice.channel.id,
textChannelId: interaction.channel.id,
autoLeave: true,
autoPlay: true
});

if (!player.connected) {
Expand Down
15 changes: 5 additions & 10 deletions commands/Music/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,12 @@ module.exports = {

let query = interaction.options.getString("query");

const region = interaction.member.voice.channel.rtcRegion;

const server = client.moon._nodes.find(node => node.regions.includes(region)) || client.moon._nodes[Math.floor(Math.random() * client.moon._nodes.length)];

let player = client.moon.players.create({
let player = client.moon.createPlayer({
guildId: interaction.guild.id,
voiceChannel: interaction.member.voice.channel.id,
textChannel: interaction.channel.id,
voiceChannelId: interaction.member.voice.channel.id,
textChannelId: interaction.channel.id,
autoLeave: true,
node: server.identifier
autoPlay: true
});

if (isYouTubeUrl(query)) {
Expand Down Expand Up @@ -112,9 +108,8 @@ module.exports = {
]
});
} else if (res.loadType === "playlist") {
trackEmbed.setTitle(`▶️ ${res.playlistInfo.name}`)
trackEmbed.setTitle(`▶️ ${res.data.info.name}`)
.addFields(
{ name: locale.getLocaleString("command.play.duration"), value: `\`\`\`${convertToHHMMSS(msToSec(res.playlistInfo.duration))}\`\`\``, inline: true },
{ name: locale.getLocaleString("command.play.voiceChannel"), value: `<#${interaction.member.voice.channel.id}>`, inline: true },
{ name: locale.getLocaleString("command.play.owner"), value: `<@${interaction.user.id}>`, inline: true }
);
Expand Down
21 changes: 13 additions & 8 deletions commands/Music/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ module.exports = {
async execute(interaction, client, locale) {
if (!interaction.member.voice.channel) return await interaction.reply({ embeds: [new EmbedBuilder().setColor(Colors.Yellow).setTitle(locale.getLocaleString("command.join.userNotInVoiceChannel"))] });

let player = client.moon.players.create({
let player = client.moon.createPlayer({
guildId: interaction.guild.id,
voiceChannel: interaction.member.voice.channel.id,
textChannel: interaction.channel.id,
autoLeave: true
voiceChannelId: interaction.member.voice.channel.id,
textChannelId: interaction.channel.id,
autoLeave: true,
autoPlay: true
});

if (!player.connected) {
Expand All @@ -34,7 +35,7 @@ module.exports = {
});
}

const queue = player.queue.getQueue();
const queue = player.queue.tracks;

if (queue.length == 0) return interaction.reply({
embeds: [
Expand Down Expand Up @@ -115,9 +116,13 @@ module.exports = {
});

collector.on("end", () => {
message.edit({
components: []
});
try {
message.edit({
components: []
});
} catch (err) {
console.error(err);
}
});
}
};
9 changes: 5 additions & 4 deletions commands/Music/resume.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ module.exports = {
async execute(interaction, client, locale) {
if (!interaction.member.voice.channel) return await interaction.reply({ embeds: [new EmbedBuilder().setColor(Colors.Yellow).setTitle(locale.getLocaleString("command.join.userNotInVoiceChannel"))] });

let player = client.moon.players.create({
let player = client.moon.createPlayer({
guildId: interaction.guild.id,
voiceChannel: interaction.member.voice.channel.id,
textChannel: interaction.channel.id,
autoLeave: true
voiceChannelId: interaction.member.voice.channel.id,
textChannelId: interaction.channel.id,
autoLeave: true,
autoPlay: true
});

if (!player.connected) {
Expand Down
11 changes: 6 additions & 5 deletions commands/Music/skip.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ module.exports = {

await interaction.deferReply();

let player = client.moon.players.create({
let player = client.moon.createPlayer({
guildId: interaction.guild.id,
voiceChannel: interaction.member.voice.channel.id,
textChannel: interaction.channel.id,
autoLeave: true
voiceChannelId: interaction.member.voice.channel.id,
textChannelId: interaction.channel.id,
autoLeave: true,
autoPlay: true
});

if (!player.connected) {
Expand All @@ -45,7 +46,7 @@ module.exports = {
ephemeral: true
});

const queue = player.queue.getQueue();
const queue = player.queue.tracks;

if (queue.length == 0) return await interaction.editReply({
embeds: [
Expand Down
9 changes: 5 additions & 4 deletions commands/Music/volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ module.exports = {
async execute(interaction, client, locale) {
if (!interaction.member.voice.channel) return await interaction.reply({ embeds: [new EmbedBuilder().setColor(Colors.Yellow).setTitle(locale.getLocaleString("command.join.userNotInVoiceChannel"))] });

let player = client.moon.players.create({
let player = client.moon.createPlayer({
guildId: interaction.guild.id,
voiceChannel: interaction.member.voice.channel.id,
textChannel: interaction.channel.id,
autoLeave: true
voiceChannelId: interaction.member.voice.channel.id,
textChannelId: interaction.channel.id,
autoLeave: true,
autoPlay: true
});

if (!player.connected) {
Expand Down
9 changes: 5 additions & 4 deletions commands/Voice/join.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ module.exports = {
async execute(interaction, client, locale) {
if (!interaction.member.voice.channel) return await interaction.reply({ embeds: [new EmbedBuilder().setColor(Colors.Yellow).setTitle(locale.getLocaleString("command.join.userNotInVoiceChannel"))] });

let player = client.moon.players.create({
let player = client.moon.createPlayer({
guildId: interaction.guild.id,
voiceChannel: interaction.member.voice.channel.id,
textChannel: interaction.channel.id,
autoLeave: true
voiceChannelId: interaction.member.voice.channel.id,
textChannelId: interaction.channel.id,
autoLeave: true,
autoPlay: true
});

if (!player.connected) {
Expand Down
10 changes: 5 additions & 5 deletions commands/Voice/leave.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ module.exports = {
async execute(interaction, client, locale) {
if (!interaction.member.voice.channel) return await interaction.reply({ embeds: [new EmbedBuilder().setColor(Colors.Yellow).setTitle(locale.getLocaleString("command.join.userNotInVoiceChannel"))] });

let player = client.moon.players.create({
let player = client.moon.createPlayer({
guildId: interaction.guild.id,
voiceChannel: interaction.member.voice.channel.id,
textChannel: interaction.channel.id,
autoLeave: true
voiceChannelId: interaction.member.voice.channel.id,
textChannelId: interaction.channel.id,
autoLeave: true,
autoPlay: true
});

if (!player.connected) {
player.destroy();
return interaction.reply({
embeds: [
new EmbedBuilder()
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ api.get("/guilds", async (req, res) => {
if (guilds.length < 200) break;

after = guilds[guilds.length - 1].id;
}
};

return res.status(200).json({
total: guildsList.length,
list: guildsList
});
} catch (error) {
console.error(error);
return res.status(500).json({ error: 'An error occurred while fetching guilds' });
return res.status(500).json({ error: "An error occurred while fetching guilds" });
}
});

Expand Down
22 changes: 16 additions & 6 deletions moonlink.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { EmbedBuilder, Colors } = require("discord.js");
const { MoonlinkManager } = require("moonlink.js");
const { Manager } = require("moonlink.js");
const { version } = require("./package.json");
const Locale = require("./class/Locale");
const LocaleSchema = require("./schemas/Locale");

Expand Down Expand Up @@ -31,8 +32,17 @@ async function getLocale(userId) {
* @param {import("discord.js").Client} client - The Discord client.
*/
function initializationMoonlink(client) {
const moon = new MoonlinkManager(JSON.parse(process.env.NODES), {}, (guild, sPayload) => {
client.guilds.cache.get(guild).shard.send(JSON.parse(sPayload));
const moon = new Manager({
nodes: JSON.parse(process.env.NODES),
options: {
defaultPlatformSearch: "spsearch",
sortTypeNode: "playingPlayers",
clientName: `HStudio/${version}`
},
sendPayload: (guildId, payload) => {
const guild = client.guilds.cache.get(guildId);
if (guild) guild.shard.send(JSON.parse(payload));
}
});

moon.on("nodeCreate", (node) => {
Expand Down Expand Up @@ -60,14 +70,14 @@ function initializationMoonlink(client) {
moon.on("trackStart", async (player, track) => {
let sourceIcon = ":arrow_forward:";

const locale = await getLocale(track.requester);
const locale = await getLocale(track.requestedBy);

try {
if (track.sourceName == "spotify") {
sourceIcon = "<:spotify:1264178732739072020>";

client.channels.cache
.get(player.textChannel)
.get(player.textChannelId)
.send({
embeds: [
new EmbedBuilder()
Expand All @@ -77,7 +87,7 @@ function initializationMoonlink(client) {
});
} else {
client.channels.cache
.get(player.textChannel)
.get(player.textChannelId)
.send({
embeds: [
new EmbedBuilder()
Expand Down
Loading