2022-07-31 17:08:00 +05:00
|
|
|
const { Message, CommandInteraction } = require("discord.js");
|
2022-01-04 02:18:28 +05:00
|
|
|
|
2022-07-31 17:08:00 +05:00
|
|
|
CommandInteraction.prototype.translate = function (key, args) {
|
2022-07-23 17:14:42 +05:00
|
|
|
const language = this.client.translations.get(this.guild ? this.guild.data.language : "ru-RU");
|
2022-01-04 02:18:28 +05:00
|
|
|
if (!language) throw "Message: Invalid language set in data.";
|
|
|
|
|
|
|
|
return language(key, args);
|
|
|
|
};
|
|
|
|
|
2022-07-31 17:08:00 +05:00
|
|
|
CommandInteraction.prototype.replyT = function (key, args, options = {}) {
|
2022-07-26 17:20:10 +05:00
|
|
|
let string = this.translate(key, args, this.guild ? this.guild.data.language : "ru-RU");
|
|
|
|
if (options.prefixEmoji) string = `${this.client.customEmojis[options.prefixEmoji]} | ${string}`;
|
2022-01-04 02:18:28 +05:00
|
|
|
|
2022-07-31 17:08:00 +05:00
|
|
|
if (options.edit) return this.editReply({ content: string, ephemeral: options.ephemeral || false });
|
|
|
|
else return this.reply({ content: string, ephemeral: options.ephemeral || false });
|
2022-01-04 02:18:28 +05:00
|
|
|
};
|
|
|
|
|
2022-07-31 17:08:00 +05:00
|
|
|
CommandInteraction.prototype.error = function (key, args, options = {}) {
|
2022-01-04 02:18:28 +05:00
|
|
|
options.prefixEmoji = "error";
|
|
|
|
|
2022-07-26 17:20:10 +05:00
|
|
|
return this.replyT(key, args, options);
|
2022-01-04 02:18:28 +05:00
|
|
|
};
|
|
|
|
|
2022-07-31 17:08:00 +05:00
|
|
|
CommandInteraction.prototype.success = function (key, args, options = {}) {
|
2022-01-04 02:18:28 +05:00
|
|
|
options.prefixEmoji = "success";
|
|
|
|
|
2022-07-26 17:20:10 +05:00
|
|
|
return this.replyT(key, args, options);
|
2022-01-04 02:18:28 +05:00
|
|
|
};
|
|
|
|
|
2022-07-31 17:08:00 +05:00
|
|
|
Message.prototype.translate = function (key, args) {
|
2022-07-26 17:20:10 +05:00
|
|
|
const language = this.client.translations.get(this.guild ? this.guild.data.language : "ru-RU");
|
|
|
|
if (!language) throw "Message: Invalid language set in data.";
|
2022-01-04 02:18:28 +05:00
|
|
|
|
2022-07-26 17:20:10 +05:00
|
|
|
return language(key, args);
|
2022-01-04 02:18:28 +05:00
|
|
|
};
|
|
|
|
|
2022-07-31 17:08:00 +05:00
|
|
|
Message.prototype.replyT = function (key, args, options = {}) {
|
2022-07-26 17:20:10 +05:00
|
|
|
let string = this.translate(key, args, this.guild ? this.guild.data.language : "ru-RU");
|
|
|
|
if (options.prefixEmoji) string = `${this.client.customEmojis[options.prefixEmoji]} | ${string}`;
|
|
|
|
|
2022-07-31 17:08:00 +05:00
|
|
|
if (options.edit) return this.edit({ content: string });
|
|
|
|
else return this.reply({ content: string });
|
2022-01-04 02:18:28 +05:00
|
|
|
};
|
|
|
|
|
2022-07-31 17:08:00 +05:00
|
|
|
Message.prototype.error = function (key, args, options = {}) {
|
2022-07-26 17:20:10 +05:00
|
|
|
options.prefixEmoji = "error";
|
|
|
|
|
|
|
|
return this.replyT(key, args, options);
|
2022-01-04 02:18:28 +05:00
|
|
|
};
|
|
|
|
|
2022-07-31 17:08:00 +05:00
|
|
|
Message.prototype.success = function (key, args, options = {}) {
|
2022-07-26 17:20:10 +05:00
|
|
|
options.prefixEmoji = "success";
|
|
|
|
|
|
|
|
return this.replyT(key, args, options);
|
2022-01-04 02:18:28 +05:00
|
|
|
};
|