mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
refactor: change xID to xId (#6036)
* refactor: change `xID` to `xId` * Update src/managers/MessageManager.js Co-authored-by: Noel <buechler.noel@outlook.com> Co-authored-by: Noel <buechler.noel@outlook.com>
This commit is contained in:
@@ -27,21 +27,21 @@ class ApplicationCommandManager extends CachedManager {
|
||||
* @name ApplicationCommandManager#cache
|
||||
*/
|
||||
|
||||
add(data, cache, guildID) {
|
||||
return super.add(data, cache, { extras: [this.guild, guildID] });
|
||||
add(data, cache, guildId) {
|
||||
return super.add(data, cache, { extras: [this.guild, guildId] });
|
||||
}
|
||||
|
||||
/**
|
||||
* The APIRouter path to the commands
|
||||
* @param {Snowflake} [options.id] ID of the application command
|
||||
* @param {Snowflake} [options.guildID] ID of the guild to use in the path,
|
||||
* @param {Snowflake} [options.id] The application command's id
|
||||
* @param {Snowflake} [options.guildId] The guild's id to use in the path,
|
||||
* ignored when using a {@link GuildApplicationCommandManager}
|
||||
* @returns {Object}
|
||||
* @private
|
||||
*/
|
||||
commandPath({ id, guildID } = {}) {
|
||||
commandPath({ id, guildId } = {}) {
|
||||
let path = this.client.api.applications(this.client.application.id);
|
||||
if (this.guild ?? guildID) path = path.guilds(this.guild?.id ?? guildID);
|
||||
if (this.guild ?? guildId) path = path.guilds(this.guild?.id ?? guildId);
|
||||
return id ? path.commands(id) : path.commands;
|
||||
}
|
||||
|
||||
@@ -62,12 +62,12 @@ class ApplicationCommandManager extends CachedManager {
|
||||
/**
|
||||
* Options used to fetch Application Commands from discord
|
||||
* @typedef {BaseFetchOptions} FetchApplicationCommandOptions
|
||||
* @property {Snowflake} [guildID] ID of the guild to fetch commands for, for when the guild is not cached
|
||||
* @property {Snowflake} [guildId] The guild's id to fetch commands for, for when the guild is not cached
|
||||
*/
|
||||
|
||||
/**
|
||||
* Obtains one or multiple application commands from Discord, or the cache if it's already available.
|
||||
* @param {Snowflake} [id] ID of the application command
|
||||
* @param {Snowflake} [id] The application command's id
|
||||
* @param {FetchApplicationCommandOptions} [options] Additional options for this fetch
|
||||
* @returns {Promise<ApplicationCommand|Collection<Snowflake, ApplicationCommand>>}
|
||||
* @example
|
||||
@@ -81,26 +81,26 @@ class ApplicationCommandManager extends CachedManager {
|
||||
* .then(commands => console.log(`Fetched ${commands.size} commands`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async fetch(id, { guildID, cache = true, force = false } = {}) {
|
||||
async fetch(id, { guildId, cache = true, force = false } = {}) {
|
||||
if (typeof id === 'object') {
|
||||
({ guildID, cache = true, force = false } = id);
|
||||
({ guildId, cache = true, force = false } = id);
|
||||
} else if (id) {
|
||||
if (!force) {
|
||||
const existing = this.cache.get(id);
|
||||
if (existing) return existing;
|
||||
}
|
||||
const command = await this.commandPath({ id, guildID }).get();
|
||||
const command = await this.commandPath({ id, guildId }).get();
|
||||
return this.add(command, cache);
|
||||
}
|
||||
|
||||
const data = await this.commandPath({ guildID }).get();
|
||||
return data.reduce((coll, command) => coll.set(command.id, this.add(command, cache, guildID)), new Collection());
|
||||
const data = await this.commandPath({ guildId }).get();
|
||||
return data.reduce((coll, command) => coll.set(command.id, this.add(command, cache, guildId)), new Collection());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an application command.
|
||||
* @param {ApplicationCommandData} command The command
|
||||
* @param {Snowflake} [guildID] ID of the guild to create this command in,
|
||||
* @param {Snowflake} [guildId] The guild's id to create this command in,
|
||||
* ignored when using a {@link GuildApplicationCommandManager}
|
||||
* @returns {Promise<ApplicationCommand>}
|
||||
* @example
|
||||
@@ -112,17 +112,17 @@ class ApplicationCommandManager extends CachedManager {
|
||||
* .then(console.log)
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async create(command, guildID) {
|
||||
const data = await this.commandPath({ guildID }).post({
|
||||
async create(command, guildId) {
|
||||
const data = await this.commandPath({ guildId }).post({
|
||||
data: this.constructor.transformCommand(command),
|
||||
});
|
||||
return this.add(data, undefined, guildID);
|
||||
return this.add(data, undefined, guildId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets all the commands for this application or guild.
|
||||
* @param {ApplicationCommandData[]} commands The commands
|
||||
* @param {Snowflake} [guildID] ID of the guild to create the commands in,
|
||||
* @param {Snowflake} [guildId] The guild's id to create the commands in,
|
||||
* ignored when using a {@link GuildApplicationCommandManager}
|
||||
* @returns {Promise<Collection<Snowflake, ApplicationCommand>>}
|
||||
* @example
|
||||
@@ -141,12 +141,12 @@ class ApplicationCommandManager extends CachedManager {
|
||||
* .then(console.log)
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async set(commands, guildID) {
|
||||
const data = await this.commandPath({ guildID }).put({
|
||||
async set(commands, guildId) {
|
||||
const data = await this.commandPath({ guildId }).put({
|
||||
data: commands.map(c => this.constructor.transformCommand(c)),
|
||||
});
|
||||
return data.reduce(
|
||||
(coll, command) => coll.set(command.id, this.add(command, undefined, guildID)),
|
||||
(coll, command) => coll.set(command.id, this.add(command, undefined, guildId)),
|
||||
new Collection(),
|
||||
);
|
||||
}
|
||||
@@ -155,7 +155,7 @@ class ApplicationCommandManager extends CachedManager {
|
||||
* Edits an application command.
|
||||
* @param {ApplicationCommandResolvable} command The command to edit
|
||||
* @param {ApplicationCommandData} data The data to update the command with
|
||||
* @param {Snowflake} [guildID] ID of the guild where the command registered,
|
||||
* @param {Snowflake} [guildId] The guild's id where the command registered,
|
||||
* ignored when using a {@link GuildApplicationCommandManager}
|
||||
* @returns {Promise<ApplicationCommand>}
|
||||
* @example
|
||||
@@ -166,18 +166,18 @@ class ApplicationCommandManager extends CachedManager {
|
||||
* .then(console.log)
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async edit(command, data, guildID) {
|
||||
const id = this.resolveID(command);
|
||||
async edit(command, data, guildId) {
|
||||
const id = this.resolveId(command);
|
||||
if (!id) throw new TypeError('INVALID_TYPE', 'command', 'ApplicationCommandResolvable');
|
||||
|
||||
const patched = await this.commandPath({ id, guildID }).patch({ data: this.constructor.transformCommand(data) });
|
||||
return this.add(patched, undefined, guildID);
|
||||
const patched = await this.commandPath({ id, guildId }).patch({ data: this.constructor.transformCommand(data) });
|
||||
return this.add(patched, undefined, guildId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an application command.
|
||||
* @param {ApplicationCommandResolvable} command The command to delete
|
||||
* @param {Snowflake} [guildID] ID of the guild where the command is registered,
|
||||
* @param {Snowflake} [guildId] The guild's id where the command is registered,
|
||||
* ignored when using a {@link GuildApplicationCommandManager}
|
||||
* @returns {Promise<?ApplicationCommand>}
|
||||
* @example
|
||||
@@ -186,11 +186,11 @@ class ApplicationCommandManager extends CachedManager {
|
||||
* .then(console.log)
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async delete(command, guildID) {
|
||||
const id = this.resolveID(command);
|
||||
async delete(command, guildId) {
|
||||
const id = this.resolveId(command);
|
||||
if (!id) throw new TypeError('INVALID_TYPE', 'command', 'ApplicationCommandResolvable');
|
||||
|
||||
await this.commandPath({ id, guildID }).delete();
|
||||
await this.commandPath({ id, guildId }).delete();
|
||||
|
||||
const cached = this.cache.get(id);
|
||||
this.cache.delete(id);
|
||||
|
||||
Reference in New Issue
Block a user