How to send Server Region in Embed Discord JS v13?

Viewed 640

I have a Server Info command which worked in v12 but I updated to v13. In v12 when I send the Command it Responds with the correct region but in v13 when I send the command, responds at server region with undefined, help!

This is server info command:

const Discord = require('discord.js');

module.exports = {
    name: "serverinfo",
    aliases: ["si"],
    description: "Shows all Info about the Server!",
    execute: async (message, args, client) => {

        let region;
        switch (message.guild.region) {
            case "europe":
                region = ' europe';
                break;
            case "russia":
                region = ' russia';
                break;
            case "us-east":
                region = ' us-east'
                break;
            case "us-west":
                region = ' us-west';
                break;
            case "us-south":
                region = ' us-south'
                break;
            case "us-central":
                region = ' us-central'
                break;
        }

        const embed = new Discord.MessageEmbed()
            .setThumbnail(message.guild.iconURL({dynamic : true}))
            .setColor('#dd6fb9')
            .setTitle(`**Bot Command**`)
            .setFooter("@" + message.author.tag, message.author.displayAvatarURL({dynamic : true}))
            .addFields(

                {
                    name: `Region: `,
                    value: `${region}`,
                    inline: true
                }

        await message.channel.send( { embeds: [embed] }).then(setTimeout(() => message.delete())).then(msg =>{
            setTimeout(() => msg.delete(), 120000)});
    },
};
1 Answers

A guild no longer has the attribute region. You can however get the preferredLocale of the server:

const Discord = require('discord.js');

module.exports = {
    name: "serverinfo",
    aliases: ["si"],
    description: "Shows all Info about the Server!",
    execute: async (message, args, client) => {

        const embed = new Discord.MessageEmbed()
            .setThumbnail(message.guild.iconURL({dynamic : true}))
            .setColor('#dd6fb9')
            .setTitle(`**Bot Command**`)
            .setFooter("@" + message.author.tag, message.author.displayAvatarURL({dynamic : true}))
            .addFields(

                {
                    name: `Region: `,
                    value: `${message.guild.preferredLocale}`,
                    inline: true
                }

        await message.channel.send( { embeds: [embed] }).then(setTimeout(() => message.delete())).then(msg =>{
            setTimeout(() => msg.delete(), 120000)});
    },
};
Related