-1

How can I replace the string message.guild.region which returns different regions (for example: europe, brazil, japan, russia, etc) and make it return those Regions but instead with the first letter capital (for example: Europe, Brazil, Japan, Russian, etc)? Any help is welcome, sorry if something isn't clear. I will try to explain it as best as I can.

Here's my code:

    if (message.content.startsWith(`${prefix}serverinfo`)) {
        const serverinfoembed = new Discord.MessageEmbed()
        .setColor(`#a87f32`)
        .setTitle(`${message.guild.name}`)
        .addFields(
        { name: '**Owner**', value: `${message.guild.owner}`, inline: true },
        { name: '**Region**', value: `${message.guild.region}`, inline: true },
        { name: '**Members**', value: `${message.guild.memberCount}`, inline: true },
        )
        .setFooter(`ID: ${message.guild.id} | Server Created • ${message.guild.createdAt.toDateString()}`)
        message.channel.send(serverinfoembed)
    }
Miolaro
  • 5
  • 3

2 Answers2

0

I think you'll need this:

How do I make the first letter of a string uppercase in JavaScript?

Then use the map function:

newRegions = regions.map(region => upperCaseFirst(region);
0

Pass it to this function:

function capitalizeFirstLetter(string) {
  return string.charAt(0).toUpperCase() + string.slice(1);
}
mamady
  • 180
  • 1
  • 11