Музыка перенесена

Пакет discord-player на замену distube
Фиксики и мелкие правки, как обычно
This commit is contained in:
JonnyBro 2022-08-03 20:57:54 +05:00
parent ed8cc4f0be
commit b546036abc
25 changed files with 1282 additions and 1477 deletions

View file

@ -1,115 +0,0 @@
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"),
{ sendPaginatedEmbeds } = require("discord.js-embed-pagination");
class Queue extends BaseCommand {
/**
*
* @param {import("../base/JaBa")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("queue")
.setDescription(client.translate("music/queue:DESCRIPTION")),
aliases: [],
dirname: __dirname,
guildOnly: true,
ownerOnly: false
});
}
/**
*
* @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Array} data
*/
async execute(client, interaction) {
const voice = interaction.member.voice.channel;
const queue = client.player.getQueue(interaction);
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL");
if (!queue) return interaction.error("music/play:NOT_PLAYING");
if (queue.songs.length === 1) {
const embed = new EmbedBuilder()
.setAuthor({
name: interaction.translate("music/queue:TITLE"),
iconURL: interaction.guild.iconURL()
})
.addFields([
{
name: interaction.translate("music/nowplaying:CURRENTLY_PLAYING"),
value: `[${queue.songs[0].name}](${queue.songs[0].url})\n*${interaction.translate("music/queue:ADDED")} ${queue.songs[0].member}*\n`
}
])
.setColor(client.config.embed.color);
return interaction.reply({
embeds: [embed]
});
}
const songs = queue.songs.slice(1, queue.songs.length).map(song => {
return {
name: interaction.translate("music/queue:TITLE"),
value: `**${queue.songs.indexOf(song)}**. [${song.name}](${song.url})\n*${interaction.translate("music/queue:ADDED")} ${song.member}*\n`
};
});
const pages = songs.map(song => {
new EmbedBuilder()
.setAuthor({
name: interaction.translate("music/queue:TITLE"),
iconURL: interaction.guild.iconURL()
})
.setColor(client.config.embed.color)
.addFields([
// {
// name: interaction.translate("music/nowplaying:CURRENTLY_PLAYING"),
// value: `[${queue.songs[0].name}](${queue.songs[0].url})\n*${interaction.translate("music/queue:ADDED")} ${queue.songs[0].member}*\n`
// },
...songs
]);
});
sendPaginatedEmbeds(interaction, pages, {
previousLabel: interaction.translate("music/queue:"),
nextLabel: interaction.translate("music/queue:"),
pageLabel: interaction.translate("music/queue:"),
content: `${interaction.translate("music/nowplaying:CURRENTLY_PLAYING")}\n[${queue.songs[0].name}](${queue.songs[0].url})\n*${interaction.translate("music/queue:ADDED")} ${queue.songs[0].member}*\n`,
showPagePosition: true,
time: 120000
});
// FieldsEmbed.embed
// .setColor(client.config.embed.color)
// .setAuthor({
// name: interaction.translate("music/queue:TITLE"),
// iconURL: interaction.guild.iconURL()
// })
// .addFields([
// {
// name: interaction.translate("music/nowplaying:CURRENTLY_PLAYING"),
// value: `[${queue.songs[0].name}](${queue.songs[0].url})\n*${interaction.translate("music/queue:ADDED")} ${queue.songs[0].member}*\n`
// }
// ]);
// FieldsEmbed
// .setArray(queue.songs[1] ? queue.songs.slice(1, queue.songs.length) : [])
// .setAuthorizedUsers([interaction.member.id])
// .setChannel(interaction.channel)
// .setElementsPerPage(5)
// .setDeleteOnTimeout(true)
// .setPageIndicator(true)
// .formatField(interaction.translate("music/queue:TITLE"), (track) => `**${queue.songs.indexOf(track)}**. [${track.name}](${track.url})\n*${interaction.translate("music/queue:ADDED")} ${track.member}*\n`)
// .build();
}
}
module.exports = Queue;

View file

