This commit is contained in:
JonnyBro 2022-03-26 17:23:03 +05:00
parent f26deb9f5f
commit 8aba76a924
15 changed files with 317 additions and 27 deletions

View file

@ -82,10 +82,11 @@ const userSchema = new mongoose.Schema({
}},
/* OTHER INFORMATIONS */
afk: { type: String, default: null }, // Whether the member is AFK
reminds: { type: Array, default: [] }, // the reminds of the user
logged: { type: Boolean, default: false }, // if the user is logged to the dashboard
apiToken: { type: String, default: genToken() } // the api token of the user
afk: { type: String, default: null }, // The AFK reason (if any)
reminds: { type: Array, default: [] }, // The reminds of the user
playlists: { type: Array, default: [] }, // The playlists of the user
logged: { type: Boolean, default: false }, // If the user is logged to the dashboard
apiToken: { type: String, default: genToken() } // The API token of the user
});
userSchema.method("genApiToken", async function() {

View file

@ -20,8 +20,8 @@ class Transactions extends Command {
async run(message, args, data) {
const timestamp = Date.now() + (30 * 24 * 60 * 60 * 1000); // day hour min sec msec / 1 month
const transactions = data.memberData.transactions;
for (const t of transactions) {
if (t.date > timestamp) {
for await (const t of transactions) {
if (t.date < timestamp) {
const index = transactions.indexOf(t);
transactions.splice(index, 1);
}
@ -50,13 +50,11 @@ class Transactions extends Command {
if (transactions.length < 1) {
embed.setDescription(message.translate("economy/transactions:NO_TRANSACTIONS"));
return message.reply({
embeds: [embed]
});
} else {
if (sortedTransactions[0].length > 0) embed.addField(message.translate("economy/transactions:T_GOT"), sortedTransactions[0].join("\n"), true);
if (sortedTransactions[1].length > 0) embed.addField(message.translate("economy/transactions:T_SEND"), sortedTransactions[1].join("\n"), true);
}
message.reply({
embeds: [embed]
});

View file

@ -0,0 +1,45 @@
const Command = require("../../base/Command");
class CreatePlaylist extends Command {
constructor(client) {
super(client, {
name: "createplaylist",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: ["cpl", "createpl"],
memberPermissions: [],
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
nsfw: false,
ownerOnly: false,
cooldown: 3000
});
}
async run(message, args, data) {
args = args.join(" ").split(" | ");
const name = args[0];
const songs = args[1].split(" ");
if (!name) return message.error("music/createplaylist:NO_NAME");
if (!songs) return message.error("music/createplaylist:NO_SONGS");
const playlist = await this.client.player.createCustomPlaylist(songs, {
member: message.member,
properties: {
name
},
parallel: true
});
data.userData.playlists.push(playlist);
data.userData.markModified("playlists");
data.userData.save();
message.success("music/createplaylist:CREATED", {
name
});
}
}
module.exports = CreatePlaylist;

View file

@ -0,0 +1,98 @@
const Command = require("../../base/Command"),
Discord = require("discord.js");
class Playlists extends Command {
constructor(client) {
super(client, {
name: "playlists",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: ["pls"],
memberPermissions: [],
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
nsfw: false,
ownerOnly: false,
cooldown: 3000
});
}
async run(message, args, data) {
const playlists = data.userData.playlists;
if (args[0]) {
const name = args.join(" ");
let playlist;
for (const pl of playlists) {
if (pl.name === name) {
playlist = pl;
} else {
message.error("music/removeplaylist:NOT_FOUND", {
name
});
}
}
const embed = new Discord.MessageEmbed()
.setAuthor({
name: message.translate("music/playlists:EMBED_TITLE2", {
name
}),
iconURL: message.author.displayAvatarURL({
size: 512,
dynamic: true,
format: "png"
})
})
.setColor(data.config.embed.color)
.setFooter({
text: data.config.embed.footer
})
.addField(message.translate("music/playlists:NAME"), playlist.name, true)
.addField(message.translate("music/playlists:COUNT"), playlist.songs.length.toString(), true);
const songs = [];
for (const song of playlist.songs) {
songs.push(`[${song.name}](${song.url})`);
}
embed.addField(message.translate("music/playlists:SONGS"), songs.join("\n"));
return message.reply({
embeds: [embed]
});
}
const embed = new Discord.MessageEmbed()
.setAuthor({
name: message.translate("music/playlists:EMBED_TITLE"),
iconURL: message.author.displayAvatarURL({
size: 512,
dynamic: true,
format: "png"
})
})
.setColor(data.config.embed.color)
.setFooter({
text: data.config.embed.footer
});
const pls = [];
playlists.forEach((pl) => {
pls.push(`${message.translate("music/playlists:NAME")}: ${pl.name}\n${message.translate("music/playlists:COUNT")}: ${pl.songs.length}\n`);
});
if (playlists.length < 1) {
embed.setDescription(message.translate("music/playlists:NO_PLAYLISTS"));
} else {
embed.addField(message.translate("music/playlists:PLAYLISTS"), pls.join("\n"), true);
}
message.reply({
embeds: [embed]
});
}
}
module.exports = Playlists;

View file

@ -0,0 +1,56 @@
const Command = require("../../base/Command"),
DisTube = require("distube"),
{ Permissions } = require("discord.js");
class PlayPlaylists extends Command {
constructor(client) {
super(client, {
name: "playplaylist",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: ["ppl"],
memberPermissions: [],
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
nsfw: false,
ownerOnly: false,
cooldown: 3000
});
}
async run(message, args, data) {
const voice = message.member.voice.channel;
const name = args.join(" ");
let playlist;
for (const pl of data.userData.playlists) {
if (pl.name === name) {
playlist = new DisTube.Playlist(pl);
} else {
return message.error("music/removeplaylist:NOT_FOUND", {
name
});
}
}
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
// Check my permissions
const perms = voice.permissionsFor(this.client.user);
if (!perms.has(Permissions.FLAGS.CONNECT) || !perms.has(Permissions.FLAGS.SPEAK)) return message.error("music/play:VOICE_CHANNEL_CONNECT");
try {
this.client.player.play(message.member.voice.channel, playlist, {
member: message.member,
textChannel: message.channel,
message
});
} catch (e) {
message.error("music/play:ERR_OCCURRED", {
error: e
});
console.error(e);
}
}
}
module.exports = PlayPlaylists;

View file

@ -33,7 +33,7 @@ class Queue extends Command {
dynamic: true
})
})
.addField(message.translate("music/np:CURRENTLY_PLAYING"), `[${queue.songs[0].name}](${queue.songs[0].url})\n*Добавил ${queue.songs[0].member}*\n`)
.addField(message.translate("music/np:CURRENTLY_PLAYING"), `[${queue.songs[0].name}](${queue.songs[0].url})\n*${message.translate("music/queue:ADDED")} ${queue.songs[0].member || message.translate("music/queue:PLAYLIST")}*\n`)
.setColor(data.config.embed.color);
return message.reply({
embeds: [embed]
@ -50,8 +50,7 @@ class Queue extends Command {
dynamic: true
})
})
.addField(message.translate("music/np:CURRENTLY_PLAYING"), `[${queue.songs[0].name}](${queue.songs[0].url})\n*${message.translate("music/queue:TITLE")} ${queue.songs[0].member}*\n`);
.addField(message.translate("music/np:CURRENTLY_PLAYING"), `[${queue.songs[0].name}](${queue.songs[0].url})\n*${message.translate("music/queue:ADDED")} ${queue.songs[0].member || message.translate("music/queue:PLAYLIST")}*\n`);
FieldsEmbed
.setArray(queue.songs[1] ? queue.songs.slice(1, queue.songs.length) : [])
.setAuthorizedUsers([message.author.id])
@ -60,7 +59,7 @@ class Queue extends Command {
.setDeleteOnTimeout(true)
.setDisabledNavigationEmojis(["jump"])
.setPageIndicator(true)
.formatField(message.translate("music/queue:TITLE"), (track) => `**${queue.songs.indexOf(track)}**. [${track.name}](${track.url})\n*${message.translate("music/queue:TITLE")} ${track.member}*\n`)
.formatField(message.translate("music/queue:TITLE"), (track) => `**${queue.songs.indexOf(track)}**. [${track.name}](${track.url})\n*${message.translate("music/queue:ADDED")} ${track.member || message.translate("music/queue:PLAYLIST")}*\n`)
.build();
}
}

View file

@ -0,0 +1,44 @@
const Command = require("../../base/Command");
class RemovePlaylist extends Command {
constructor(client) {
super(client, {
name: "removeplaylist",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: ["rpl", "removepl"],
memberPermissions: [],
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
nsfw: false,
ownerOnly: false,
cooldown: 3000
});
}
async run(message, args, data) {
const name = args[0];
if (!name) return message.error("music/createplaylist:NO_NAME");
const playlists = data.userData.playlists;
for (const playlist of playlists) {
if (playlist.name === name) {
const index = playlists.indexOf(playlist);
playlists.splice(index, 1);
data.userData.markModified("playlists");
data.userData.save();
message.success("music/removeplaylist:REMOVED", {
name
});
} else {
message.error("music/removeplaylist:NOT_FOUND", {
name
});
}
}
}
}
module.exports = RemovePlaylist;

View file

@ -1,3 +1,15 @@
### JaBa v3.4.4
* Добавлено
* Создание, удаление и воспроизведение плейлистов!
* *createplaylist (cpl)* - Создать плейлист.
* *playlists (pls)* - Список ваших плейлистов (Так же информация об отдельном плейлисте, смотрите *help*).
* *playplaylist (ppl)* - Воспроизвести ваш плейлист.
* *removeplaylist (rpl)* - Удалить плейлист.
* Исправления
* Транзакции в *transactions* удаляются через месяц.
* Мелкие правки в локализации, исправление орфографических ошибок.
### JaBa v3.4.3
* Изменения
* Украинская локализация закончена.

View file

@ -0,0 +1,8 @@
{
"DESCRIPTION": "Создать плейлист",
"USAGE": "{{prefix}}createplaylist [название] | [ссылки на треки/трансляции]",
"EXAMPLES": "{{prefix}}createplaylist Мой крутой плейлист | https://www.youtube.com/watch?v=dQw4w9WgXcQ https://www.youtube.com/watch?v=MEg-oqI9qmw",
"NO_NAME": "Укажите название плейлиста!",
"NO_SONGS": "Укажите ссылки(у) на треки/трансляции!",
"CREATED": "Плейлист `{{name}}` сохранён!"
}

View file

@ -0,0 +1,12 @@
{
"DESCRIPTION": "Посмотреть список ваших плейлистов",
"USAGE": "{{prefix}}playlists (название)",
"EXAMPLES": "{{prefix}}playlists\n{{prefix}}playlists Мой крутой плейлист",
"EMBED_TITLE": "Список плейлистов",
"EMBED_TITLE2": "Плейлист \"{{name}}\"",
"NO_PLAYLISTS": "У вас нет плейлистов!",
"PLAYLISTS": "Плейлисты",
"NAME": "Название",
"COUNT": "Количество треков",
"SONGS": "Треки в плейлисте"
}

View file

@ -0,0 +1,8 @@
{
"DESCRIPTION": "Создать плейлист",
"USAGE": "{{prefix}}createplaylist [название] | [ссылки на треки/трансляции]",
"EXAMPLES": "{{prefix}}createplaylist Мой крутой плейлист | https://www.youtube.com/watch?v=dQw4w9WgXcQ https://www.youtube.com/watch?v=MEg-oqI9qmw",
"NO_NAME": "Укажите название плейлиста!",
"NO_SONGS": "Укажите ссылки(у) на треки/трансляции!",
"CREATED": "Плейлист `{{name}}` сохранён!"
}

View file

@ -3,5 +3,6 @@
"USAGE": "{{prefix}}queue",
"EXAMPLES": "{{prefix}}queue",
"TITLE": "Очередь",
"ADDED": "Добавил"
"ADDED": "Добавил",
"PLAYLIST": "Плейлист"
}

View file

@ -0,0 +1,8 @@
{
"DESCRIPTION": "Удалить плейлист",
"USAGE": "{{prefix}}removeplaylist [название]",
"EXAMPLES": "{{prefix}}removeplaylist Мой крутой плейлист",
"NO_NAME": "Укажите название плейлиста!",
"REMOVED": "Плейлист `{{name}}` удалён!",
"NOT_FOUND": "Плейлист `{{name}}` не найден!"
}

22
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "jaba",
"version": "3.4.3",
"version": "3.4.4",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "jaba",
"version": "3.4.2",
"version": "3.4.3",
"license": "ISC",
"dependencies": {
"@discordjs/opus": "^0.7.0",
@ -30,7 +30,7 @@
"discord-paginationembed": "github:gazmull/discord-paginationembed#v3",
"discord-together": "^1.3.3",
"discord.js": "^13.6.0",
"distube": "^3.3.2",
"distube": "^3.3.3",
"ejs": "^3.1.3",
"express": "^4.17.1",
"express-session": "^1.17.0",
@ -1472,12 +1472,12 @@
}
},
"node_modules/distube": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/distube/-/distube-3.3.2.tgz",
"integrity": "sha512-cSri8ulAw7cP7hSC7Dfgw++O0U7pv6EhtMtB7I5oIzDC+YNv9qg0P1DKZ/TnuBWcmdBaxltmeG4o6BHiOLshiw==",
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/distube/-/distube-3.3.3.tgz",
"integrity": "sha512-4iGrKmyVT46/V/J6KZ+1XOq1gosbr07KZtMKodYtuG2vAX/cNP9TA2giqX7wJZoXJO2NYic7XWe06Z/NgBlgIw==",
"dependencies": {
"@distube/youtube-dl": "^2.2.4",
"@distube/ytdl-core": "^4.9.4",
"@distube/ytdl-core": "^4.11.1",
"@distube/ytpl": "^1.1.1",
"@distube/ytsr": "^1.1.5",
"prism-media": "https://codeload.github.com/distubejs/prism-media/tar.gz/main#workaround.tar.gz",
@ -5837,12 +5837,12 @@
}
},
"distube": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/distube/-/distube-3.3.2.tgz",
"integrity": "sha512-cSri8ulAw7cP7hSC7Dfgw++O0U7pv6EhtMtB7I5oIzDC+YNv9qg0P1DKZ/TnuBWcmdBaxltmeG4o6BHiOLshiw==",
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/distube/-/distube-3.3.3.tgz",
"integrity": "sha512-4iGrKmyVT46/V/J6KZ+1XOq1gosbr07KZtMKodYtuG2vAX/cNP9TA2giqX7wJZoXJO2NYic7XWe06Z/NgBlgIw==",
"requires": {
"@distube/youtube-dl": "^2.2.4",
"@distube/ytdl-core": "^4.9.4",
"@distube/ytdl-core": "^4.11.1",
"@distube/ytpl": "^1.1.1",
"@distube/ytsr": "^1.1.5",
"prism-media": "https://codeload.github.com/distubejs/prism-media/tar.gz/main#workaround.tar.gz",

View file

@ -1,6 +1,6 @@
{
"name": "jaba",
"version": "3.4.3",
"version": "3.4.4",
"description": "A very complete Discord bot (more than 100 commands) that uses the Discord.js",
"main": "index.js",
"private": true,
@ -34,7 +34,7 @@
"discord-paginationembed": "github:gazmull/discord-paginationembed#v3",
"discord-together": "^1.3.3",
"discord.js": "^13.6.0",
"distube": "^3.3.2",
"distube": "^3.3.3",
"ejs": "^3.1.3",
"express": "^4.17.1",
"express-session": "^1.17.0",