Skip to content

Commit

Permalink
Add localization and emojis to server panel message options
Browse files Browse the repository at this point in the history
  • Loading branch information
chimpdev committed Oct 4, 2024
1 parent 52d3bb2 commit ffb7db4
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function MonthlyVotesGraph({ server }) {

<Tooltip
side={isMobile ? 'bottom' : 'right'}
content={t(`graph.tooltip.${isIncreased ? 'increased' : isDecreased ? 'decreased' : 'noChanges'}`, { postProcess: 'interval', count: 1, difference})}
content={t(`graph.tooltip.${isIncreased ? 'increased' : isDecreased ? 'decreased' : 'noChanges'}`, { postProcess: 'interval', count: 1, difference })}
>
<div className={cn(
'select-none flex w-max gap-x-1 px-2 items-center py-1 text-xs font-semibold rounded-lg',
Expand Down
1 change: 1 addition & 0 deletions server/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ supportInviteUrl: 'https://invite.discord.place'
emojis:
loading: '<a:loading:1247786499076915252>'
checkmark: '<:yes:1226129515718381568>'
pink_heart: '<:heart:1211809043564339290>'
badges:
admin: '<:white_admin:1267620006183571530>'
moderator: '<:white_moderator:1251538987592712345>'
Expand Down
26 changes: 26 additions & 0 deletions server/src/locales/az.json
Original file line number Diff line number Diff line change
Expand Up @@ -452,5 +452,31 @@
"numbers_selected": "Seçilen numaralar: {numbers}"
}
}
},
"server_panel_message": {
"embeds": [
{
"title": "**Oylar**",
"description": "- Bu sunucuya toplamda ***{serverVotes}*** kez ***{totalVoters}*** kullanıcı tarafından oy verilmiştir.",
"table": {
"vote": "Oy"
}
},
{
"title": "**Aylık Oylar**",
"description": "- Bu sunucu, bu ay ***{count}*** oy kazanmıştır."
},
{
"title": "**Ödüller**",
"description": "- Bu sunucunun ***{count}*** oy ödülü vardır.",
"table": {
"unknown_role": "bilinmeyen"
}
}
],
"buttons": {
"vote": "Oy Ver",
"view_on_discord_place": "discord.place'de Görüntüle"
}
}
}
26 changes: 26 additions & 0 deletions server/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -452,5 +452,31 @@
"numbers_selected": "You selected {numbers}."
}
}
},
"server_panel_message": {
"embeds": [
{
"title": "**Votes**",
"description": "- ***{serverVotes}*** time this server has been voted in total by ***${totalVoters}*** users.",
"table": {
"vote": "Vote"
}
},
{
"title": "**Monthly Votes**",
"description": "- This server has gained ***{count}*** votes in this month."
},
{
"title": "**Rewards**",
"description": "(1)[- This server has ***{count}*** reward.];(2-inf)[- This server has ***{count}*** rewards.]",
"table": {
"unknown_role": "unknown"
}
}
],
"buttons": {
"vote": "Vote",
"view_on_discord_place": "View on discord.place"
}
}
}
26 changes: 26 additions & 0 deletions server/src/locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -589,5 +589,31 @@
"numbers_selected": "Seçilen numaralar: {numbers}"
}
}
},
"server_panel_message": {
"embeds": [
{
"title": "**Oylar**",
"description": "- Bu sunucuya toplamda ***{serverVotes}*** kez ***{totalVoters}*** kullanıcı tarafından oy verilmiştir.",
"table": {
"vote": "Oy"
}
},
{
"title": "**Aylık Oylar**",
"description": "- Bu sunucu, bu ay ***{count}*** oy kazanmıştır."
},
{
"title": "**Ödüller**",
"description": "- Bu sunucunun ***{count}*** oy ödülü vardır.",
"table": {
"unknown_role": "bilinmeyen"
}
}
],
"buttons": {
"vote": "Oy Ver",
"view_on_discord_place": "discord.place'de Görüntüle"
}
}
}
11 changes: 6 additions & 5 deletions server/src/utils/servers/updatePanelMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,23 @@ async function createPanelMessageOptions(guild, server) {
new Discord.EmbedBuilder()
.setAuthor({ name: guild.name, iconURL: guild.iconURL() })
.setColor(embedColor.hex)
.setDescription(`**Votes**\n- ***${formatter.format(server.voters.reduce((acc, voter) => acc + voter.vote, 0))}*** time this server has been voted in total by ***${server.voters.length}*** users.\n\`\`\`ansi\n${topVotersTable.map(([index, votes, username]) => `${ansiColors.reset.bold(`${index}${index == 10 ? '' : ' '} |`)} ${ansiColors.reset.bold.blue(`${votes}${' '.repeat(Math.max(...topVotersTable.map(([, votes]) => votes)).toString().length - votes.toString().length)} Vote`)} ${ansiColors.reset.bold(`‒ ${username}`)}`).join('\n')}\`\`\``)
.setDescription(`${await guild.translate('server_panel_message.embeds.0.title')}\n${await guild.translate('server_panel_message.embeds.0.description', { serverVotes: formatter.format(server.voters.reduce((acc, voter) => acc + voter.vote, 0)), totalVoters: server.voters.length })}\n\`\`\`ansi\n${(await Promise.all(topVotersTable.map(async ([index, votes, username]) => `${ansiColors.reset.bold(`${index}${index == 10 ? '' : ' '} |`)} ${ansiColors.reset.bold.blue(`${votes}${' '.repeat(Math.max(...topVotersTable.map(([, votes]) => votes)).toString().length - votes.toString().length)} ${await guild.translate('server_panel_message.embeds.0.table.vote')}`)} ${ansiColors.reset.bold(`‒ ${username}`)}`))).join('\n')}\`\`\``)
];

