mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-22 05:04:58 +05:00
82 lines
No EOL
2.4 KiB
JavaScript
82 lines
No EOL
2.4 KiB
JavaScript
const { Message, CommandInteraction } = require("discord.js");
|
|
|
|
/**
|
|
*
|
|
* @param {String} key
|
|
* @param {Array} args
|
|
* @returns {String}
|
|
*/
|
|
CommandInteraction.prototype.translate = function (key, args) {
|
|
const language = this.client.translations.get(this.guild ? this.guild.data.language : "ru-RU");
|
|
if (!language) throw "Message: Invalid language set in data.";
|
|
|
|
return language(key, args);
|
|
};
|
|
|
|
/**
|
|
*
|
|
* @param {String} key
|
|
* @param {Array} args
|
|
* @param {Array} options
|
|
* @returns {import("discord.js").BaseCommandInteraction}
|
|
*/
|
|
CommandInteraction.prototype.replyT = function (key, args, options = {}) {
|
|
let string = this.translate(key, args, this.guild ? this.guild.data.language : "ru-RU");
|
|
if (options.prefixEmoji) string = `${this.client.customEmojis[options.prefixEmoji]} | ${string}`;
|
|
|
|
if (options.edit) return this.editReply({ content: string, ephemeral: options.ephemeral || false });
|
|
else return this.reply({ content: string, ephemeral: options.ephemeral || false });
|
|
};
|
|
|
|
/**
|
|
*
|
|
* @param {String} key
|
|
* @param {Array} args
|
|
* @param {Array} options
|
|
* @returns {import("discord.js").BaseCommandInteraction}
|
|
*/
|
|
CommandInteraction.prototype.error = function (key, args, options = {}) {
|
|
options.prefixEmoji = "error";
|
|
|
|
return this.replyT(key, args, options);
|
|
};
|
|
|
|
/**
|
|
*
|
|
* @param {String} key
|
|
* @param {Array} args
|
|
* @param {Array} options
|
|
* @returns {import("discord.js").BaseCommandInteraction}
|
|
*/
|
|
CommandInteraction.prototype.success = function (key, args, options = {}) {
|
|
options.prefixEmoji = "success";
|
|
|
|
return this.replyT(key, args, options);
|
|
};
|
|
|
|
Message.prototype.translate = function (key, args) {
|
|
const language = this.client.translations.get(this.guild ? this.guild.data.language : "ru-RU");
|
|
if (!language) throw "Message: Invalid language set in data.";
|
|
|
|
return language(key, args);
|
|
};
|
|
|
|
Message.prototype.replyT = function (key, args, options = {}) {
|
|
let string = this.translate(key, args, this.guild ? this.guild.data.language : "ru-RU");
|
|
if (options.prefixEmoji) string = `${this.client.customEmojis[options.prefixEmoji]} | ${string}`;
|
|
|
|
if (options.edit) return this.edit({ content: string });
|
|
else return this.reply({ content: string });
|
|
};
|
|
|
|
Message.prototype.error = function (key, args, options = {}) {
|
|
options.prefixEmoji = "error";
|
|
|
|
return this.replyT(key, args, options);
|
|
};
|
|
|
|
Message.prototype.success = function (key, args, options = {}) {
|
|
options.prefixEmoji = "success";
|
|
|
|
return this.replyT(key, args, options);
|
|
}; |