mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-25 14:44:58 +05:00
getUsername function
This commit is contained in:
parent
55a4734926
commit
76e8d16eb1
14 changed files with 44 additions and 34 deletions
|
@ -64,7 +64,7 @@ class Money extends BaseCommand {
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor({
|
||||||
name: interaction.translate("economy/money:TITLE", {
|
name: interaction.translate("economy/money:TITLE", {
|
||||||
user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
|
user: client.functions.getUsername(member.user),
|
||||||
}),
|
}),
|
||||||
iconURL: member.user.displayAvatarURL(),
|
iconURL: member.user.displayAvatarURL(),
|
||||||
})
|
})
|
||||||
|
|
|
@ -71,7 +71,7 @@ class Pay extends BaseCommand {
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
const info1 = {
|
const info1 = {
|
||||||
user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
|
user: client.functions.getUsername(member.user),
|
||||||
amount: amount,
|
amount: amount,
|
||||||
date: Date.now(),
|
date: Date.now(),
|
||||||
type: "send",
|
type: "send",
|
||||||
|
@ -79,7 +79,7 @@ class Pay extends BaseCommand {
|
||||||
data.memberData.transactions.push(info1);
|
data.memberData.transactions.push(info1);
|
||||||
|
|
||||||
const info2 = {
|
const info2 = {
|
||||||
user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
|
user: client.functions.getUsername(member.user),
|
||||||
amount: amount,
|
amount: amount,
|
||||||
date: Date.now(),
|
date: Date.now(),
|
||||||
type: "got",
|
type: "got",
|
||||||
|
|
|
@ -127,7 +127,7 @@ class Profile extends BaseCommand {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: interaction.translate("economy/profile:LOVER"),
|
name: interaction.translate("economy/profile:LOVER"),
|
||||||
value: (!userData.lover ? interaction.translate("common:NOT_DEFINED") : lover.discriminator === "0" ? lover.username : lover.tag),
|
value: (!userData.lover ? interaction.translate("common:NOT_DEFINED") : client.functions.getUsername(lover)),
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,7 +60,7 @@ class Report extends BaseCommand {
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor({
|
||||||
name: interaction.translate("general/report:TITLE", {
|
name: interaction.translate("general/report:TITLE", {
|
||||||
user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
|
user: client.functions.getUsername(member.user),
|
||||||
}),
|
}),
|
||||||
iconURL: interaction.user.displayAvatarURL({
|
iconURL: interaction.user.displayAvatarURL({
|
||||||
extension: "png",
|
extension: "png",
|
||||||
|
|
|
@ -50,7 +50,7 @@ class Suggest extends BaseCommand {
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor({
|
||||||
name: interaction.translate("general/suggest:TITLE", {
|
name: interaction.translate("general/suggest:TITLE", {
|
||||||
user: interaction.user.discriminator === "0" ? interaction.user.username : interaction.user.tag,
|
user: client.functions.getUsername(interaction.user),
|
||||||
}),
|
}),
|
||||||
iconURL: interaction.member.displayAvatarURL(),
|
iconURL: interaction.member.displayAvatarURL(),
|
||||||
})
|
})
|
||||||
|
|
|
@ -44,7 +44,7 @@ class Userinfo extends BaseCommand {
|
||||||
const member = interaction.options.getMember("user") || interaction.member;
|
const member = interaction.options.getMember("user") || interaction.member;
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor({
|
||||||
name: `${member.user.discriminator === "0" ? member.user.username : member.user.tag} (${member.id})`,
|
name: `${client.functions.getUsername(member.user)} (${member.id})`,
|
||||||
iconURL: member.displayAvatarURL(),
|
iconURL: member.displayAvatarURL(),
|
||||||
})
|
})
|
||||||
.setThumbnail(member.displayAvatarURL({
|
.setThumbnail(member.displayAvatarURL({
|
||||||
|
@ -53,7 +53,7 @@ class Userinfo extends BaseCommand {
|
||||||
.addFields([
|
.addFields([
|
||||||
{
|
{
|
||||||
name: ":man: " + interaction.translate("common:USERNAME"),
|
name: ":man: " + interaction.translate("common:USERNAME"),
|
||||||
value: member.user.discriminator === "0" ? member.user.username : member.user.tag,
|
value: client.functions.getUsername(member.user),
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -137,7 +137,7 @@ class Clear extends BaseCommand {
|
||||||
if (member || user_id) {
|
if (member || user_id) {
|
||||||
interaction.replyT("moderation/clear:CLEARED_MEMBER", {
|
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"))}`,
|
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?.user.discriminator === "0" ? member?.user.username : member?.user.tag || user_id),
|
user: member && client.functions.getUsername(member.user) || user_id,
|
||||||
}, { edit: true });
|
}, { edit: true });
|
||||||
} else {
|
} else {
|
||||||
interaction.replyT("moderation/clear:CLEARED", {
|
interaction.replyT("moderation/clear:CLEARED", {
|
||||||
|
|
|
@ -47,7 +47,7 @@ class Warn extends BaseCommand {
|
||||||
|
|
||||||
const modal = new ModalBuilder()
|
const modal = new ModalBuilder()
|
||||||
.setCustomId("warn_modal")
|
.setCustomId("warn_modal")
|
||||||
.setTitle(interaction.translate("moderation/warn:MODAL_TITLE", { nickname: member.user.discriminator === "0" ? member.user.username : member.user.tag }).normalize("NFKD"));
|
.setTitle(interaction.translate("moderation/warn:MODAL_TITLE", { nickname: client.functions.getUsername(member.user) }).normalize("NFKD"));
|
||||||
|
|
||||||
const reasonInput = new TextInputBuilder()
|
const reasonInput = new TextInputBuilder()
|
||||||
.setCustomId("warn_reason")
|
.setCustomId("warn_reason")
|
||||||
|
@ -89,11 +89,11 @@ class Warn extends BaseCommand {
|
||||||
.addFields([
|
.addFields([
|
||||||
{
|
{
|
||||||
name: interaction.translate("common:USER"),
|
name: interaction.translate("common:USER"),
|
||||||
value: `\`${member.user.discriminator === "0" ? member.user.username : member.user.tag}\` (${member.user.toString()})`,
|
value: `\`${client.functions.getUsername(member.user)}\` (${member.user.toString()})`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: interaction.translate("common:MODERATOR"),
|
name: interaction.translate("common:MODERATOR"),
|
||||||
value: `\`${interaction.user.discriminator === "0" ? interaction.user.username : interaction.user.tag}\` (${interaction.user.toString()})`,
|
value: `\`${client.functions.getUsername(interaction.user)}\` (${interaction.user.toString()})`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: interaction.translate("common:REASON"),
|
name: interaction.translate("common:REASON"),
|
||||||
|
@ -107,7 +107,7 @@ class Warn extends BaseCommand {
|
||||||
member.send({
|
member.send({
|
||||||
content: interaction.translate("moderation/ban:BANNED_DM", {
|
content: interaction.translate("moderation/ban:BANNED_DM", {
|
||||||
user: member.user,
|
user: member.user,
|
||||||
moderator: interaction.user.discriminator === "0" ? interaction.user.username : interaction.user.tag,
|
moderator: client.functions.getUsername(interaction.user),
|
||||||
server: interaction.guild.name,
|
server: interaction.guild.name,
|
||||||
reason,
|
reason,
|
||||||
}),
|
}),
|
||||||
|
@ -125,7 +125,7 @@ class Warn extends BaseCommand {
|
||||||
|
|
||||||
interaction.followUp({
|
interaction.followUp({
|
||||||
content: interaction.translate("moderation/setwarns:AUTO_BAN", {
|
content: interaction.translate("moderation/setwarns:AUTO_BAN", {
|
||||||
user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
|
user: client.functions.getUsername(member.user),
|
||||||
count: `${banCount} ${client.functions.getNoun(banCount, interaction.translate("misc:NOUNS:WARNS:1"), interaction.translate("misc:NOUNS:WARNS:2"), interaction.translate("misc:NOUNS:WARNS:5"))}`,
|
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({
|
member.send({
|
||||||
content: interaction.translate("moderation/kick:KICKED_DM", {
|
content: interaction.translate("moderation/kick:KICKED_DM", {
|
||||||
user: member.user,
|
user: member.user,
|
||||||
moderator: interaction.user.discriminator === "0" ? interaction.user.username : interaction.user.tag,
|
moderator: client.functions.getUsername(interaction.user),
|
||||||
server: interaction.guild.name,
|
server: interaction.guild.name,
|
||||||
reason,
|
reason,
|
||||||
}),
|
}),
|
||||||
|
@ -155,7 +155,7 @@ class Warn extends BaseCommand {
|
||||||
|
|
||||||
interaction.followUp({
|
interaction.followUp({
|
||||||
content: interaction.translate("moderation/setwarns:AUTO_KICK", {
|
content: interaction.translate("moderation/setwarns:AUTO_KICK", {
|
||||||
user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
|
user: client.functions.getUsername(member.user),
|
||||||
count: `${kickCount} ${client.functions.getNoun(kickCount, interaction.translate("misc:NOUNS:WARNS:1"), interaction.translate("misc:NOUNS:WARNS:2"), interaction.translate("misc:NOUNS:WARNS:5"))}`,
|
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({
|
member.send({
|
||||||
content: interaction.translate("moderation/warn:WARNED_DM", {
|
content: interaction.translate("moderation/warn:WARNED_DM", {
|
||||||
user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
|
user: client.functions.getUsername(member.user),
|
||||||
server: interaction.guild.name,
|
server: interaction.guild.name,
|
||||||
moderator: interaction.user.discriminator === "0" ? interaction.user.username : interaction.user.tag,
|
moderator: client.functions.getUsername(interaction.user),
|
||||||
reason,
|
reason,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
|
@ -55,7 +55,7 @@ class CommandHandler extends BaseEvent {
|
||||||
interaction.user.send(args);
|
interaction.user.send(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
client.logger.log(`User ${interaction.user.discriminator === "0" ? interaction.user.username : interaction.user.tag} 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 ${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");
|
||||||
|
|
||||||
return command.execute(client, interaction, data);
|
return command.execute(client, interaction, data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ class GuildMemberRemove extends BaseEvent {
|
||||||
|
|
||||||
if (channel) {
|
if (channel) {
|
||||||
const message = guildData.plugins.goodbye.message
|
const message = guildData.plugins.goodbye.message
|
||||||
.replace(/{user}/g, member.user.discriminator === "0" ? member.user.username : member.user.tag)
|
.replace(/{user}/g, client.functions.getUsername(member.user))
|
||||||
.replace(/{server}/g, member.guild.name)
|
.replace(/{server}/g, member.guild.name)
|
||||||
.replace(/{membercount}/g, member.guild.memberCount);
|
.replace(/{membercount}/g, member.guild.memberCount);
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ class GuildMemberRemove extends BaseEvent {
|
||||||
// Draw # for discriminator
|
// Draw # for discriminator
|
||||||
ctx.fillStyle = "#FFFFFF";
|
ctx.fillStyle = "#FFFFFF";
|
||||||
ctx.font = "70px RubikMonoOne";
|
ctx.font = "70px RubikMonoOne";
|
||||||
ctx.fillText("#", canvas.width - 690, canvas.height - 165);
|
ctx.fillText(member.user.discriminator === "0" ? "" : "#", canvas.width - 690, canvas.height - 165);
|
||||||
|
|
||||||
// Draw title
|
// Draw title
|
||||||
ctx.font = "45px RubikMonoOne";
|
ctx.font = "45px RubikMonoOne";
|
||||||
|
|
|
@ -49,7 +49,7 @@ class MessageCreate extends BaseEvent {
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor({
|
||||||
name: message.translate("misc:QUOTE_TITLE", {
|
name: message.translate("misc:QUOTE_TITLE", {
|
||||||
user: msg.author.discriminator === "0" ? msg.author.username : msg.author.tag,
|
user: client.functions.getUsername(msg.author),
|
||||||
}),
|
}),
|
||||||
iconURL: "https://wynem.com/assets/images/icons/quote.webp",
|
iconURL: "https://wynem.com/assets/images/icons/quote.webp",
|
||||||
})
|
})
|
||||||
|
@ -64,7 +64,7 @@ class MessageCreate extends BaseEvent {
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
.setFooter({
|
.setFooter({
|
||||||
text: message.translate("misc:QUOTE_FOOTER", { user: message.author.discriminator === "0" ? message.author.username : message.author.tag }),
|
text: message.translate("misc:QUOTE_FOOTER", { user: client.functions.getUsername(message.author) }),
|
||||||
})
|
})
|
||||||
.setColor(client.config.embed.color)
|
.setColor(client.config.embed.color)
|
||||||
.setTimestamp(msg.createdTimestamp);
|
.setTimestamp(msg.createdTimestamp);
|
||||||
|
@ -111,11 +111,12 @@ class MessageCreate extends BaseEvent {
|
||||||
}, { mention: true });
|
}, { mention: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
message.mentions.users.forEach(async (u) => {
|
message.mentions.users.forEach(async u => {
|
||||||
const userData = await client.findOrCreateUser({
|
const userData = await client.findOrCreateUser({
|
||||||
id: u.id,
|
id: u.id,
|
||||||
});
|
});
|
||||||
if (userData.afk) message.replyT("general/afk:IS_AFK", { user: u.discriminator === "0" ? u.username : u.tag, reason: userData.afk }, { ephemeral: true });
|
|
||||||
|
if (userData.afk) message.replyT("general/afk:IS_AFK", { user: client.functions.getUsername(u), reason: userData.afk }, { ephemeral: true });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ class Ready extends BaseEvent {
|
||||||
if (client.config.dashboard.enabled) await client.dashboard.load(client);
|
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(`Loaded a total of ${commands.length} command(s).`, "ready");
|
||||||
client.logger.log(`${client.user.discriminator === "0" ? client.user.username : client.user.tag}, ready to serve ${tUsers} members in ${tServers} servers.`, "ready");
|
client.logger.log(`${client.functions.getUsername(client.user)}, 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");
|
client.logger.log(`Invite Link: ${client.generateInvite({ scopes: ["bot", "applications.commands"], permissions: [ PermissionsBitField.Flags.Administrator ] })}`, "ready");
|
||||||
|
|
||||||
console.timeEnd("botReady");
|
console.timeEnd("botReady");
|
||||||
|
|
|
@ -37,7 +37,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort array by key
|
* Sorts array by key
|
||||||
* @param {Array} array Array to sort
|
* @param {Array} array Array to sort
|
||||||
* @param {Number} key Key
|
* @param {Number} key Key
|
||||||
* @returns {Array} Sorted array
|
* @returns {Array} Sorted array
|
||||||
|
@ -51,7 +51,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shuffles array
|
* Shuffles the array
|
||||||
* @param {*} pArray Array to shuffle
|
* @param {*} pArray Array to shuffle
|
||||||
* @returns {Array} Shuffled array
|
* @returns {Array} Shuffled array
|
||||||
*/
|
*/
|
||||||
|
@ -104,7 +104,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert given time
|
* Converts given time
|
||||||
* @param {import("../base/JaBa")} client Discord client
|
* @param {import("../base/JaBa")} client Discord client
|
||||||
* @param {String} time Time
|
* @param {String} time Time
|
||||||
* @param {Boolean} type Type (To now = true or from now = false)
|
* @param {Boolean} type Type (To now = true or from now = false)
|
||||||
|
@ -120,7 +120,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get noun for number
|
* Get a noun for number
|
||||||
* @param {Number} number Number
|
* @param {Number} number Number
|
||||||
* @param {String} one String for one
|
* @param {String} one String for one
|
||||||
* @param {String} two String for two
|
* @param {String} two String for two
|
||||||
|
@ -137,4 +137,13 @@ module.exports = {
|
||||||
|
|
||||||
return five;
|
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()
|
const acceptEmbed = new EmbedBuilder()
|
||||||
.setTitle(interaction.translate("fun/tictactoe:REQUEST_WAIT", {
|
.setTitle(interaction.translate("fun/tictactoe:REQUEST_WAIT", {
|
||||||
user: opponent.discriminator === "0" ? opponent.username : opponent.tag,
|
user: client.functions.getUsername(opponent),
|
||||||
}))
|
}))
|
||||||
.setAuthor({
|
.setAuthor({
|
||||||
name: user.discriminator === "0" ? user.username : user.tag,
|
name: client.functions.getUsername(user),
|
||||||
iconURL: user.displayAvatarURL(),
|
iconURL: user.displayAvatarURL(),
|
||||||
})
|
})
|
||||||
.setColor(options.embedColor || "#075FFF")
|
.setColor(options.embedColor || "#075FFF")
|
||||||
|
@ -832,7 +832,7 @@ async function tictactoe(interaction, options = {}) {
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle(interaction.translate("fun/tictactoe:NO_ANSWER_TITLE"))
|
.setTitle(interaction.translate("fun/tictactoe:NO_ANSWER_TITLE"))
|
||||||
.setAuthor({
|
.setAuthor({
|
||||||
name: user.discriminator === "0" ? user.username : user.tag,
|
name: client.functions.getUsername(user),
|
||||||
iconURL: user.displayAvatarURL(),
|
iconURL: user.displayAvatarURL(),
|
||||||
})
|
})
|
||||||
.setColor(options.timeoutEmbedColor || "#C90000")
|
.setColor(options.timeoutEmbedColor || "#C90000")
|
||||||
|
@ -851,7 +851,7 @@ async function tictactoe(interaction, options = {}) {
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle(interaction.translate("fun/tictactoe:CANCELED"))
|
.setTitle(interaction.translate("fun/tictactoe:CANCELED"))
|
||||||
.setAuthor({
|
.setAuthor({
|
||||||
name: user.discriminator === "0" ? user.username : user.tag,
|
name: client.functions.getUsername(user),
|
||||||
iconURL: user.displayAvatarURL(),
|
iconURL: user.displayAvatarURL(),
|
||||||
})
|
})
|
||||||
.setColor(options.timeoutEmbedColor || "#C90000")
|
.setColor(options.timeoutEmbedColor || "#C90000")
|
||||||
|
|
Loading…
Reference in a new issue