mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-22 05:04:58 +05:00
extend the User object other than using a function
This commit is contained in:
parent
76e8d16eb1
commit
ec79480bcb
15 changed files with 34 additions and 38 deletions
|
@ -64,7 +64,7 @@ class Money extends BaseCommand {
|
|||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: interaction.translate("economy/money:TITLE", {
|
||||
user: client.functions.getUsername(member.user),
|
||||
user: member.user.getUsername(),
|
||||
}),
|
||||
iconURL: member.user.displayAvatarURL(),
|
||||
})
|
||||
|
|
|
@ -71,7 +71,7 @@ class Pay extends BaseCommand {
|
|||
await memberData.save();
|
||||
|
||||
const info1 = {
|
||||
user: client.functions.getUsername(member.user),
|
||||
user: member.user.getUsername(),
|
||||
amount: amount,
|
||||
date: Date.now(),
|
||||
type: "send",
|
||||
|
@ -79,7 +79,7 @@ class Pay extends BaseCommand {
|
|||
data.memberData.transactions.push(info1);
|
||||
|
||||
const info2 = {
|
||||
user: client.functions.getUsername(member.user),
|
||||
user: member.user.getUsername(),
|
||||
amount: amount,
|
||||
date: Date.now(),
|
||||
type: "got",
|
||||
|
|
|
@ -127,7 +127,7 @@ class Profile extends BaseCommand {
|
|||
},
|
||||
{
|
||||
name: interaction.translate("economy/profile:LOVER"),
|
||||
value: (!userData.lover ? interaction.translate("common:NOT_DEFINED") : client.functions.getUsername(lover)),
|
||||
value: (!userData.lover ? interaction.translate("common:NOT_DEFINED") : lover.getUsername()),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -60,7 +60,7 @@ class Report extends BaseCommand {
|
|||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: interaction.translate("general/report:TITLE", {
|
||||
user: client.functions.getUsername(member.user),
|
||||
user: member.user.getUsername(),
|
||||
}),
|
||||
iconURL: interaction.user.displayAvatarURL({
|
||||
extension: "png",
|
||||
|
|
|
@ -50,7 +50,7 @@ class Suggest extends BaseCommand {
|
|||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: interaction.translate("general/suggest:TITLE", {
|
||||
user: client.functions.getUsername(interaction.user),
|
||||
user: interaction.user.getUsername(),
|
||||
}),
|
||||
iconURL: interaction.member.displayAvatarURL(),
|
||||
})
|
||||
|
|
|
@ -44,7 +44,7 @@ class Userinfo extends BaseCommand {
|
|||
const member = interaction.options.getMember("user") || interaction.member;
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: `${client.functions.getUsername(member.user)} (${member.id})`,
|
||||
name: `${member.user.getUsername()} (${member.id})`,
|
||||
iconURL: member.displayAvatarURL(),
|
||||
})
|
||||
.setThumbnail(member.displayAvatarURL({
|
||||
|
@ -53,7 +53,7 @@ class Userinfo extends BaseCommand {
|
|||
.addFields([
|
||||
{
|
||||
name: ":man: " + interaction.translate("common:USERNAME"),
|
||||
value: client.functions.getUsername(member.user),
|
||||
value: member.user.getUsername(),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -137,7 +137,7 @@ class Clear extends BaseCommand {
|
|||
if (member || user_id) {
|
||||
interaction.replyT("moderation/clear:CLEARED_MEMBER", {
|
||||
amount: `**${option}** ${client.functions.getNoun(option, interaction.translate("misc:NOUNS:MESSAGES:1"), interaction.translate("misc:NOUNS:MESSAGES:2"), interaction.translate("misc:NOUNS:MESSAGES:5"))}`,
|
||||
user: member && client.functions.getUsername(member.user) || user_id,
|
||||
user: member && member.user.getUsername() || user_id,
|
||||
}, { edit: true });
|
||||
} else {
|
||||
interaction.replyT("moderation/clear:CLEARED", {
|
||||
|
|
|
@ -47,7 +47,7 @@ class Warn extends BaseCommand {
|
|||
|
||||
const modal = new ModalBuilder()
|
||||
.setCustomId("warn_modal")
|
||||
.setTitle(interaction.translate("moderation/warn:MODAL_TITLE", { nickname: client.functions.getUsername(member.user) }).normalize("NFKD"));
|
||||
.setTitle(interaction.translate("moderation/warn:MODAL_TITLE", { nickname: member.user.getUsername() }).normalize("NFKD"));
|
||||
|
||||
const reasonInput = new TextInputBuilder()
|
||||
.setCustomId("warn_reason")
|
||||
|
@ -89,11 +89,11 @@ class Warn extends BaseCommand {
|
|||
.addFields([
|
||||
{
|
||||
name: interaction.translate("common:USER"),
|
||||
value: `\`${client.functions.getUsername(member.user)}\` (${member.user.toString()})`,
|
||||
value: `\`${member.user.getUsername()}\` (${member.user.toString()})`,
|
||||
},
|
||||
{
|
||||
name: interaction.translate("common:MODERATOR"),
|
||||
value: `\`${client.functions.getUsername(interaction.user)}\` (${interaction.user.toString()})`,
|
||||
value: `\`${interaction.user.getUsername()}\` (${interaction.user.toString()})`,
|
||||
},
|
||||
{
|
||||
name: interaction.translate("common:REASON"),
|
||||
|
@ -107,7 +107,7 @@ class Warn extends BaseCommand {
|
|||
member.send({
|
||||
content: interaction.translate("moderation/ban:BANNED_DM", {
|
||||
user: member.user,
|
||||
moderator: client.functions.getUsername(interaction.user),
|
||||
moderator: interaction.user.getUsername(),
|
||||
server: interaction.guild.name,
|
||||
reason,
|
||||
}),
|
||||
|
@ -125,7 +125,7 @@ class Warn extends BaseCommand {
|
|||
|
||||
interaction.followUp({
|
||||
content: interaction.translate("moderation/setwarns:AUTO_BAN", {
|
||||
user: client.functions.getUsername(member.user),
|
||||
user: member.user.getUsername(),
|
||||
count: `${banCount} ${client.functions.getNoun(banCount, interaction.translate("misc:NOUNS:WARNS:1"), interaction.translate("misc:NOUNS:WARNS:2"), interaction.translate("misc:NOUNS:WARNS:5"))}`,
|
||||
}),
|
||||
});
|
||||
|
@ -137,7 +137,7 @@ class Warn extends BaseCommand {
|
|||
member.send({
|
||||
content: interaction.translate("moderation/kick:KICKED_DM", {
|
||||
user: member.user,
|
||||
moderator: client.functions.getUsername(interaction.user),
|
||||
moderator: interaction.user.getUsername(),
|
||||
server: interaction.guild.name,
|
||||
reason,
|
||||
}),
|
||||
|
@ -155,7 +155,7 @@ class Warn extends BaseCommand {
|
|||
|
||||
interaction.followUp({
|
||||
content: interaction.translate("moderation/setwarns:AUTO_KICK", {
|
||||
user: client.functions.getUsername(member.user),
|
||||
user: member.user.getUsername(),
|
||||
count: `${kickCount} ${client.functions.getNoun(kickCount, interaction.translate("misc:NOUNS:WARNS:1"), interaction.translate("misc:NOUNS:WARNS:2"), interaction.translate("misc:NOUNS:WARNS:5"))}`,
|
||||
}),
|
||||
});
|
||||
|
@ -164,9 +164,9 @@ class Warn extends BaseCommand {
|
|||
*/
|
||||
member.send({
|
||||
content: interaction.translate("moderation/warn:WARNED_DM", {
|
||||
user: client.functions.getUsername(member.user),
|
||||
user: member.user.getUsername(),
|
||||
server: interaction.guild.name,
|
||||
moderator: client.functions.getUsername(interaction.user),
|
||||
moderator: interaction.user.getUsername(),
|
||||
reason,
|
||||
}),
|
||||
});
|
||||
|
|
|
@ -55,7 +55,7 @@ class CommandHandler extends BaseEvent {
|
|||
interaction.user.send(args);
|
||||
}
|
||||
|
||||
client.logger.log(`User ${client.functions.getUsername(interaction.user)} used ${command.command.name} in ${interaction.guild ? interaction.guild.name : "DM"} with arguments: ${interaction.options.data.length > 0 ? interaction.options.data.map(arg => { return `${arg.name}: ${arg.value}`; }).join(", ") : "no args"}`, "cmd");
|
||||
client.logger.log(`User ${interaction.user.getUsername()} used ${command.command.name} in ${interaction.guild ? interaction.guild.name : "DM"} with arguments: ${interaction.options.data.length > 0 ? interaction.options.data.map(arg => { return `${arg.name}: ${arg.value}`; }).join(", ") : "no args"}`, "cmd");
|
||||
|
||||
return command.execute(client, interaction, data);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class GuildMemberRemove extends BaseEvent {
|
|||
|
||||
if (channel) {
|
||||
const message = guildData.plugins.goodbye.message
|
||||
.replace(/{user}/g, client.functions.getUsername(member.user))
|
||||
.replace(/{user}/g, member.user.getUsername())
|
||||
.replace(/{server}/g, member.guild.name)
|
||||
.replace(/{membercount}/g, member.guild.memberCount);
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ class MessageCreate extends BaseEvent {
|
|||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: message.translate("misc:QUOTE_TITLE", {
|
||||
user: client.functions.getUsername(msg.author),
|
||||
user: msg.author.getUsername(),
|
||||
}),
|
||||
iconURL: "https://wynem.com/assets/images/icons/quote.webp",
|
||||
})
|
||||
|
@ -64,7 +64,7 @@ class MessageCreate extends BaseEvent {
|
|||
},
|
||||
])
|
||||
.setFooter({
|
||||
text: message.translate("misc:QUOTE_FOOTER", { user: client.functions.getUsername(message.author) }),
|
||||
text: message.translate("misc:QUOTE_FOOTER", { user: message.author.getUsername() }),
|
||||
})
|
||||
.setColor(client.config.embed.color)
|
||||
.setTimestamp(msg.createdTimestamp);
|
||||
|
@ -116,7 +116,7 @@ class MessageCreate extends BaseEvent {
|
|||
id: u.id,
|
||||
});
|
||||
|
||||
if (userData.afk) message.replyT("general/afk:IS_AFK", { user: client.functions.getUsername(u), reason: userData.afk }, { ephemeral: true });
|
||||
if (userData.afk) message.replyT("general/afk:IS_AFK", { user: u.getUsername(), reason: userData.afk }, { ephemeral: true });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class Ready extends BaseEvent {
|
|||
if (client.config.dashboard.enabled) await client.dashboard.load(client);
|
||||
|
||||
client.logger.log(`Loaded a total of ${commands.length} command(s).`, "ready");
|
||||
client.logger.log(`${client.functions.getUsername(client.user)}, ready to serve ${tUsers} members in ${tServers} servers.`, "ready");
|
||||
client.logger.log(`${client.user.getUsername()}, ready to serve ${tUsers} members in ${tServers} servers.`, "ready");
|
||||
client.logger.log(`Invite Link: ${client.generateInvite({ scopes: ["bot", "applications.commands"], permissions: [ PermissionsBitField.Flags.Administrator ] })}`, "ready");
|
||||
|
||||
console.timeEnd("botReady");
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
const { Message, BaseInteraction } = require("discord.js");
|
||||
const { Message, BaseInteraction, User } = require("discord.js");
|
||||
|
||||
User.prototype.getUsername = function () {
|
||||
return this.discriminator === "0" ? this.username : this.tag;
|
||||
};
|
||||
|
||||
BaseInteraction.prototype.translate = function (key, args) {
|
||||
const language = this.client.translations.get(this.guild ? (this.guild.data ? this.guild.data.language : "ru-RU") : "ru-RU");
|
||||
|
|
|
@ -132,18 +132,10 @@ module.exports = {
|
|||
n %= 100;
|
||||
if (n >= 5 && n <= 20) return five;
|
||||
n %= 10;
|
||||
|
||||
if (n === 1) return one;
|
||||
if (n >= 2 && n <= 4) return two;
|
||||
|
||||
return five;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns just a username if user has a new username, else returns user's tag
|
||||
* @param {import("discord.js").User} user Number
|
||||
* @returns
|
||||
*/
|
||||
getUsername(user) {
|
||||
return user.discriminator === "0" ? user.username : user.tag;
|
||||
},
|
||||
};
|
|
@ -69,10 +69,10 @@ async function tictactoe(interaction, options = {}) {
|
|||
|
||||
const acceptEmbed = new EmbedBuilder()
|
||||
.setTitle(interaction.translate("fun/tictactoe:REQUEST_WAIT", {
|
||||
user: client.functions.getUsername(opponent),
|
||||
user: opponent.getUsername(),
|
||||
}))
|
||||
.setAuthor({
|
||||
name: client.functions.getUsername(user),
|
||||
name: user.getUsername(),
|
||||
iconURL: user.displayAvatarURL(),
|
||||
})
|
||||
.setColor(options.embedColor || "#075FFF")
|
||||
|
@ -832,7 +832,7 @@ async function tictactoe(interaction, options = {}) {
|
|||
const embed = new EmbedBuilder()
|
||||
.setTitle(interaction.translate("fun/tictactoe:NO_ANSWER_TITLE"))
|
||||
.setAuthor({
|
||||
name: client.functions.getUsername(user),
|
||||
name: user.getUsername(),
|
||||
iconURL: user.displayAvatarURL(),
|
||||
})
|
||||
.setColor(options.timeoutEmbedColor || "#C90000")
|
||||
|
@ -851,7 +851,7 @@ async function tictactoe(interaction, options = {}) {
|
|||
const embed = new EmbedBuilder()
|
||||
.setTitle(interaction.translate("fun/tictactoe:CANCELED"))
|
||||
.setAuthor({
|
||||
name: client.functions.getUsername(user),
|
||||
name: user.getUsername(),
|
||||
iconURL: user.displayAvatarURL(),
|
||||
})
|
||||
.setColor(options.timeoutEmbedColor || "#C90000")
|
||||
|
|
Loading…
Reference in a new issue