SudhanPlayz / Discord-MusicBot

An advanced discord music bot, supports Spotify, Soundcloud, YouTube with Shuffling, Volume Control and Web Dashboard with Slash Commands support!
https://musicbot.darrenofficial.com
Other
2.95k stars 2.87k forks source link

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

Closed PandaKeny closed 2 years ago

PandaKeny commented 2 years ago

as the title currently no aliases?

gspxrk commented 2 years ago

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 commented 2 years ago

Uh basically, we use Slash commands

PandaKeny commented 2 years ago

Thanks, I'm looking forward to your v5 version

PandaKeny commented 2 years ago

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

BioCla commented 2 years ago

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 commented 2 years ago

who wants help to translate the bot 🥂

BioCla commented 2 years ago

who wants help to translate the bot 🥂

I can do Italian

PandaKeny commented 2 years ago

I can do Vietnamese

DarrenOfficial commented 2 years ago

Well I'll implement it as soon as d.js add that feature https://github.com/discord/discord-api-docs/issues/2313

DarrenOfficial commented 2 years ago

Well turns out it's already added but... not available yet https://github.com/discordjs/discord.js/issues/7765#issuecomment-1104971223

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

Linked PR: https://github.com/discordjs/discord.js/pull/7766

gspxrk commented 2 years ago

who wants help to translate the bot 🥂

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

sprucecellodev125 commented 2 years ago

who wants help to translate the bot 🥂

I can Indonesia

alaireselene commented 2 years ago

who wants help to translate the bot 🥂

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

PandaKeny commented 2 years ago

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

BioCla commented 2 years ago

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 commented 2 years ago

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(...) => {...}
}