2022-07-23 17:14:42 +05:00
|
|
|
const { Guild, Message } = require("discord.js");
|
2022-01-04 02:18:28 +05:00
|
|
|
|
|
|
|
Guild.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);
|
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Wrapper for sendT with error emoji
|
|
|
|
Message.prototype.error = function (key, args, options = {}) {
|
|
|
|
options.prefixEmoji = "error";
|
|
|
|
|
|
|
|
return this.sendT(key, args, options);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Wrapper for sendT with success emoji
|
|
|
|
Message.prototype.success = function (key, args, options = {}) {
|
|
|
|
options.prefixEmoji = "success";
|
|
|
|
|
|
|
|
return this.sendT(key, args, options);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Translate and send the message
|
|
|
|
Message.prototype.sendT = function (key, args, options = {}) {
|
|
|
|
let string = this.translate(key, args);
|
|
|
|
if (options.prefixEmoji) string = `${this.client.customEmojis[options.prefixEmoji]} | ${string}`;
|
|
|
|
|
|
|
|
if (options.edit) return this.edit(string);
|
2022-02-05 21:05:09 +05:00
|
|
|
else return this.reply({ content: string });
|
2022-01-04 02:18:28 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
// Format a date
|
|
|
|
Message.prototype.printDate = function (date, format) {
|
|
|
|
return this.client.printDate(date, format, this.guild.data.language);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Convert time
|
|
|
|
Message.prototype.convertTime = function (time, type, noPrefix) {
|
|
|
|
return this.client.convertTime(time, type, noPrefix, (this.guild && this.guild.data) ? this.guild.data.language : null);
|
|
|
|
};
|
|
|
|
|
2022-01-05 00:24:57 +05:00
|
|
|
Message.prototype.getNoun = function (number, one, two, five) {
|
2022-01-04 02:18:28 +05:00
|
|
|
return this.client.getNoun(number, one, two, five);
|
|
|
|
};
|