mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
refactor: rename *ID to *Id (#710)
* refactor: rename *ID to *Id * Update src/helpers/commands/delete_slash_command.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/commands/delete_slash_command.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/commands/delete_slash_response.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/commands/edit_slash_response.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/utils.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/utils.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/utils.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/utils.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/utils.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/commands/get_slash_command.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/commands/send_interaction_response.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/commands/upsert_slash_command.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/guilds/edit_widget.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/guilds/get_widget.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/guilds/get_widget.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/guilds/get_widget_image_url.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/guilds/get_widget_image_url.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/guilds/get_widget_settings.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update .gitignore Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update LICENSE Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/members/edit_bot_profile.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/members/edit_bot_profile.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/webhooks/create_webhook.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/webhooks/delete_webhook.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/constants.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/webhooks/edit_webhook.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/webhooks/execute_webhook.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/webhooks/get_webhook.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/rest/cache.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/rest/request.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/constants.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/commands/delete_slash_response.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/constants.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/constants.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/constants.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/constants.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/utils.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/utils.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Revert docs file Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com>
This commit is contained in:
+16
-19
@@ -1,10 +1,7 @@
|
||||
import { cache } from "../cache.ts";
|
||||
import { deleteRole } from "../helpers/roles/delete_role.ts";
|
||||
import { editRole } from "../helpers/roles/edit_role.ts";
|
||||
import { Collection } from "../util/collection.ts";
|
||||
import { createNewProp } from "../util/utils.ts";
|
||||
import { Guild } from "./guild.ts";
|
||||
import { Member } from "./member.ts";
|
||||
|
||||
const baseRole: Partial<Role> = {
|
||||
get guild() {
|
||||
@@ -23,43 +20,43 @@ const baseRole: Partial<Role> = {
|
||||
},
|
||||
|
||||
// METHODS
|
||||
delete(guildID?: string) {
|
||||
delete(guildId?: string) {
|
||||
// If not guild id was provided try and find one
|
||||
if (!guildID) guildID = guildID || this.guild?.id;
|
||||
if (!guildId) guildId = guildId || this.guild?.id;
|
||||
// If a guild id is still not available error out
|
||||
if (!guildID) {
|
||||
if (!guildId) {
|
||||
throw new Error(
|
||||
"role.delete() did not find a valid guild in cache. Please provide the guildID like role.delete(guildID)",
|
||||
"role.delete() did not find a valid guild in cache. Please provide the guildId like role.delete(guildId)",
|
||||
);
|
||||
}
|
||||
|
||||
return deleteRole(guildID, this.id!).catch(console.error);
|
||||
return deleteRole(guildId, this.id!).catch(console.error);
|
||||
},
|
||||
edit(options: CreateRoleOptions, guildID?: string) {
|
||||
edit(options: CreateRoleOptions, guildId?: string) {
|
||||
// If not guild id was provided try and find one
|
||||
if (!guildID) guildID = guildID || this.guild?.id;
|
||||
if (!guildId) guildId = guildId || this.guild?.id;
|
||||
// If a guild id is still not available error out
|
||||
if (!guildID) {
|
||||
if (!guildId) {
|
||||
throw new Error(
|
||||
"role.edit() did not find a valid guild in cache. Please provide the guildID like role.edit({}, guildID)",
|
||||
"role.edit() did not find a valid guild in cache. Please provide the guildId like role.edit({}, guildId)",
|
||||
);
|
||||
}
|
||||
|
||||
return editRole(guildID, this.id!, options);
|
||||
return editRole(guildId, this.id!, options);
|
||||
},
|
||||
higherThanRoleID(roleID: string, position?: number) {
|
||||
higherThanRoleId(roleId: string, position?: number) {
|
||||
// If no position try and find one from cache
|
||||
if (!position) position = this.guild?.roles.get(roleID)?.position;
|
||||
if (!position) position = this.guild?.roles.get(roleId)?.position;
|
||||
// If still none error out.
|
||||
if (!position) {
|
||||
throw new Error(
|
||||
"role.higherThanRoleID() did not have a position provided and the role or guild was not found in cache. Please provide a position like role.higherThanRoleID(roleID, position)",
|
||||
"role.higherThanRoleId() did not have a position provided and the role or guild was not found in cache. Please provide a position like role.higherThanRoleId(roleId, position)",
|
||||
);
|
||||
}
|
||||
|
||||
// Rare edge case handling
|
||||
if (this.position === position) {
|
||||
return this.id! < roleID;
|
||||
return this.id! < roleId;
|
||||
}
|
||||
|
||||
return this.position! > position;
|
||||
@@ -76,9 +73,9 @@ export async function createRoleStruct({ tags = {}, ...rest }: RoleData) {
|
||||
|
||||
const role = Object.create(baseRole, {
|
||||
...restProps,
|
||||
botID: createNewProp(tags.bot_id),
|
||||
botId: createNewProp(tags.bot_id),
|
||||
isNitroBoostRole: createNewProp("premium_subscriber" in tags),
|
||||
integrationID: createNewProp(tags.integration_id),
|
||||
integrationId: createNewProp(tags.integration_id),
|
||||
});
|
||||
|
||||
return role as Role;
|
||||
|
||||
Reference in New Issue
Block a user