mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +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:
@@ -3,10 +3,10 @@ import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
||||
|
||||
/** Ban a user from the guild and optionally delete previous messages sent by the user. Requires the BAN_MEMBERS permission. */
|
||||
export async function ban(guildID: string, id: string, options: BanOptions) {
|
||||
await requireBotGuildPermissions(guildID, ["BAN_MEMBERS"]);
|
||||
export async function ban(guildId: string, id: string, options: BanOptions) {
|
||||
await requireBotGuildPermissions(guildId, ["BAN_MEMBERS"]);
|
||||
|
||||
const result = await RequestManager.put(endpoints.GUILD_BAN(guildID, id), {
|
||||
const result = await RequestManager.put(endpoints.GUILD_BAN(guildId, id), {
|
||||
...options,
|
||||
delete_message_days: options.days,
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { editMember } from "./edit_member.ts";
|
||||
|
||||
/** Kicks a member from a voice channel */
|
||||
export function disconnectMember(guildID: string, memberID: string) {
|
||||
return editMember(guildID, memberID, { channel_id: null });
|
||||
export function disconnectMember(guildId: string, memberId: string) {
|
||||
return editMember(guildId, memberId, { channel_id: null });
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
||||
|
||||
/** Edit the nickname of the bot in this guild */
|
||||
export async function editBotNickname(
|
||||
guildID: string,
|
||||
guildId: string,
|
||||
nickname: string | null,
|
||||
) {
|
||||
await requireBotGuildPermissions(guildID, ["CHANGE_NICKNAME"]);
|
||||
await requireBotGuildPermissions(guildId, ["CHANGE_NICKNAME"]);
|
||||
|
||||
const response = await RequestManager.patch(
|
||||
endpoints.USER_NICK(guildID),
|
||||
endpoints.USER_NICK(guildId),
|
||||
{ nick: nickname },
|
||||
) as { nick: string };
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ import {
|
||||
|
||||
/** Edit the member */
|
||||
export async function editMember(
|
||||
guildID: string,
|
||||
memberID: string,
|
||||
guildId: string,
|
||||
memberId: string,
|
||||
options: EditMemberOptions,
|
||||
) {
|
||||
const requiredPerms: Set<Permission> = new Set();
|
||||
@@ -29,10 +29,10 @@ export async function editMember(
|
||||
typeof options.deaf !== "undefined" ||
|
||||
(typeof options.channel_id !== "undefined" || "null")
|
||||
) {
|
||||
const memberVoiceState = (await cacheHandlers.get("guilds", guildID))
|
||||
?.voiceStates.get(memberID);
|
||||
const memberVoiceState = (await cacheHandlers.get("guilds", guildId))
|
||||
?.voiceStates.get(memberId);
|
||||
|
||||
if (!memberVoiceState?.channelID) {
|
||||
if (!memberVoiceState?.channelId) {
|
||||
throw new Error(Errors.MEMBER_NOT_IN_VOICE_CHANNEL);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ export async function editMember(
|
||||
]);
|
||||
if (memberVoiceState) {
|
||||
await requireBotChannelPermissions(
|
||||
memberVoiceState?.channelID,
|
||||
memberVoiceState?.channelId,
|
||||
[...requiredVoicePerms],
|
||||
);
|
||||
}
|
||||
@@ -62,13 +62,13 @@ export async function editMember(
|
||||
}
|
||||
}
|
||||
|
||||
await requireBotGuildPermissions(guildID, [...requiredPerms]);
|
||||
await requireBotGuildPermissions(guildId, [...requiredPerms]);
|
||||
|
||||
const result = await RequestManager.patch(
|
||||
endpoints.GUILD_MEMBER(guildID, memberID),
|
||||
endpoints.GUILD_MEMBER(guildId, memberId),
|
||||
options,
|
||||
) as MemberCreatePayload;
|
||||
const member = await structures.createMemberStruct(result, guildID);
|
||||
const member = await structures.createMemberStruct(result, guildId);
|
||||
|
||||
return member;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ import { requestAllMembers } from "../../ws/shard_manager.ts";
|
||||
* GW(this function): 120/m(PER shard) rate limit. Meaning if you have 8 shards your limit is now 960/m.
|
||||
*/
|
||||
export function fetchMembers(
|
||||
guildID: string,
|
||||
shardID: number,
|
||||
guildId: string,
|
||||
shardId: number,
|
||||
options?: FetchMembersOptions,
|
||||
) {
|
||||
// You can request 1 member without the intent
|
||||
@@ -24,11 +24,11 @@ export function fetchMembers(
|
||||
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
|
||||
}
|
||||
|
||||
if (options?.userIDs?.length) {
|
||||
options.limit = options.userIDs.length;
|
||||
if (options?.userIds?.length) {
|
||||
options.limit = options.userIds.length;
|
||||
}
|
||||
|
||||
return new Promise((resolve) => {
|
||||
return requestAllMembers(guildID, shardID, resolve, options);
|
||||
return requestAllMembers(guildId, shardId, resolve, options);
|
||||
}) as Promise<Collection<string, Member>>;
|
||||
}
|
||||
|
||||
@@ -8,18 +8,18 @@ import { endpoints } from "../../util/constants.ts";
|
||||
* ⚠️ **ADVANCED USE ONLY: Your members will be cached in your guild most likely. Only use this when you are absolutely sure the member is not cached.**
|
||||
*/
|
||||
export async function getMember(
|
||||
guildID: string,
|
||||
guildId: string,
|
||||
id: string,
|
||||
options?: { force?: boolean },
|
||||
) {
|
||||
const guild = await cacheHandlers.get("guilds", guildID);
|
||||
const guild = await cacheHandlers.get("guilds", guildId);
|
||||
if (!guild && !options?.force) return;
|
||||
|
||||
const data = (await RequestManager.get(
|
||||
endpoints.GUILD_MEMBER(guildID, id),
|
||||
endpoints.GUILD_MEMBER(guildId, id),
|
||||
)) as MemberCreatePayload;
|
||||
|
||||
const memberStruct = await structures.createMemberStruct(data, guildID);
|
||||
const memberStruct = await structures.createMemberStruct(data, guildId);
|
||||
await cacheHandlers.set("members", memberStruct.id, memberStruct);
|
||||
|
||||
return memberStruct;
|
||||
|
||||
@@ -13,12 +13,12 @@ import { endpoints } from "../../util/constants.ts";
|
||||
* REST(this function): 50/s global(across all shards) rate limit with ALL requests this included
|
||||
* GW(fetchMembers): 120/m(PER shard) rate limit. Meaning if you have 8 shards your limit is 960/m.
|
||||
*/
|
||||
export async function getMembers(guildID: string, options?: GetMemberOptions) {
|
||||
export async function getMembers(guildId: string, options?: GetMemberOptions) {
|
||||
if (!(identifyPayload.intents && Intents.GUILD_MEMBERS)) {
|
||||
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
|
||||
}
|
||||
|
||||
const guild = await cacheHandlers.get("guilds", guildID);
|
||||
const guild = await cacheHandlers.get("guilds", guildId);
|
||||
if (!guild) throw new Error(Errors.GUILD_NOT_FOUND);
|
||||
|
||||
const members = new Collection<string, Member>();
|
||||
@@ -40,7 +40,7 @@ export async function getMembers(guildID: string, options?: GetMemberOptions) {
|
||||
}
|
||||
|
||||
const result = (await RequestManager.get(
|
||||
`${endpoints.GUILD_MEMBERS(guildID)}?limit=${
|
||||
`${endpoints.GUILD_MEMBERS(guildId)}?limit=${
|
||||
membersLeft > 1000 ? 1000 : membersLeft
|
||||
}${options?.after ? `&after=${options.after}` : ""}`,
|
||||
)) as MemberCreatePayload[];
|
||||
@@ -49,7 +49,7 @@ export async function getMembers(guildID: string, options?: GetMemberOptions) {
|
||||
result.map(async (member) => {
|
||||
const memberStruct = await structures.createMemberStruct(
|
||||
member,
|
||||
guildID,
|
||||
guildId,
|
||||
);
|
||||
|
||||
await cacheHandlers.set("members", memberStruct.id, memberStruct);
|
||||
|
||||
@@ -8,15 +8,15 @@ import { requestAllMembers } from "../../ws/shard_manager.ts";
|
||||
* ⚠️ **ADVANCED USE ONLY: Your members will be cached in your guild most likely. Only use this when you are absolutely sure the member is not cached.**
|
||||
*/
|
||||
export async function getMembersByQuery(
|
||||
guildID: string,
|
||||
guildId: string,
|
||||
name: string,
|
||||
limit = 1,
|
||||
) {
|
||||
const guild = await cacheHandlers.get("guilds", guildID);
|
||||
const guild = await cacheHandlers.get("guilds", guildId);
|
||||
if (!guild) return;
|
||||
|
||||
return new Promise((resolve) => {
|
||||
return requestAllMembers(guild.id, guild.shardID, resolve, {
|
||||
return requestAllMembers(guild.id, guild.shardId, resolve, {
|
||||
query: name,
|
||||
limit,
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { botID } from "../../bot.ts";
|
||||
import { botId } from "../../bot.ts";
|
||||
import { RequestManager } from "../../rest/request_manager.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import {
|
||||
@@ -7,9 +7,9 @@ import {
|
||||
} from "../../util/permissions.ts";
|
||||
|
||||
/** Kick a member from the server */
|
||||
export async function kick(guildID: string, memberID: string, reason?: string) {
|
||||
const botsHighestRole = await highestRole(guildID, botID);
|
||||
const membersHighestRole = await highestRole(guildID, memberID);
|
||||
export async function kick(guildId: string, memberId: string, reason?: string) {
|
||||
const botsHighestRole = await highestRole(guildId, botId);
|
||||
const membersHighestRole = await highestRole(guildId, memberId);
|
||||
if (
|
||||
botsHighestRole && membersHighestRole &&
|
||||
botsHighestRole.position <= membersHighestRole.position
|
||||
@@ -17,10 +17,10 @@ export async function kick(guildID: string, memberID: string, reason?: string) {
|
||||
throw new Error(Errors.BOTS_HIGHEST_ROLE_TOO_LOW);
|
||||
}
|
||||
|
||||
await requireBotGuildPermissions(guildID, ["KICK_MEMBERS"]);
|
||||
await requireBotGuildPermissions(guildId, ["KICK_MEMBERS"]);
|
||||
|
||||
const result = await RequestManager.delete(
|
||||
endpoints.GUILD_MEMBER(guildID, memberID),
|
||||
endpoints.GUILD_MEMBER(guildId, memberId),
|
||||
{ reason },
|
||||
);
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@ import { editMember } from "./edit_member.ts";
|
||||
|
||||
/**
|
||||
* Move a member from a voice channel to another.
|
||||
* @param guildID the id of the guild which the channel exists in
|
||||
* @param memberID the id of the member to move.
|
||||
* @param channelID id of channel to move user to (if they are connected to voice)
|
||||
* @param guildId the id of the guild which the channel exists in
|
||||
* @param memberId the id of the member to move.
|
||||
* @param channelId id of channel to move user to (if they are connected to voice)
|
||||
*/
|
||||
export function moveMember(
|
||||
guildID: string,
|
||||
memberID: string,
|
||||
channelID: string,
|
||||
guildId: string,
|
||||
memberId: string,
|
||||
channelId: string,
|
||||
) {
|
||||
return editMember(guildID, memberID, { channel_id: channelID });
|
||||
return editMember(guildId, memberId, { channel_id: channelId });
|
||||
}
|
||||
|
||||
@@ -9,16 +9,16 @@ import { camelKeysToSnakeCase } from "../../util/utils.ts";
|
||||
* By default, prune will not remove users with roles. You can optionally include specific roles in your prune by providing the roles (resolved to include_roles internally) parameter. Any inactive user that has a subset of the provided role(s) will be included in the prune and users with additional roles will not.
|
||||
*/
|
||||
export async function pruneMembers(
|
||||
guildID: string,
|
||||
guildId: string,
|
||||
options: PruneOptions,
|
||||
) {
|
||||
if (options.days && options.days < 1) throw new Error(Errors.PRUNE_MIN_DAYS);
|
||||
if (options.days && options.days > 30) throw new Error(Errors.PRUNE_MAX_DAYS);
|
||||
|
||||
await requireBotGuildPermissions(guildID, ["KICK_MEMBERS"]);
|
||||
await requireBotGuildPermissions(guildId, ["KICK_MEMBERS"]);
|
||||
|
||||
const result = await RequestManager.post(
|
||||
endpoints.GUILD_PRUNE(guildID),
|
||||
endpoints.GUILD_PRUNE(guildId),
|
||||
camelKeysToSnakeCase(options),
|
||||
);
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@ import { formatImageURL } from "../../util/utils.ts";
|
||||
|
||||
/** The users custom avatar or the default avatar if you don't have a member object. */
|
||||
export function rawAvatarURL(
|
||||
userID: string,
|
||||
userId: string,
|
||||
discriminator: string,
|
||||
avatar?: string | null,
|
||||
size: ImageSize = 128,
|
||||
format?: ImageFormats,
|
||||
) {
|
||||
return avatar
|
||||
? formatImageURL(endpoints.USER_AVATAR(userID, avatar), size, format)
|
||||
? formatImageURL(endpoints.USER_AVATAR(userId, avatar), size, format)
|
||||
: endpoints.USER_DEFAULT_AVATAR(Number(discriminator) % 5);
|
||||
}
|
||||
|
||||
@@ -6,21 +6,21 @@ import { sendMessage } from "../messages/send_message.ts";
|
||||
|
||||
/** Send a message to a users DM. Note: this takes 2 API calls. 1 is to fetch the users dm channel. 2 is to send a message to that channel. */
|
||||
export async function sendDirectMessage(
|
||||
memberID: string,
|
||||
memberId: string,
|
||||
content: string | MessageContent,
|
||||
) {
|
||||
let dmChannel = await cacheHandlers.get("channels", memberID);
|
||||
let dmChannel = await cacheHandlers.get("channels", memberId);
|
||||
if (!dmChannel) {
|
||||
// If not available in cache create a new one.
|
||||
const dmChannelData = await RequestManager.post(
|
||||
endpoints.USER_DM,
|
||||
{ recipient_id: memberID },
|
||||
{ recipient_id: memberId },
|
||||
) as DMChannelCreatePayload;
|
||||
const channelStruct = await structures.createChannelStruct(
|
||||
dmChannelData as unknown as ChannelCreatePayload,
|
||||
);
|
||||
// Recreate the channel and add it undert he users id
|
||||
await cacheHandlers.set("channels", memberID, channelStruct);
|
||||
await cacheHandlers.set("channels", memberId, channelStruct);
|
||||
dmChannel = channelStruct;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
||||
|
||||
/** Remove the ban for a user. Requires BAN_MEMBERS permission */
|
||||
export async function unban(guildID: string, id: string) {
|
||||
await requireBotGuildPermissions(guildID, ["BAN_MEMBERS"]);
|
||||
export async function unban(guildId: string, id: string) {
|
||||
await requireBotGuildPermissions(guildId, ["BAN_MEMBERS"]);
|
||||
|
||||
const result = await RequestManager.delete(endpoints.GUILD_BAN(guildID, id));
|
||||
const result = await RequestManager.delete(endpoints.GUILD_BAN(guildId, id));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user