Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v5] There are no aliases in the current beta version? #831

Closed
PandaKeny opened this issue May 3, 2022 · 16 comments
Closed

[v5] There are no aliases in the current beta version? #831

PandaKeny opened this issue May 3, 2022 · 16 comments
Labels
type: enhancement Feature to be added

Comments

@PandaKeny
Copy link

as the title currently no aliases?

@PandaKeny PandaKeny added the type: enhancement Feature to be added label May 3, 2022
@PandaKeny PandaKeny changed the title There are no aliases in the current beta version? V5 There are no aliases in the current beta version? May 3, 2022
@PandaKeny PandaKeny changed the title V5 There are no aliases in the current beta version? [v5] There are no aliases in the current beta version? May 3, 2022
@XstreamSpeed
Copy link
Contributor

Yeah, because of Discord's new updates regarding bots, all commands in DMB are SlashCommands. Therefore, no aliases like in v4 where there were Context commandss

@JotaroKujo0525
Copy link
Collaborator

Uh basically, we use Slash commands

@PandaKeny
Copy link
Author

Thanks, I'm looking forward to your v5 version

@PandaKeny
Copy link
Author

If possible, can you put the language in a separate section?

@BioCla
Copy link
Contributor

BioCla commented May 5, 2022

If possible, can you put the language in a separate section?

Feel free to look into this awesome article explaining how localization works!
If you're able to you can make translated version of the bot and have someone integrate the rest
https://discord.com/developers/docs/interactions/application-commands#localization

@DarrenOfficial
Copy link
Collaborator

who wants help to translate the bot 🥂

@BioCla
Copy link
Contributor

BioCla commented May 5, 2022

who wants help to translate the bot 🥂

I can do Italian

@PandaKeny
Copy link
Author

I can do Vietnamese

@DarrenOfficial
Copy link
Collaborator

Well I'll implement it as soon as d.js add that feature discord/discord-api-docs#2313

@DarrenOfficial
Copy link
Collaborator

Well turns out it's already added but... not available yet discordjs/discord.js#7765 (comment)

The linked PR has merged 7 days ago, and will be included in next release (v13.7.0).

Linked PR: discordjs/discord.js#7766

@XstreamSpeed
Copy link
Contributor

who wants help to translate the bot 🥂

I'll fix the current grammatical errors through each and every folder of the bot

@sprucecellodev125
Copy link
Collaborator

who wants help to translate the bot 🥂

I can Indonesia

@alaireselene
Copy link

who wants help to translate the bot 🥂

I can do with Vietnamese :))) I've translate this bot from v4 by forked it.

@PandaKeny
Copy link
Author

chào đồng hương =)))

@BioCla
Copy link
Contributor

BioCla commented Jun 6, 2022

Seems this was implemented, or at least there are traces in the code which are usable:
in "node_modules@discordjs\builders\dist\index.d.ts" line 880 & line 1371 (for context commands), methods are described for the localization feature.

Some implementations can be found (but look highly rudimental) in "node_modules\discord.js\src\structures\ApplicationCommand.js" starting at line 246

The data structure for the commands looks like so

/**
   * Data for creating or editing an application command.
   * @typedef {Object} ApplicationCommandData
   * @property {string} name The name of the command
   * @property {Object<Locale, string>} [nameLocalizations] The localizations for the command name
   * @property {string} description The description of the command
   * @property {Object<Locale, string>} [descriptionLocalizations] The localizations for the command description
   * @property {ApplicationCommandType} [type] The type of the command
   * @property {ApplicationCommandOptionData[]} [options] Options for the command
   * @property {boolean} [defaultPermission] Whether the command is enabled by default when the app is added to a guild
   */

There is much more investigating to do, but I think this is a good start.
Edit:
Command localization was actually added in 13.7.0, So i'm guessing that after thorough studying of the methods this should be more than doable

@BioCla
Copy link
Contributor

BioCla commented Jun 7, 2022

Repost of what I said on the discord server, Just so everyone can see and keep updated:

Image

aliasing is indeed possible through name localizations, however (And I think this may be due to my ignorance in the matter) I don't know if the name localization should be effectively changing the names of the commands according to the selected language options

In the interaction class object, for each executed command, there is a set of properties, namely:

class Interaction<Cached extends CacheType = CacheType> extends Base {
  public locale: string;
  public guildLocale: CacheTypeReducer<Cached, string, string, string>;
}

Which could come in handy for managing different aliases based on someone's selected region in discord.

guildLocale is the property which defines the region in which the server has been centered upon (default server language)
locale is the language which the single user, who interacted with the bot, has chosen to display everything on their discord app

    EnglishUS = "en-US",
    EnglishGB = "en-GB",
    Bulgarian = "bg",
    ChineseCN = "zh-CN",
    ChineseTW = "zh-TW",
    Croatian = "hr",
    Czech = "cs",
    Danish = "da",
    Dutch = "nl",
    Finnish = "fi",
    French = "fr",
    German = "de",
    Greek = "el",
    Hindi = "hi",
    Hungarian = "hu",
    Italian = "it",
    Japanese = "ja",
    Korean = "ko",
    Lithuanian = "lt",
    Norwegian = "no",
    Polish = "pl",
    PortugueseBR = "pt-BR",
    Romanian = "ro",
    Russian = "ru",
    SpanishES = "es-ES",
    Swedish = "sv-SE",
    Thai = "th",
    Turkish = "tr",
    Ukrainian = "uk",
    Vietnamese = "vi"

These are the available locales (check Discord Developer Portal)

Each one of those can be interpreted as an object property as well, not just string, for example:

    "en-US"?: string;
    "en-GB"?: string;
    bg?: string;
    "zh-CN"?: string;
    "zh-TW"?: string;
    hr?: string;
etc...

the locales can be set through methods, of the discord.js builders package, or directly through property manipulation. However, I've yet to test which of the two is most effective and/or usable
here are some examples:

command.setLocalizedNames({
  'en-GB': 'test',
  'pt-BR': 'teste',
})

and

module.exports = {
    name: "test",
    description: "test command",
    name_localizations: {
        it: "prova",
    },
    description_localizations: {
        it: "commando di prova",
    },
        run: async(...) => {...}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Feature to be added
Projects
None yet
Development

No branches or pull requests

8 participants