const monthlyVotes = await ServerMonthlyVotes.findOne({ identifier: guild.id });
if (monthlyVotes) {
embeds.push(
new Discord.EmbedBuilder()
.setColor(embedColor.hex)
.setDescription(`**Monthly Votes**\n- This server has gained ***${formatter.format(server.votes)}*** votes in this month.\n\`\`\`ansi\n${monthlyVotes.data.map(month => [formatter.format(month.votes), new Date(month.created_at).toLocaleString('en-US', { year: 'numeric', month: 'short' })]).map(([votes, date]) => `${ansiColors.reset.bold(`${date} ‒`)} ${ansiColors.reset.bold.blue(votes)}`).join('\n')}\`\`\``)
.setDescription(`${await guild.translate('server_panel_message.embeds.1.title')}\n${await guild.translate('server_panel_message.embeds.1.description', { count: formatter.format(server.votes) })}\n\`\`\`ansi\n${monthlyVotes.data.map(month => [formatter.format(month.votes), new Date(month.created_at).toLocaleString('en-US', { year: 'numeric', month: 'short' })]).map(([votes, date]) => `${ansiColors.reset.bold(`${date} ‒`)} ${ansiColors.reset.bold.blue(votes)}`).join('\n')}\`\`\``)
);
}

if (rewards.length) {
embeds.push(
new Discord.EmbedBuilder()
.setColor(embedColor.hex)
.setDescription(`**Rewards**\n- This server has ***${rewards.length}*** reward${rewards.length > 1 ? 's' : ''}.\n\`\`\`ansi\n${rewards.map(reward => ansiColors.reset.bold(`${reward.required_votes} @${guild.roles.cache.get(reward.role.id)?.name || 'unknown'}`)).join('\n')}\`\`\``)
.setDescription(`${await guild.translate('server_panel_message.embeds.2.title')}\n${await guild.translate('server_panel_message.embeds.2.description', { postProcess: 'interval', count: rewards.length })}\n\`\`\`ansi\n${(await Promise.all(rewards.map(async reward => `${ansiColors.reset.bold(`${reward.required_votes}`)} ${ansiColors.reset.bold.blue(`@${guild.roles.cache.get(reward.role.id)?.name || await guild.translate('server_panel_message.embeds.2.table.unknown_role')}`)}`))).join('\n')}\`\`\``)
);
}

Expand All @@ -99,10 +99,11 @@ async function createPanelMessageOptions(guild, server) {
.addComponents(
new Discord.ButtonBuilder()
.setCustomId('vote')
.setLabel('Vote')
.setLabel(await guild.translate('server_panel_message.buttons.vote'))
.setEmoji(config.emojis.pink_heart)
.setStyle(Discord.ButtonStyle.Secondary),
new Discord.ButtonBuilder()
.setLabel('View on discord.place')
.setLabel(await guild.translate('server_panel_message.buttons.view_on_discord_place'))
.setStyle(Discord.ButtonStyle.Link)
.setURL(`${config.frontendUrl}/servers/${guild.id}`)
)
Expand Down

0 comments on commit ffb7db4

Please sign in to comment.