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:
ayntee
2021-03-29 21:03:46 +04:00
committed by GitHub
parent 618d30b65d
commit eaff54f90f
138 changed files with 895 additions and 908 deletions
@@ -1,9 +1,9 @@
import { cacheHandlers } from "../../cache.ts";
/** Gets an array of all the channels ids that are the children of this category. */
export function categoryChildrenIDs(guildID: string, id: string) {
export function categoryChildrenIds(guildId: string, id: string) {
return cacheHandlers.filter(
"channels",
(channel) => channel.parentID === id && channel.guildID === guildID,
(channel) => channel.parentId === id && channel.guildId === guildId,
);
}
@@ -1,12 +1,12 @@
/** Checks if a channel overwrite for a user id or a role id has permission in this channel */
export function channelOverwriteHasPermission(
guildID: string,
guildId: string,
id: string,
overwrites: RawOverwrite[],
permissions: Permission[],
) {
const overwrite = overwrites.find((perm) => perm.id === id) ||
overwrites.find((perm) => perm.id === guildID);
overwrites.find((perm) => perm.id === guildId);
return permissions.every((perm) => {
if (overwrite) {
+3 -3
View File
@@ -9,7 +9,7 @@ import {
/** Create a channel in your server. Bot needs MANAGE_CHANNEL permissions in the server. */
export async function createChannel(
guildID: string,
guildId: string,
name: string,
options?: ChannelCreateOptions,
) {
@@ -20,10 +20,10 @@ export async function createChannel(
overwrite.deny.forEach(requiredPerms.add, requiredPerms);
});
await requireBotGuildPermissions(guildID, [...requiredPerms]);
await requireBotGuildPermissions(guildId, [...requiredPerms]);
const result = (await RequestManager.post(
endpoints.GUILD_CHANNELS(guildID),
endpoints.GUILD_CHANNELS(guildId),
{
...options,
name,
+7 -7
View File
@@ -5,25 +5,25 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts";
/** Delete a channel in your server. Bot needs MANAGE_CHANNEL permissions in the server. */
export async function deleteChannel(
guildID: string,
channelID: string,
guildId: string,
channelId: string,
reason?: string,
) {
await requireBotGuildPermissions(guildID, ["MANAGE_CHANNELS"]);
await requireBotGuildPermissions(guildId, ["MANAGE_CHANNELS"]);
const guild = await cacheHandlers.get("guilds", guildID);
const guild = await cacheHandlers.get("guilds", guildId);
if (!guild) throw new Error(Errors.GUILD_NOT_FOUND);
if (guild?.rulesChannelID === channelID) {
if (guild?.rulesChannelId === channelId) {
throw new Error(Errors.RULES_CHANNEL_CANNOT_BE_DELETED);
}
if (guild?.publicUpdatesChannelID === channelID) {
if (guild?.publicUpdatesChannelId === channelId) {
throw new Error(Errors.UPDATES_CHANNEL_CANNOT_BE_DELETED);
}
const result = await RequestManager.delete(
endpoints.CHANNEL_BASE(channelID),
endpoints.CHANNEL_BASE(channelId),
{ reason },
);
@@ -4,14 +4,14 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts";
/** Delete the channel permission overwrites for a user or role in this channel. Requires `MANAGE_ROLES` permission. */
export async function deleteChannelOverwrite(
guildID: string,
channelID: string,
overwriteID: string,
guildId: string,
channelId: string,
overwriteId: string,
) {
await requireBotGuildPermissions(guildID, ["MANAGE_ROLES"]);
await requireBotGuildPermissions(guildId, ["MANAGE_ROLES"]);
const result = await RequestManager.delete(
endpoints.CHANNEL_OVERWRITE(channelID, overwriteID),
endpoints.CHANNEL_OVERWRITE(channelId, overwriteId),
);
return result;
+11 -11
View File
@@ -7,18 +7,18 @@ import {
/** Update a channel's settings. Requires the `MANAGE_CHANNELS` permission for the guild. */
export async function editChannel(
channelID: string,
channelId: string,
options: ChannelEditOptions,
reason?: string,
) {
await requireBotChannelPermissions(channelID, ["MANAGE_CHANNELS"]);
await requireBotChannelPermissions(channelId, ["MANAGE_CHANNELS"]);
if (options.name || options.topic) {
const request = editChannelNameTopicQueue.get(channelID);
const request = editChannelNameTopicQueue.get(channelId);
if (!request) {
// If this hasnt been done before simply add 1 for it
editChannelNameTopicQueue.set(channelID, {
channelID: channelID,
editChannelNameTopicQueue.set(channelId, {
channelId: channelId,
amount: 1,
// 10 minutes from now
timestamp: Date.now() + 600000,
@@ -30,7 +30,7 @@ export async function editChannel(
request.timestamp = Date.now() + 600000;
} else {
// 2 have already been used add to queue
request.items.push({ channelID, options });
request.items.push({ channelId, options });
if (editChannelProcessing) return;
editChannelProcessing = true;
processEditChannelQueue();
@@ -43,7 +43,7 @@ export async function editChannel(
// deno-lint-ignore camelcase
rate_limit_per_user: options.rateLimitPerUser,
// deno-lint-ignore camelcase
parent_id: options.parentID,
parent_id: options.parentId,
// deno-lint-ignore camelcase
user_limit: options.userLimit,
// deno-lint-ignore camelcase
@@ -56,7 +56,7 @@ export async function editChannel(
}),
};
const result = await RequestManager.patch(endpoints.CHANNEL_BASE(channelID), {
const result = await RequestManager.patch(endpoints.CHANNEL_BASE(channelId), {
...payload,
reason,
});
@@ -75,7 +75,7 @@ function processEditChannelQueue() {
if (now > request.timestamp) return;
// 10 minutes have passed so we can reset this channel again
if (!request.items.length) {
return editChannelNameTopicQueue.delete(request.channelID);
return editChannelNameTopicQueue.delete(request.channelId);
}
request.amount = 0;
// There are items to process for this request
@@ -83,11 +83,11 @@ function processEditChannelQueue() {
if (!details) return;
editChannel(details.channelID, details.options);
editChannel(details.channelId, details.options);
const secondDetails = request.items.shift();
if (!secondDetails) return;
return editChannel(secondDetails.channelID, secondDetails.options);
return editChannel(secondDetails.channelId, secondDetails.options);
});
if (editChannelNameTopicQueue.size) {
@@ -7,15 +7,15 @@ import {
/** Edit the channel permission overwrites for a user or role in this channel. Requires `MANAGE_ROLES` permission. */
export async function editChannelOverwrite(
guildID: string,
channelID: string,
overwriteID: string,
guildId: string,
channelId: string,
overwriteId: string,
options: Omit<Overwrite, "id">,
) {
await requireBotGuildPermissions(guildID, ["MANAGE_ROLES"]);
await requireBotGuildPermissions(guildId, ["MANAGE_ROLES"]);
const result = await RequestManager.put(
endpoints.CHANNEL_OVERWRITE(channelID, overwriteID),
endpoints.CHANNEL_OVERWRITE(channelId, overwriteId),
{
allow: calculateBits(options.allow),
deny: calculateBits(options.deny),
+5 -5
View File
@@ -4,15 +4,15 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts";
/** Follow a News Channel to send messages to a target channel. Requires the `MANAGE_WEBHOOKS` permission in the target channel. Returns the webhook id. */
export async function followChannel(
sourceChannelID: string,
targetChannelID: string,
sourceChannelId: string,
targetChannelId: string,
) {
await requireBotChannelPermissions(targetChannelID, ["MANAGE_WEBHOOKS"]);
await requireBotChannelPermissions(targetChannelId, ["MANAGE_WEBHOOKS"]);
const data = (await RequestManager.post(
endpoints.CHANNEL_FOLLOW(sourceChannelID),
endpoints.CHANNEL_FOLLOW(sourceChannelId),
{
webhook_channel_id: targetChannelID,
webhook_channel_id: targetChannelId,
},
)) as FollowedChannelPayload;
+2 -2
View File
@@ -7,9 +7,9 @@ import { endpoints } from "../../util/constants.ts";
*
* ⚠️ **If you need this, you are probably doing something wrong. This is not intended for use. Your channels will be cached in your guild.**
*/
export async function getChannel(channelID: string, addToCache = true) {
export async function getChannel(channelId: string, addToCache = true) {
const result = (await RequestManager.get(
endpoints.CHANNEL_BASE(channelID),
endpoints.CHANNEL_BASE(channelId),
)) as ChannelCreatePayload;
const channelStruct = await structures.createChannelStruct(
+3 -3
View File
@@ -3,11 +3,11 @@ import { endpoints } from "../../util/constants.ts";
import { requireBotChannelPermissions } from "../../util/permissions.ts";
/** Gets the webhooks for this channel. Requires MANAGE_WEBHOOKS */
export async function getChannelWebhooks(channelID: string) {
await requireBotChannelPermissions(channelID, ["MANAGE_WEBHOOKS"]);
export async function getChannelWebhooks(channelId: string) {
await requireBotChannelPermissions(channelId, ["MANAGE_WEBHOOKS"]);
const result = await RequestManager.get(
endpoints.CHANNEL_WEBHOOKS(channelID),
endpoints.CHANNEL_WEBHOOKS(channelId),
);
return result as WebhookPayload[];
+3 -3
View File
@@ -7,13 +7,13 @@ import { endpoints } from "../../util/constants.ts";
*
* ⚠️ **If you need this, you are probably doing something wrong. This is not intended for use. Your channels will be cached in your guild.**
*/
export async function getChannels(guildID: string, addToCache = true) {
export async function getChannels(guildId: string, addToCache = true) {
const result = (await RequestManager.get(
endpoints.GUILD_CHANNELS(guildID),
endpoints.GUILD_CHANNELS(guildId),
) as ChannelCreatePayload[]);
return Promise.all(result.map(async (res) => {
const channelStruct = await structures.createChannelStruct(res, guildID);
const channelStruct = await structures.createChannelStruct(res, guildId);
if (addToCache) {
await cacheHandlers.set("channels", channelStruct.id, channelStruct);
}
+2 -2
View File
@@ -3,9 +3,9 @@ import { structures } from "../../structures/mod.ts";
import { endpoints } from "../../util/constants.ts";
/** Get pinned messages in this channel. */
export async function getPins(channelID: string) {
export async function getPins(channelId: string) {
const result = (await RequestManager.get(
endpoints.CHANNEL_PINS(channelID),
endpoints.CHANNEL_PINS(channelId),
)) as MessageCreateOptions[];
return Promise.all(
+4 -4
View File
@@ -1,11 +1,11 @@
import { cacheHandlers } from "../../cache.ts";
/** Checks whether a channel is synchronized with its parent/category channel or not. */
export async function isChannelSynced(channelID: string) {
const channel = await cacheHandlers.get("channels", channelID);
if (!channel?.parentID) return false;
export async function isChannelSynced(channelId: string) {
const channel = await cacheHandlers.get("channels", channelId);
if (!channel?.parentId) return false;
const parentChannel = await cacheHandlers.get("channels", channel.parentID);
const parentChannel = await cacheHandlers.get("channels", channel.parentId);
if (!parentChannel) return false;
return channel.permissionOverwrites?.every((overwrite) => {
+4 -4
View File
@@ -8,8 +8,8 @@ import { botHasChannelPermissions } from "../../util/permissions.ts";
* However, if a bot is responding to a command and expects the computation to take a few seconds,
* this endpoint may be called to let the user know that the bot is processing their message.
*/
export async function startTyping(channelID: string) {
const channel = await cacheHandlers.get("channels", channelID);
export async function startTyping(channelId: string) {
const channel = await cacheHandlers.get("channels", channelId);
// If the channel is cached, we can do extra checks/safety
if (channel) {
if (
@@ -23,7 +23,7 @@ export async function startTyping(channelID: string) {
}
const hasSendMessagesPerm = await botHasChannelPermissions(
channelID,
channelId,
["SEND_MESSAGES"],
);
if (
@@ -33,7 +33,7 @@ export async function startTyping(channelID: string) {
}
}
const result = await RequestManager.post(endpoints.CHANNEL_TYPING(channelID));
const result = await RequestManager.post(endpoints.CHANNEL_TYPING(channelId));
return result;
}
+2 -2
View File
@@ -3,7 +3,7 @@ import { endpoints } from "../../util/constants.ts";
/** Modify the positions of channels on the guild. Requires MANAGE_CHANNELS permisison. */
export async function swapChannels(
guildID: string,
guildId: string,
channelPositions: PositionSwap[],
) {
if (channelPositions.length < 2) {
@@ -11,7 +11,7 @@ export async function swapChannels(
}
const result = await RequestManager.patch(
endpoints.GUILD_CHANNELS(guildID),
endpoints.GUILD_CHANNELS(guildId),
channelPositions,
);