@ -1,8 +1,9 @@
const { EmbedBuilder, Client, Collection, SlashCommandBuilder, ContextMenuCommandBuilder } = require("discord.js"),
const {/* EmbedBuilder, */Client, Collection, SlashCommandBuilder, ContextMenuCommandBuilder } = require("discord.js"),
{ GiveawaysManager } = require("discord-giveaways"),
{ SoundCloudPlugin } = require("@distube/soundcloud"),
{ SpotifyPlugin } = require("@distube/spotify"),
{ YtDlpPlugin } = require("@distube/yt-dlp"),
// { SoundCloudPlugin } = require("@distube/soundcloud"),
// { SpotifyPlugin } = require("@distube/spotify"),
// { YtDlpPlugin } = require("@distube/yt-dlp"),
{ Player } = require("discord-player"),
{ REST } = require("@discordjs/rest"),
{ Routes } = require("discord-api-types/v10");
@ -13,7 +14,7 @@ const BaseEvent = require("./BaseEvent.js"),
path = require("path"),
fs = require("fs").promises,
mongoose = require("mongoose"),
DisTube = require("distube"),
// DisTube = require("distube"),
moment = require("moment");
moment.relativeTimeThreshold("s", 60);
@ -52,60 +53,35 @@ class JaBa extends Client {
this.discordTogether = new DiscordTogether(this);
this.player = new DisTube.default(this, {
plugins: [
new SpotifyPlugin({
emitEventsAfterFetching: true
}),
new SoundCloudPlugin(),
new YtDlpPlugin()
],
directLink: true,
emitNewSongOnly: true,
leaveOnEmpty: true,
leaveOnFinish: true,
leaveOnStop: true,
searchSongs: 10,
searchCooldown: 30,
emptyCooldown: 10,
emitAddListWhenCreatingQueue: false,
emitAddSongWhenCreatingQueue: false
this.player = new Player(this, {
autoRegisterExtractor: true,
leaveOnEnd: true,
leaveOnStop: true
});
this.player
.on("playSong", async (queue, song) => {
const m = await queue.textChannel.send({ content: this.translate("music/play:NOW_PLAYING", { songName: song.name }, queue.textChannel.guild.data.language) });
if (song.duration > 1) {
.on("trackStart", async (queue, track) => {
const m = await queue.metadata.channel.send({ content: this.translate("music/play:NOW_PLAYING", { songName: track.title }, queue.metadata.channel.guild.data.language) });
if (track.durationMS > 1) {
setTimeout(() => {
if (m.deletable) m.delete();
}, song.duration * 1000);
}, track.durationMS * 1000);
} else {
setTimeout(() => {
if (m.deletable) m.delete();
}, 10 * 60 * 1000); // m * s * ms
}
})
.on("addSong", (queue, song) => queue.textChannel.send({ content: this.translate("music/play:ADDED_QUEUE", { songName: song.name }, queue.textChannel.guild.data.language) }))
.on("addList", (queue, playlist) => queue.textChannel.send({ content: this.translate("music/play:ADDED_QUEUE_COUNT", { songCount: `**${playlist.songs.length}** ${this.getNoun(playlist.songs.length, this.translate("misc:NOUNS:TRACKS:1"), this.translate("misc:NOUNS:TRACKS:1"), this.translate("misc:NOUNS:TRACKS:2"), this.translate("misc:NOUNS:TRACKS:5"))}` }, queue.textChannel.guild.data.language) }))
.on("searchResult", (message, result) => {
let i = 0;
const embed = new EmbedBuilder()
.setDescription(result.map(song => `**${++i}** - ${song.name}`).join("\n"))
.setFooter({ text: this.translate("music/play:RESULTS_FOOTER", null, message.guild.data.language) })
.setColor(this.config.embed.color);
message.reply({ embeds: [embed] });
})
.on("searchDone", () => {})
.on("searchCancel", message => message.error("misc:TIMES_UP"))
.on("searchInvalidAnswer", message => message.error("misc:INVALID_NUMBER_RANGE", { min: 1, max: 10 }))
.on("searchNoResult", message => message.error("music/play:NO_RESULT"))
.on("error", (textChannel, e) => {
.on("queueEnd", queue => queue.metadata.channel.send(this.translate("music/play:QUEUE_ENDED", null, queue.metadata.channel.guild.data.language)))
.on("channelEmpty", queue => queue.metadata.channel.send(this.translate("music/play:STOP_EMPTY", null, queue.metadata.channel.guild.data.language)))
.on("connectionError", (queue, e) => {
console.error(e);
textChannel.send({ content: this.translate("music/play:ERR_OCCURRED", { error: e }, textChannel.guild.data.language) });
queue.metadata.channel.send({ content: this.translate("music/play:ERR_OCCURRED", { error: e.message }, queue.metadata.channel.guild.data.language) });
})
.on("finish", queue => queue.textChannel.send(this.translate("music/play:QUEUE_ENDED", null, queue.textChannel.guild.data.language)))
// .on("disconnect", queue => queue.textChannel.send(this.translate("music/play:STOP_DISCONNECTED", null, queue.textChannel.guild.data.language)))
.on("empty", queue => queue.textChannel.send(this.translate("music/play:STOP_EMPTY", null, queue.textChannel.guild.data.language)));
.on("error", (queue, e) => {
console.error(e);
queue.metadata.channel.send({ content: this.translate("music/play:ERR_OCCURRED", { error: e.message }, queue.metadata.channel.guild.data.language) });
});
this.giveawaysManager = new GiveawaysManager(this, {
storage: "./giveaways.json",

View file

@ -1,46 +0,0 @@
const { SlashCommandBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class AutoPlay extends BaseCommand {
/**
*
* @param {import("../base/JaBa")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("autoplay")
.setDescription(client.translate("music/autoplay:DESCRIPTION")),
aliases: [],
dirname: __dirname,
guildOnly: true,
ownerOnly: false
});
}
/**
*
* @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Array} data
*/
async execute(client, interaction) {
const voice = interaction.member.voice.channel;
const queue = client.player.getQueue(interaction);
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL", null, { ephemeral: true });
if (!queue) return interaction.error("music/play:NOT_PLAYING", null, { ephemeral: true });
const autoplay = queue.toggleAutoplay();
interaction.success(`music/autoplay:SUCCESS_${autoplay ? "ENABLED" : "DISABLED"}`);
}
}
module.exports = AutoPlay;

View file

@ -32,27 +32,24 @@ class Back extends BaseCommand {
*/
async execute(client, interaction) {
const voice = interaction.member.voice.channel;
const queue = client.player.getQueue(interaction);
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL", null, { ephemeral: true });
const queue = client.player.getQueue(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING", null, { ephemeral: true });
if (!queue.previousSongs[0]) return interaction.error("music/back:NO_PREV_SONG", null, { ephemeral: true });
if (!queue.previousTracks[0]) return interaction.error("music/back:NO_PREV_SONG", null, { ephemeral: true });
const embed = new EmbedBuilder()
.setAuthor({
name: interaction.translate("music/back:DESCRIPTION")
name: interaction.translate("music/back:SUCCESS")
})
.setThumbnail(queue.tracks[0].thumbnail)
.setDescription(interaction.translate("music/back:SUCCESS"))
.setThumbnail(queue.current.thumbnail)
.setDescription(`[${queue.current.title}](${queue.current.url})`)
.setColor(client.config.embed.color)
.setFooter({
text: client.config.embed.footer
});
client.player.previous(interaction);
interaction.reply({
embeds: [embed]
});
queue.back()
.then(() => interaction.reply({ embeds: [embed] }));
}
}

View file

@ -54,7 +54,6 @@ class Clips extends BaseCommand {
const msg = await interaction.reply({
content: interaction.translate("music/clips:AVAILABLE_CLIPS"),
ephemeral: true,
components: [row],
fetchReply: true
});
@ -68,13 +67,11 @@ class Clips extends BaseCommand {
collector.on("collect", async msg => {
const clip = msg?.values[0];
const voice = msg.member.voice.channel;
const queue = client.player.getQueue(msg);
if (!voice) return msg.error("music/play:NO_VOICE_CHANNEL");
if (getVoiceConnection(msg.guild.id)) return msg.error("music/clip:ACTIVE_CLIP");
if (queue) return msg.error("music/clip:ACTIVE_QUEUE");
if (!clip) return msg.error("music/clip:NO_ARG");
if (!fs.existsSync(`./clips/${clip}.mp3`)) return msg.error("music/clip:NO_FILE", { file: clip });
if (!voice) return msg.update({ content: interaction.translate("music/play:NO_VOICE_CHANNEL"), components: [] });
const queue = client.player.getQueue(msg.guild.id);
if (queue) return msg.update({ content: interaction.translate("music/clips:ACTIVE_QUEUE"), components: [] });
if (getVoiceConnection(msg.guild.id)) return msg.update({ content: interaction.translate("music/clips:ACTIVE_CLIP"), components: [] });
if (!fs.existsSync(`./clips/${clip}.mp3`)) return msg.update({ content: interaction.translate("music/clips:NO_FILE", { file: clip }), components: [] });
try {
const connection = joinVoiceChannel({

View file

@ -1,4 +1,5 @@
const { SlashCommandBuilder, ActionRowBuilder, SelectMenuBuilder, InteractionCollector, ComponentType } = require("discord.js");
const { SlashCommandBuilder, ActionRowBuilder, SelectMenuBuilder, InteractionCollector, ComponentType } = require("discord.js"),
{ QueueRepeatMode } = require("discord-player");
const BaseCommand = require("../../base/BaseCommand");
class Loop extends BaseCommand {
@ -32,31 +33,37 @@ class Loop extends BaseCommand {
*/
async execute(client, interaction) {
const voice = interaction.member.voice.channel;
const queue = client.player.getQueue(interaction);
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL");
const queue = client.player.getQueue(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING");
const row = new ActionRowBuilder()
.addComponents(
new SelectMenuBuilder()
.setCustomId("nsfw_select")
.setCustomId("loop_select")
.setPlaceholder(client.translate("common:NOTHING_SELECTED"))
.addOptions([
{
label: client.translate("music/loop:QUEUE"),
value: "queue"
label: client.translate("music/loop:AUTOPLAY"),
value: QueueRepeatMode.AUTOPLAY.toString()
},
{
label: client.translate("music/loop:SONG"),
value: "song"
label: client.translate("music/loop:QUEUE"),
value: QueueRepeatMode.QUEUE.toString()
},
{
label: client.translate("music/loop:TRACK"),
value: QueueRepeatMode.TRACK.toString()
},
{
label: client.translate("music/loop:DISABLE"),
value: QueueRepeatMode.OFF.toString()
}
])
);
const msg = await interaction.reply({
content: interaction.translate("common:AVAILABLE_CATEGORIES"),
ephemeral: true,
components: [row],
fetchReply: true
});
@ -68,19 +75,11 @@ class Loop extends BaseCommand {
});
collector.on("collect", async msg => {
const type = msg?.values[0];
let mode = null;
if (type === "queue") {
mode = client.player.setRepeatMode(interaction, 2);
} else if (type === "song") {
mode = client.player.setRepeatMode(interaction, 1);
} else {
mode = client.player.setRepeatMode(interaction, 0);
}
const type = Number(msg?.values[0]);
queue.setRepeatMode(type);
await msg.update({
content: `music/loop:${mode ? mode === 2 ? "QUEUE_ENABLED" : "SONG_ENABLED" : "DISABLED"}`,
content: interaction.translate(`music/loop:${type === 3 ? "AUTOPLAY_ENABLED" :
type === 2 ? "QUEUE_ENABLED" : type === 1 ? "TRACK_ENABLED" : "LOOP_DISABLED"}`),
components: []
});
});

View file

@ -1,4 +1,5 @@
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js"),
{ QueueRepeatMode } = require("discord-player");
const BaseCommand = require("../../base/BaseCommand");
class Nowplaying extends BaseCommand {
@ -31,24 +32,11 @@ class Nowplaying extends BaseCommand {
* @param {Array} data
*/
async execute(client, interaction) {
const voice = interaction.member.voice.channel;
const queue = client.player.getQueue(interaction);
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL");
await interaction.deferReply();
const queue = client.player.getQueue(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING");
const track = queue.songs[0];
const status = queue =>
`${interaction.translate("music/nowplaying:REPEAT")}: \`${
queue.repeatMode
? queue.repeatMode === 2 ? interaction.translate("music/nowplaying:QUEUE") : interaction.translate("music/nowplaying:SONG")
: interaction.translate("music/nowplaying:DISABLED")
}\` | ${interaction.translate("music/nowplaying:AUTOPLAY")}: \`${
queue.autoplay
? interaction.translate("music/nowplaying:ENABLED")
: interaction.translate("music/nowplaying:DISABLED")
}\``;
const progressBar = queue.createProgressBar();
const track = queue.current;
const embed = new EmbedBuilder()
.setAuthor({
@ -58,19 +46,22 @@ class Nowplaying extends BaseCommand {
.addFields([
{
name: interaction.translate("music/nowplaying:T_TITLE"),
value: `[${track.name}](${track.url})`
value: `[${track.title}](${track.url})`
},
{
name: interaction.translate("music/nowplaying:T_CHANNEL"),
value: track.uploader.name || interaction.translate("common:UNKNOWN")
name: interaction.translate("music/nowplaying:T_AUTHOR"),
value: track.author || interaction.translate("common:UNKNOWN")
},
{
name: interaction.translate("music/nowplaying:T_DURATION"),
value: `${queue.formattedCurrentTime} / ${track.duration > 1 ? track.formattedDuration : interaction.translate("music/play:LIVE")}`
value: progressBar
},
{
name: interaction.translate("music/nowplaying:T_CONF"),
value: status(queue)
name: "\u200b",
value: `${interaction.translate("music/nowplaying:REPEAT")}: \`${
queue.repeatMode === QueueRepeatMode.AUTOPLAY ? interaction.translate("music/nowplaying:AUTOPLAY") : queue.repeatMode === QueueRepeatMode.QUEUE ? interaction.translate("music/nowplaying:QUEUE") : queue.repeatMode === QueueRepeatMode.TRACK ? interaction.translate("music/nowplaying:TRACK")
: interaction.translate("music/nowplaying:DISABLED")
}\``
}
])
.setColor(client.config.embed.color)
@ -79,7 +70,7 @@ class Nowplaying extends BaseCommand {
})
.setTimestamp();
interaction.reply({
interaction.editReply({
embeds: [embed]
});
}

View file

@ -1,4 +1,5 @@
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js"),
{ QueryType } = require("discord-player");
const BaseCommand = require("../../base/BaseCommand");
class Play extends BaseCommand {
@ -11,8 +12,8 @@ class Play extends BaseCommand {
command: new SlashCommandBuilder()
.setName("play")
.setDescription(client.translate("music/play:DESCRIPTION"))
.addStringOption(option => option.setName("link")
.setDescription(client.translate("music/play:LINK"))
.addStringOption(option => option.setName("query")
.setDescription(client.translate("music/play:QUERY"))
.setRequired(true)),
aliases: [],
dirname: __dirname,
@ -35,24 +36,51 @@ class Play extends BaseCommand {
*/
async execute(client, interaction) {
await interaction.deferReply();
const voice = interaction.member.voice.channel;
const link = interaction.options.getString("link");
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL");
const query = interaction.options.getString("query");
const perms = voice.permissionsFor(client.user);
if (!perms.has(PermissionsBitField.Flags.Connect) || !perms.has(PermissionsBitField.Flags.Speak)) return interaction.error("music/play:VOICE_CHANNEL_CONNECT");
const searchResult = await client.player.search(query, {
requestedBy: interaction.user,
searchEngine: query.includes("soundcloud") ? QueryType.SOUNDCLOUD_SEARCH : QueryType.AUTO
}).catch(() => {});
if (!searchResult || !searchResult.tracks.length) return interaction.editReply({
content: interaction.translate("music/play:NO_RESULT", {
query
})
});
const queue = client.player.getQueue(interaction.guildId) || client.player.createQueue(interaction.guild, {
metadata: {
channel: interaction.channel
},
ytdlOptions: {
filter: "audioonly",
highWaterMark: 1 << 30,
dlChunkSize: 0,
liveBuffer: 4900
}
});
if (!queue.tracks[0]) {
searchResult.playlist ? queue.addTracks(searchResult.tracks) : queue.addTrack(searchResult.tracks[0]);
} else {
searchResult.playlist ? searchResult.tracks.forEach(track => queue.insert(track)) : queue.insert(searchResult.tracks[0]);
}
try {
client.player.play(interaction.member.voice.channel, link, {
member: interaction.member,
textChannel: interaction.channel
});
if (!queue.connection) await queue.connect(interaction.member.voice.channel);
if (!queue.playing) await queue.play();
interaction.editReply({
content: interaction.translate("music/play:ADDED_QUEUE", { songName: link })
content: interaction.translate("music/play:ADDED_QUEUE", {
songName: searchResult.playlist ? searchResult.playlist.title : searchResult.tracks[0].title
})
});
} catch (e) {
client.player.deleteQueue(interaction.guildId);
interaction.error("music/play:ERR_OCCURRED", {
error: e
});

67
commands/Music/queue.js Normal file
View file

@ -0,0 +1,67 @@
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class Queue extends BaseCommand {
/**
*
* @param {import("../base/JaBa")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("queue")
.setDescription(client.translate("music/queue:DESCRIPTION")),
aliases: [],
dirname: __dirname,
guildOnly: true,
ownerOnly: false
});
}
/**
*
* @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Array} data
*/
async execute(client, interaction) {
const queue = client.player.getQueue(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING");
const currentTrack = queue.current;
const tracks = queue.tracks.slice(0, 10).map((t, i) => {
return `${i}. [${t.title}](${t.url})\n> ${interaction.translate("music/queue:ADDED")} ${t.requestedBy}`;
});
const embed = new EmbedBuilder()
.setAuthor({
name: interaction.translate("music/queue:TITLE"),
iconURL: interaction.guild.iconURL()
})
.setColor(client.config.embed.color)
.addFields(
{
name: interaction.translate("music/nowplaying:CURRENTLY_PLAYING"),
value: `[${currentTrack.title}](${currentTrack.url})\n> ${interaction.translate("music/queue:ADDED")} ${currentTrack.requestedBy}`
},
{
name: "\u200b",
value: `${tracks.join("\n")}\n${interaction.translate("music/nowplaying:MORE", {
tracks: `${queue.tracks.length - tracks.length} ${client.getNoun(queue.tracks.length - tracks.length, interaction.translate("misc:NOUNS:TRACKS:1"), interaction.translate("misc:NOUNS:TRACKS:2"), interaction.translate("misc:NOUNS:TRACKS:5"))}`
})}`
}
);
interaction.reply({
embeds: [embed]
});
}
}
module.exports = Queue;

View file

@ -1,6 +1,5 @@
const { SlashCommandBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"),
ms = require("ms");
const BaseCommand = require("../../base/BaseCommand");
class Seek extends BaseCommand {
/**
@ -12,8 +11,8 @@ class Seek extends BaseCommand {
command: new SlashCommandBuilder()
.setName("seek")
.setDescription(client.translate("music/seek:DESCRIPTION"))
.addStringOption(option => option.setName("time")
.setDescription("music/seek:TIME")
.addIntegerOption(option => option.setName("time")
.setDescription(client.translate("music/seek:TIME"))
.setRequired(true)),
aliases: [],
dirname: __dirname,
@ -36,18 +35,13 @@ class Seek extends BaseCommand {
*/
async execute(client, interaction) {
const voice = interaction.member.voice.channel;
const queue = client.player.getQueue(interaction);
const time = ms(interaction.options.getString("time")) / 1000;
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL");
const queue = client.player.getQueue(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING");
if (isNaN(time)) return interaction.error("music/seek:INVALID_TIME");
const time = interaction.options.getInteger("time");
await client.player.seek(interaction, time);
interaction.replyT("music/seek:SUCCESS", {
time: ms(interaction.options.getString("time"))
});
queue.seek(time)
.then(() => interaction.replyT("music/seek:SUCCESS", { time: `${time} ${client.getNoun(time, interaction.translate("misc:NOUNS:SECONDS:1"), interaction.translate("misc:NOUNS:SECONDS:2"), interaction.translate("misc:NOUNS:SECONDS:5"))}` }));
}
}

View file

@ -32,25 +32,25 @@ class Skip extends BaseCommand {
*/
async execute(client, interaction) {
const voice = interaction.member.voice.channel;
const queue = client.player.getQueue(interaction);
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL");
const queue = client.player.getQueue(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING");
if (!queue.songs[1]) return interaction.error("music/skip:NO_NEXT_SONG");
if (!queue.tracks[1]) return interaction.error("music/skip:NO_NEXT_SONG");
const embed = new EmbedBuilder()
.setAuthor({
name: interaction.translate("music/skip:SUCCESS")
})
.setThumbnail(queue.songs[1].thumbnail)
.setThumbnail(queue.tracks[1].thumbnail)
.setDescription(interaction.translate("music/play:NOW_PLAYING", {
songName: queue.songs[1].name
songName: queue.tracks[1].name
}))
.setFooter({
text: client.config.embed.footer
})
.setColor(client.config.embed.color);
client.player.skip(interaction);
queue.skip();
interaction.reply({
embeds: [embed]

View file

@ -1,7 +1,7 @@
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const { SlashCommandBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class Jump extends BaseCommand {
class Skipto extends BaseCommand {
/**
*
* @param {import("../base/JaBa")} client
@ -9,10 +9,10 @@ class Jump extends BaseCommand {
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("jump")
.setDescription(client.translate("music/jump:DESCRIPTION"))
.setName("skipto")
.setDescription(client.translate("music/skipto:DESCRIPTION"))
.addIntegerOption(option => option.setName("position")
.setDescription("music/jump:POSITION")
.setDescription(client.translate("music/skipto:POSITION"))
.setRequired(true)),
aliases: [],
dirname: __dirname,
@ -34,32 +34,22 @@ class Jump extends BaseCommand {
* @param {Array} data
*/
async execute(client, interaction) {
const queue = client.player.getQueue(interaction);
const voice = interaction.member.voice.channel;
const queue = client.player.getQueue(interaction.guildId);
const position = interaction.options.getInteger("position");
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL");
if (!queue) return interaction.error("music/play:NOT_PLAYING");
if (position < 0) return interaction.error("music/jump:NO_PREV_SONG");
if (position < 0) return interaction.error("music/skipto:NO_PREV_SONG");
const embed = new EmbedBuilder()
.setAuthor({
name: interaction.translate("music/jump:SUCCESS")
})
.setThumbnail(queue.songs[position].thumbnail)
.setDescription(interaction.translate("music/play:NOW_PLAYING", {
songName: queue.songs[position].name
}))
.setFooter({
text: client.config.embed.footer
})
.setColor(client.config.embed.color);
client.player.jump(interaction, position);
if (queue.tracks[position]) {
queue.skipTo(queue.tracks[position]);
interaction.reply({
embeds: [embed]
});
interaction.success("music/skipto:SUCCESS", {
position
});
} else return interaction.error("music/skipto:ERROR", { position });
}
}
module.exports = Jump;
module.exports = Skipto;

View file

@ -1,4 +1,4 @@
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const { SlashCommandBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class Stop extends BaseCommand {
@ -32,24 +32,13 @@ class Stop extends BaseCommand {
*/
async execute(client, interaction) {
const voice = interaction.member.voice.channel;
const queue = client.player.getQueue(interaction);
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL");
const queue = client.player.getQueue(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING");
const embed = new EmbedBuilder()
.setAuthor({
name: interaction.translate("music/stop:DESCRIPTION")
})
.setDescription(interaction.translate("music/stop:SUCCESS"))
.setFooter({
text: client.config.embed.footer
})
.setColor(client.config.embed.color);
client.player.stop(interaction);
queue.destroy();
interaction.reply({
embeds: [embed]
content: interaction.translate("music/stop:SUCCESS")
});
}
}

View file

@ -11,7 +11,7 @@ function dateTimePad(value, digits) {
}
function format(tDate) {
return (tDate.getDate() + "-" +
return (dateTimePad((tDate.getDate()), 2) + "-" +
dateTimePad((tDate.getMonth() + 1), 2) + "-" +
dateTimePad(tDate.getFullYear(), 2) + " " +
dateTimePad(tDate.getHours(), 2) + ":" +

View file

@ -1,7 +0,0 @@
{
"DESCRIPTION": "Включить или отключить автовоспроизведение",
"USAGE": "autoplay",
"EXAMPLES": "autoplay",
"SUCCESS_ENABLED": "Автовоспроизведение включено!",
"SUCCESS_DISABLED": "Автовоспроизведение выключено!"
}

View file

@ -3,5 +3,7 @@
"USAGE": "clips",
"EXAMPLES": "clips",
"AVAILABLE_CLIPS": "Список доступных клипов:",
"ACTIVE_QUEUE": "Не могу воспроизвести клип, т.к. на сервере есть активная очередь!",
"ACTIVE_CLIP": "Уже воспроизводится какой-то файл!",
"PLAYING": "Начато проигрывание клипа `{{clip}}`"
}

View file

@ -2,9 +2,12 @@
"DESCRIPTION": "Включить или отключить повтор очереди/одного трека",
"USAGE": "loop",
"EXAMPLES": "loop",
"AUTOPLAY": "Автовоспроизведение",
"QUEUE": "Очередь",
"SONG": "Текущий трек",
"TRACK": "Текущий трек",
"DISABLE": "Отключить",
"AUTOPLAY_ENABLED": "Автовоспроизведение **включено**",
"QUEUE_ENABLED": "Повтор очереди **включён**!",
"SONG_ENABLED": "Повтор текущего трека **включён**!",
"DISABLED": "Повтор **отключён**!"
"TRACK_ENABLED": "Повтор текущего трека **включён**!",
"LOOP_DISABLED": "Повтор **отключён**!"
}

View file

@ -4,16 +4,14 @@
"EXAMPLES": "nowplaying",
"CURRENTLY_PLAYING": "Сейчас играет",
"T_TITLE": "Название",
"T_CHANNEL": "Канал",
"T_AUTHOR": "Автор",
"T_DURATION": "Длительность",
"T_CONF": "Настройки",
"T_DESCRIPTION": "Описание",
"NO_DESCRIPTION": "Описание отсутствует",
"FILTERS": "Фильтры",
"REPEAT": "Повтор",
"AUTOPLAY": "Автовоспроизведение",
"QUEUE": "Очереди",
"SONG": "Трека",
"TRACK": "Трека",
"ENABLED": "Вкл.",
"DISABLED": "Выкл."
}

View file

@ -2,21 +2,17 @@
"DESCRIPTION": "Начать воспроизведение трека",
"USAGE": "play [название-трека/ссылка]",
"EXAMPLES": "play Never Gonna Give You Up",
"LINK": "Название/Прямая ссылка/Ссылка на YouTube, Spotify или SoundCloud",
"QUERY": "Название/Прямая ссылка/Ссылка на YouTube, Spotify или SoundCloud",
"NO_VOICE_CHANNEL": "Вы должны находиться в голосовом канале!",
"VOICE_CHANNEL_CONNECT": "Я не могу присоедениться к вашему голосовому каналу!",
"RESULTS_FOOTER": "Укажите число от 1 до 10 (без префикса).",
"NO_RESULT": "Ничего не найдено!",
"NO_RESULT": "По запросу `{{query}}` ничего не найдено!",
"NOW_PLAYING": "Сейчас играет **{{songName}}**",
"PLAYING_PLAYLIST": "Начинается воспроизведение плейлиста **{{playlistTitle}}**. {{playlistEmoji}}\nНачато воспроизведение первого трека, **{{songName}}**!",
"CANCELLED": "Выбор отменён",
"NOT_PLAYING": "На сервере сейчас ничего не воспроизводится.",
"QUEUE_ENDED": "Очередь окончена.",
"NOT_PLAYING": "На сервере сейчас ничего не воспроизводится",
"QUEUE_ENDED": "Очередь окончена",
"ADDED_QUEUE": "**{{songName}}** добавлен в очередь!",
"ADDED_QUEUE_COUNT": "{{songCount}} добавлено в очередь!",
"STOP_DISCONNECTED": "Воспроизведение окончено, т.к. я вышел из голосового канала.",
"STOP_EMPTY": "Воспроизведение окончено, т.к. все вышли из голосового канала.",
"RESULTS_CANCEL": "Поиск отменён!",
"LIVE": "Прямая трансляция",
"ERR_OCCURRED": "Произошла ошибка, пропускаю...\n`{{error}}`"
}

View file

@ -3,8 +3,6 @@
"USAGE": "queue",
"EXAMPLES": "queue",
"TITLE": "Очередь",
"PREVIOUS": "Пред. страница",
"NEXT": "След. страница",
"PAGE": "Страница",
"ADDED": "Добавил"
"ADDED": "Добавил",
"MORE": "и ещё {{tracks}}"
}

View file

@ -2,6 +2,6 @@
"DESCRIPTION": "Перемотать вперед или назад на данное время в текущем треке",
"USAGE": "seek [время]",
"EXAMPLES": "seek 10s\nseek -10s",
"INVALID_TIME": "Укажите время!",
"TIME": "Время в секундах",
"SUCCESS": "Трек перемотан на {{time}}!"
}

View file

@ -1,7 +1,9 @@
{
"DESCRIPTION": "Перейти на заданный трек",
"USAGE": "jump [номер]",
"EXAMPLES": "jump 3",
"USAGE": "skipto [номер]",
"EXAMPLES": "skipto 3",
"POSITION": "Номер трека в очереди",
"SUCCESS": "Выполнен переход на позицию {{position}",
"ERROR": "На позиции {{position}} ничего не найдено",
"NO_PREV_SONG": "Вы не можете перейти назад, для этого используйте команду `back`!"
}

2143
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -12,41 +12,34 @@
"author": "Jonny_Bro#4226",
"license": "ISC",
"dependencies": {
"@discord-player/extractor": "^3.0.2",
"@discordjs/opus": "^0.8.0",
"@discordjs/rest": "^1.0.0",
"@discordjs/voice": "^0.11.0",
"@distube/soundcloud": "^1.2.1",
"@distube/spotify": "^1.3.2",
"@distube/yt-dlp": "^1.1.3",
"@distube/ytdl-core": "^4.11.3",
"@sindresorhus/slugify": "^1.1.0",
"amethyste-api": "github:Androz2091/amethyste-api",
"btoa": "^1.2.1",
"canvacord": "^5.1.0",
"canvas": "^2.9.0",
"chalk": "^4.1.0",
"colors-generator": "^0.3.4",
"cron": "^1.7.2",
"discord-api-types": "^0.37.0",
"discord-giveaways": "^6.0.0",
"discord-together": "^1.3.3",
"discord-player": "^5.3.0-dev.3",
"discord.js": "^14.1.2",
"discord.js-embed-pagination": "^1.0.2",
"distube": "^4.0.3",
"ejs": "^3.1.3",
"express": "^4.17.1",
"express-session": "^1.17.0",
"ffmpeg-static": "^4.4.0",
"ffmpeg-static": "^4.4.1",
"gamedig": "^4.0.2",
"i18next": "^20.2.2",
"i18next-node-fs-backend": "^2.1.3",
"libsodium-wrappers": "^0.7.10",
"markdown-table": "2.0.0",
"mathjs": "^9.0.0",
"md5": "^2.2.1",
"moment": "^2.26.0",
"mongoose": "^5.13.14",
"ms": "^2.1.3"
"ms": "^2.1.3",
"prism-media": "^1.3.4"
},
"devDependencies": {
"eslint": "^7.5.0"