This commit is contained in:
JonnyBro 2022-08-29 21:31:36 +05:00
parent 0046828464
commit 1c974302ae
13 changed files with 927 additions and 872 deletions

View file

@ -7,7 +7,6 @@ const { Client, Collection, SlashCommandBuilder, ContextMenuCommandBuilder } = r
const BaseEvent = require("./BaseEvent.js"), const BaseEvent = require("./BaseEvent.js"),
BaseCommand = require("./BaseCommand.js"), BaseCommand = require("./BaseCommand.js"),
// AmeClient = require("amethyste-api"),
path = require("path"), path = require("path"),
fs = require("fs").promises, fs = require("fs").promises,
mongoose = require("mongoose"), mongoose = require("mongoose"),
@ -44,10 +43,8 @@ class JaBa extends Client {
this.databaseCache.users = new Collection(); this.databaseCache.users = new Collection();
this.databaseCache.guilds = new Collection(); this.databaseCache.guilds = new Collection();
this.databaseCache.members = new Collection(); this.databaseCache.members = new Collection();
this.databaseCache.usersReminds = new Collection(); // members with active reminds this.databaseCache.usersReminds = new Collection();
this.databaseCache.mutedUsers = new Collection(); // members who are currently muted this.databaseCache.mutedUsers = new Collection();
// if (this.config.apiKeys.amethyste) this.AmeAPI = new AmeClient(this.config.apiKeys.amethyste);
this.discordTogether = new DiscordTogether(this); this.discordTogether = new DiscordTogether(this);

View file

@ -10,7 +10,9 @@ class Transactions extends BaseCommand {
super({ super({
command: new SlashCommandBuilder() command: new SlashCommandBuilder()
.setName("transactions") .setName("transactions")
.setDescription(client.translate("economy/transactions:DESCRIPTION")), .setDescription(client.translate("economy/transactions:DESCRIPTION"))
.addBooleanOption(option => option.setName("clear")
.setDescription(client.translate("economy/translactions:CLEAR"))),
aliases: [], aliases: [],
dirname: __dirname, dirname: __dirname,
guildOnly: true, guildOnly: true,
@ -31,6 +33,13 @@ class Transactions extends BaseCommand {
* @param {Object} data * @param {Object} data
*/ */
async execute(client, interaction, data) { async execute(client, interaction, data) {
if (interaction.options.getBoolean("clear")) {
data.memberData.transactions = [];
await data.memberData.save();
return interaction.success("economy/transactions:CLEARED", null, { ephemeral: true });
}
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
.setAuthor({ .setAuthor({
name: interaction.translate("economy/transactions:EMBED_TRANSACTIONS"), name: interaction.translate("economy/transactions:EMBED_TRANSACTIONS"),

View file

@ -35,22 +35,26 @@ class Play extends BaseCommand {
*/ */
async execute(client, interaction) { async execute(client, interaction) {
await interaction.deferReply(); await interaction.deferReply();
const voice = interaction.member.voice.channel; const voice = interaction.member.voice.channel;
if (!voice) return interaction.editReply({ content: interaction.translate("music/play:NO_VOICE_CHANNEL") }); if (!voice) return interaction.editReply({ content: interaction.translate("music/play:NO_VOICE_CHANNEL") });
const query = interaction.options.getString("query"); const query = interaction.options.getString("query");
const perms = voice.permissionsFor(client.user); const perms = voice.permissionsFor(client.user);
if (!perms.has(PermissionsBitField.Flags.Connect) || !perms.has(PermissionsBitField.Flags.Speak)) return interaction.editReply({ content: interaction.translate("music/play:VOICE_CHANNEL_CONNECT") }); if (!perms.has(PermissionsBitField.Flags.Connect) || !perms.has(PermissionsBitField.Flags.Speak)) return interaction.editReply({ content: interaction.translate("music/play:VOICE_CHANNEL_CONNECT") });
const searchResult = await client.player.search(query, { try {
requestedBy: interaction.user, var searchResult = await client.player.search(query, {
searchEngine: "jaba" requestedBy: interaction.user,
}).catch(() => {}); searchEngine: "jaba"
});
if (!searchResult || !searchResult.tracks.length) return interaction.editReply({ } catch (error) {
content: interaction.translate("music/play:NO_RESULT", { return interaction.editReply({
query content: interaction.translate("music/play:NO_RESULT", {
}) query,
}); error
})
});
}
const queue = client.player.getQueue(interaction.guildId) || client.player.createQueue(interaction.guild, { const queue = client.player.getQueue(interaction.guildId) || client.player.createQueue(interaction.guild, {
metadata: { channel: interaction.channel }, metadata: { channel: interaction.channel },
@ -123,7 +127,6 @@ class Play extends BaseCommand {
.setTitle(interaction.translate("music/play:RESULTS_TITLE", { .setTitle(interaction.translate("music/play:RESULTS_TITLE", {
query query
})) }))
.setThumbnail(interaction.client.user.avatarURL())
.setColor(client.config.embed.color) .setColor(client.config.embed.color)
.setDescription(searchResult.tracks.map(track => { .setDescription(searchResult.tracks.map(track => {
const views = new Intl.NumberFormat(interaction.client.languages.find(language => language.name === interaction.guild.data.language).moment, { const views = new Intl.NumberFormat(interaction.client.languages.find(language => language.name === interaction.guild.data.language).moment, {
@ -155,24 +158,19 @@ class Play extends BaseCommand {
if (!queue.connection) await queue.connect(interaction.member.voice.channel); if (!queue.connection) await queue.connect(interaction.member.voice.channel);
if (!queue.playing) await queue.play(); if (!queue.playing) await queue.play();
rows.forEach(row => {
row.components.forEach(component => {
component.setDisabled(true);
});
});
return interaction.editReply({ return interaction.editReply({
content: interaction.translate("music/play:ADDED_QUEUE", { content: interaction.translate("music/play:ADDED_QUEUE", {
songName: selected.title songName: selected.title
}), }),
components: [row1, row2, row3] components: [],
embeds: []
}); });
} catch (e) { } catch (error) {
client.player.deleteQueue(interaction.guildId); client.player.deleteQueue(interaction.guildId);
console.error(e); console.log(error);
return interaction.editReply({ return interaction.editReply({
content: interaction.translate("music/play:ERR_OCCURRED", { content: interaction.translate("music/play:ERR_OCCURRED", {
error: e error
}) })
}); });
} }
@ -220,12 +218,12 @@ class Play extends BaseCommand {
songName: searchResult.playlist ? searchResult.playlist.title : searchResult.tracks[0].title songName: searchResult.playlist ? searchResult.playlist.title : searchResult.tracks[0].title
}) })
}); });
} catch (e) { } catch (error) {
client.player.deleteQueue(interaction.guildId); client.player.deleteQueue(interaction.guildId);
console.error(e); console.log(error);
return interaction.editReply({ return interaction.editReply({
content: interaction.translate("music/play:ERR_OCCURRED", { content: interaction.translate("music/play:ERR_OCCURRED", {
error: e error
}) })
}); });
} }

View file

@ -32,8 +32,6 @@ module.exports = {
name: "XXXXXXXXXXX#1234" // And the name of the bot's owner name: "XXXXXXXXXXX#1234" // And the name of the bot's owner
}, },
/* The API keys that are required for certain commands */ /* The API keys that are required for certain commands */
apiKeys: { /* Not used right now */
// AMETHYSTE: https://api.amethyste.moe apiKeys: {}
amethyste: "XXXXXXXXXXX"
}
}; };

View file

@ -1,3 +1,11 @@
### JaBa v4.1.3
* Добавлено
* Возможность принудительной очистки транзакций с помощью *transactions clear:True*
* Изменения
* Сделал перепись населения буквам в коде, теперь их меньше.
* Переделал обработку ошибок в *play*, теперь она говорит ошибку, а не считает её неизвестной.
### JaBa v4.1.2 ### JaBa v4.1.2
* Добавлено * Добавлено
* Выбор при поиске текстом через команду *play*. * Выбор при поиске текстом через команду *play*.

View file

@ -88,9 +88,8 @@ class DiscordTogether {
/** /**
* @param {String} code The invite link (only use the blue link) * @param {String} code The invite link (only use the blue link)
*/ */
const returnData = { const returnData = { code: "none" };
code: "none",
};
if (option && this.applications.find(apps => apps.id === option).id) { if (option && this.applications.find(apps => apps.id === option).id) {
const applicationID = this.applications.find(apps => apps.id === option).id; const applicationID = this.applications.find(apps => apps.id === option).id;
try { try {
@ -107,9 +106,9 @@ class DiscordTogether {
Authorization: `Bot ${this.client.config.token}`, Authorization: `Bot ${this.client.config.token}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}).then((res) => res.json()) }).then(res => res.json())
.then((invite) => { .then(invite => {
if (invite.error || !invite.code) throw new Error("An error occured while retrieving data !"); if (invite.error || !invite.code) throw new Error("An error occured while retrieving data!");
if (Number(invite.code) === 50013) console.warn("Your bot lacks permissions to perform that action"); if (Number(invite.code) === 50013) console.warn("Your bot lacks permissions to perform that action");
returnData.code = `https://discord.com/invite/${invite.code}`; returnData.code = `https://discord.com/invite/${invite.code}`;
}); });
@ -118,12 +117,9 @@ class DiscordTogether {
} }
return returnData; return returnData;
} else { } else {
throw new SyntaxError("Invalid option !"); throw new SyntaxError("Invalid option!");
} }
} }
} }
module.exports = { module.exports = { DiscordTogether, defaultApplications };
DiscordTogether,
defaultApplications
};

View file

@ -267,7 +267,7 @@ module.exports = {
return resolve({ playlist: null, info: null }); return resolve({ playlist: null, info: null });
} catch (error) { } catch (error) {
console.log(`Extractor: An error occurred while attempting to resolve ${query} :\n${error}`); console.log(`Extractor: An error occurred while attempting to resolve ${query} :\n${error}`);
return resolve({ playlist: null, info: null }); return reject(error);
} }
}); });
} }

View file

@ -1,5 +1,5 @@
const i18next = require("i18next"), const i18next = require("i18next"),
Backend = require("i18next-node-fs-backend"), Backend = require("i18next-fs-backend"),
path = require("path"), path = require("path"),
fs = require("fs").promises; fs = require("fs").promises;

View file

@ -2,7 +2,9 @@
"DESCRIPTION": "Посмотреть историю транзакций", "DESCRIPTION": "Посмотреть историю транзакций",
"USAGE": "", "USAGE": "",
"EXAMPLES": "transactions", "EXAMPLES": "transactions",
"NO_TRANSACTIONS": "У вас нет транзакций.", "CLEAR": "Очистить список транзакций?",
"CLEARED": "Список транзакций очищен",
"NO_TRANSACTIONS": "У вас нет транзакций",
"EMBED_TRANSACTIONS": "Ваши транзакции", "EMBED_TRANSACTIONS": "Ваши транзакции",
"BANK": "Банк", "BANK": "Банк",
"NUMBERS": "Угадай число", "NUMBERS": "Угадай число",

View file

@ -7,12 +7,12 @@
"VOICE_CHANNEL_CONNECT": "Я не могу присоедениться к вашему голосовому каналу!", "VOICE_CHANNEL_CONNECT": "Я не могу присоедениться к вашему голосовому каналу!",
"SEARCH_RESULTS": "Я нашёл данные видео на просторах Youtube'а! Выберите что-то одно с помощью кнопок ниже.", "SEARCH_RESULTS": "Я нашёл данные видео на просторах Youtube'а! Выберите что-то одно с помощью кнопок ниже.",
"RESULTS_TITLE": "Результаты поиска по \"{{query}}\"", "RESULTS_TITLE": "Результаты поиска по \"{{query}}\"",
"NO_RESULT": "Произошла неизвестная ошибка при поиске `{{query}}`! Скорее всего это видео имеет ограничение по возрасту.", "NO_RESULT": "Произошла ошибка при поиске `{{query}}`!\n```{{error}}```",
"NOW_PLAYING": "Сейчас играет **{{songName}}**", "NOW_PLAYING": "Сейчас играет **{{songName}}**",
"NOT_PLAYING": "На сервере сейчас ничего не воспроизводится", "NOT_PLAYING": "На сервере сейчас ничего не воспроизводится",
"QUEUE_ENDED": "Очередь окончена", "QUEUE_ENDED": "Очередь окончена",
"ADDED_QUEUE": "**{{songName}}** добавлен в очередь", "ADDED_QUEUE": "**{{songName}}** добавлен в очередь",
"STOP_DISCONNECTED": "Воспроизведение окончено, т.к. я вышел из голосового канала.", "STOP_DISCONNECTED": "Воспроизведение окончено, т.к. я вышел из голосового канала.",
"STOP_EMPTY": "Воспроизведение окончено, т.к. все вышли из голосового канала.", "STOP_EMPTY": "Воспроизведение окончено, т.к. все вышли из голосового канала.",
"ERR_OCCURRED": "Произошла ошибка...\n`{{error}}`" "ERR_OCCURRED": "Произошла ошибка...\n```{{error}}```"
} }

View file

@ -6,7 +6,7 @@
"VOICE_CHANNEL_CONNECT": "Я не можу приєднатися до вашого голосового каналу!", "VOICE_CHANNEL_CONNECT": "Я не можу приєднатися до вашого голосового каналу!",
"MISSING_SONG_NAME": "Вкажіть назву треку або посилання на нього!", "MISSING_SONG_NAME": "Вкажіть назву треку або посилання на нього!",
"RESULTS_FOOTER": "Вкажіть число від 1 до 10 (без префіксу).", "RESULTS_FOOTER": "Вкажіть число від 1 до 10 (без префіксу).",
"NO_RESULT": "Нічого не знайдено!", "NO_RESULT": "Нічого не знайдено!\n```{{error}}```",
"NOW_PLAYING": "Зараз грає **{{songName}}**", "NOW_PLAYING": "Зараз грає **{{songName}}**",
"PLAYING_PLAYLIST": "Починається відтворення плейлиста **{{playlistTitle}}**. {{playlistEmoji}}\nПочато відтворення першого треку, **{{songName}}**!", "PLAYING_PLAYLIST": "Починається відтворення плейлиста **{{playlistTitle}}**. {{playlistEmoji}}\nПочато відтворення першого треку, **{{songName}}**!",
"CANCELLED": "Вибір скасовано", "CANCELLED": "Вибір скасовано",

1670
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{ {
"name": "jaba", "name": "jaba",
"version": "4.1.2", "version": "4.1.3",
"description": "My Discord Bot", "description": "My Discord Bot",
"main": "index.js", "main": "index.js",
"private": true, "private": true,
@ -16,12 +16,11 @@
"@discordjs/opus": "^0.8.0", "@discordjs/opus": "^0.8.0",
"@discordjs/rest": "^1.1.0", "@discordjs/rest": "^1.1.0",
"@discordjs/voice": "^0.11.0", "@discordjs/voice": "^0.11.0",
"amethyste-api": "github:Androz2091/amethyste-api",
"btoa": "^1.2.1", "btoa": "^1.2.1",
"canvacord": "^5.1.0", "canvacord": "^5.1.0",
"canvas": "^2.9.0", "canvas": "^2.9.0",
"chalk": "^4.1.0", "chalk": "^4.1.2",
"cron": "^1.7.2", "cron": "^2.1.0",
"discord-api-types": "^0.37.5", "discord-api-types": "^0.37.5",
"discord-giveaways": "^6.0.1", "discord-giveaways": "^6.0.1",
"discord-player": "github:JonnyBro/discord-player", "discord-player": "github:JonnyBro/discord-player",
@ -29,21 +28,21 @@
"ejs": "^3.1.3", "ejs": "^3.1.3",
"express": "^4.17.1", "express": "^4.17.1",
"express-session": "^1.17.0", "express-session": "^1.17.0",
"ffmpeg-static": "^4.4.1", "ffmpeg-static": "^5.1.0",
"gamedig": "^4.0.2", "gamedig": "^4.0.2",
"i18next": "^20.2.2", "i18next": "^21.9.1",
"i18next-node-fs-backend": "^2.1.3", "i18next-fs-backend": "^1.1.5",
"libsodium-wrappers": "^0.7.10", "libsodium-wrappers": "^0.7.10",
"markdown-table": "2.0.0", "markdown-table": "^2.0.0",
"md5": "^2.2.1", "md5": "^2.2.1",
"moment": "^2.26.0", "moment": "^2.26.0",
"mongoose": "^5.13.14", "mongoose": "^5.13.15",
"ms": "^2.1.3", "ms": "^2.1.3",
"play-dl": "^1.9.5", "play-dl": "^1.9.5",
"prism-media": "^1.3.4" "prism-media": "^1.3.4"
}, },
"devDependencies": { "devDependencies": {
"eslint": "^7.5.0" "eslint": "^8.23.0"
}, },
"eslintConfig": { "eslintConfig": {
"env": { "env": {