From 6bad7fa2409895f04e3d24c032ff952bf4fa292c Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Thu, 15 Apr 2021 21:31:22 +0200 Subject: [PATCH 01/78] Update bot.ts --- src/bot.ts | 53 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/src/bot.ts b/src/bot.ts index c1505c1fb..7d514ecfc 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -90,34 +90,43 @@ export function setApplicationId(id: string) { * * Advanced Devs: This function will allow you to have an insane amount of customization potential as when you get to large bots you need to be able to optimize every tiny detail to make you bot work the way you need. */ -export async function startBigBrainBot(data: BigBrainBotConfig) { - authorization = `Bot ${data.token}`; - identifyPayload.token = `Bot ${data.token}`; +export async function startBigBrainBot(config: BigBrainBotConfig) { + authorization = `Bot ${config.token}`; + rest.token = `Bot ${config.token}`; - if (data.secretKey) secretKey = data.secretKey; - if (data.restURL) baseEndpoints.BASE_URL = data.restURL; - if (data.cdnURL) baseEndpoints.CDN_URL = data.cdnURL; - if (data.eventHandlers) eventHandlers = data.eventHandlers; - if (data.compress) { - identifyPayload.compress = data.compress; - } - - identifyPayload.intents = data.intents.reduce( - ( - bits, - next, - ) => (bits |= typeof next === "string" - ? DiscordGatewayIntents[next] - : next), - 0, - ); + if (config.secretKey) secretKey = config.secretKey; + if (config.restURL) baseEndpoints.BASE_URL = config.restURL; + if (config.cdnURL) baseEndpoints.CDN_URL = config.cdnURL; + if (config.eventHandlers) eventHandlers = config.eventHandlers; // PROXY DOESNT NEED US SPAWNING SHARDS - if (!data.wsPort) { + if (!config.wsPort) { + ws.identifyPayload.token = `Bot ${config.token}`; + + if (config.compress) { + ws.identifyPayload.compress = config.compress; + } + + ws.identifyPayload.intents = config.intents.reduce( + ( + bits, + next, + ) => (bits |= typeof next === "string" + ? DiscordGatewayIntents[next] + : next), + 0, + ); + // Initial API connection to get info about bots connection ws.botGatewayData = await getGatewayBot(); + console.log(ws.botGatewayData); + ws.maxShards = ws.maxShards || config.lastShardId || + ws.botGatewayData.shards; + // Explicitly append gateway version and encoding + ws.botGatewayData.url += `?v=${GATEWAY_VERSION}&encoding=json`; proxyWSURL = ws.botGatewayData.url; - ws.spawnShards(data.firstShardId); + + ws.spawnShards(config.firstShardId); } } From 864945f578992491fe828564f38ecd78b13cb8ac Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 16 Apr 2021 18:57:42 +0200 Subject: [PATCH 02/78] remove identifyPayload --- src/bot.ts | 26 +++----------------------- src/helpers/members/fetch_members.ts | 4 ++-- src/helpers/members/get_members.ts | 5 +++-- 3 files changed, 8 insertions(+), 27 deletions(-) diff --git a/src/bot.ts b/src/bot.ts index 7d514ecfc..76026c9d1 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -14,18 +14,6 @@ export let eventHandlers: EventHandlers = {}; export let proxyWSURL = `wss://gateway.discord.gg`; -export const identifyPayload = { - token: "", - compress: true, - properties: { - $os: "linux", - $browser: "Discordeno", - $device: "Discordeno", - }, - intents: 0, - shard: [0, 0], -}; - export async function startBot(config: BotConfig) { if (config.eventHandlers) eventHandlers = config.eventHandlers; authorization = `Bot ${config.token}`; @@ -49,17 +37,8 @@ export async function startBot(config: BotConfig) { ws.botGatewayData.url += `?v=${GATEWAY_VERSION}&encoding=json`; proxyWSURL = ws.botGatewayData.url; - identifyPayload.token = config.token; - identifyPayload.intents = config.intents.reduce( - ( - bits, - next, - ) => (bits |= typeof next === "string" - ? DiscordGatewayIntents[next] - : next), - 0, - ); - identifyPayload.shard = [0, ws.botGatewayData.shards]; + + // ws.lastShardId = ws.maxShards; ws.spawnShards(); } @@ -122,6 +101,7 @@ export async function startBigBrainBot(config: BigBrainBotConfig) { console.log(ws.botGatewayData); ws.maxShards = ws.maxShards || config.lastShardId || ws.botGatewayData.shards; + ws.lastShardId = config.lastShardId || ws.botGatewayData.shards; // Explicitly append gateway version and encoding ws.botGatewayData.url += `?v=${GATEWAY_VERSION}&encoding=json`; proxyWSURL = ws.botGatewayData.url; diff --git a/src/helpers/members/fetch_members.ts b/src/helpers/members/fetch_members.ts index e336d42cf..9a0428aad 100644 --- a/src/helpers/members/fetch_members.ts +++ b/src/helpers/members/fetch_members.ts @@ -1,9 +1,9 @@ -import { identifyPayload } from "../../bot.ts"; import { DiscordenoMember } from "../../structures/member.ts"; import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts"; import { RequestGuildMembers } from "../../types/guilds/request_guild_members.ts"; import { Errors } from "../../types/misc/errors.ts"; import { Collection } from "../../util/collection.ts"; +import { ws } from "../../ws/ws.ts"; /** * ⚠️ BEGINNER DEVS!! YOU SHOULD ALMOST NEVER NEED THIS AND YOU CAN GET FROM cache.members.get() @@ -21,7 +21,7 @@ export function fetchMembers( // You can request 1 member without the intent if ( (!options?.limit || options.limit > 1) && - !(identifyPayload.intents && DiscordGatewayIntents.GUILD_MEMBERS) + !(ws.identifyPayload.intents && DiscordGatewayIntents.GUILD_MEMBERS) ) { throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS); } diff --git a/src/helpers/members/get_members.ts b/src/helpers/members/get_members.ts index 396eb844f..0a1a97249 100644 --- a/src/helpers/members/get_members.ts +++ b/src/helpers/members/get_members.ts @@ -1,4 +1,4 @@ -import { eventHandlers, identifyPayload } from "../../bot.ts"; +import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; import { DiscordenoMember } from "../../structures/member.ts"; @@ -12,6 +12,7 @@ import { ListGuildMembers } from "../../types/guilds/list_guild_members.ts"; import { Errors } from "../../types/misc/errors.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; +import { ws } from "../../ws/ws.ts"; /** * ⚠️ BEGINNER DEVS!! YOU SHOULD ALMOST NEVER NEED THIS AND YOU CAN GET FROM cache.members.get() @@ -22,7 +23,7 @@ import { endpoints } from "../../util/constants.ts"; * 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?: ListGuildMembers) { - if (!(identifyPayload.intents && DiscordGatewayIntents.GUILD_MEMBERS)) { + if (!(ws.identifyPayload.intents && DiscordGatewayIntents.GUILD_MEMBERS)) { throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS); } From 6315ba75fc0d5670ca86701d4a093a6df7b2589d Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 16 Apr 2021 19:14:48 +0200 Subject: [PATCH 03/78] add sendShardMessage --- src/helpers/misc/edit_bot_status.ts | 4 ++-- src/ws/identify.ts | 6 +++--- src/ws/send_shard_message.ts | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 src/ws/send_shard_message.ts diff --git a/src/helpers/misc/edit_bot_status.ts b/src/helpers/misc/edit_bot_status.ts index 35e09c6bc..bfed6b0bc 100644 --- a/src/helpers/misc/edit_bot_status.ts +++ b/src/helpers/misc/edit_bot_status.ts @@ -1,6 +1,7 @@ import { eventHandlers } from "../../bot.ts"; import { DiscordGatewayOpcodes } from "../../types/codes/gateway_opcodes.ts"; import type { StatusUpdate } from "../../types/gateway/status_update.ts"; +import { sendShardMessage } from "../../ws/send_shard_message.ts"; import { ws } from "../../ws/ws.ts"; export function editBotStatus(data: Omit) { @@ -10,7 +11,7 @@ export function editBotStatus(data: Omit) { `Running forEach loop in editBotStatus function.`, ); - shard.queue.push({ + sendShardMessage(shard, { op: DiscordGatewayOpcodes.StatusUpdate, d: { since: null, @@ -18,6 +19,5 @@ export function editBotStatus(data: Omit) { ...data, }, }); - ws.processQueue(shard.id); }); } diff --git a/src/ws/identify.ts b/src/ws/identify.ts index 0671e8d9a..bcd8d2fa4 100644 --- a/src/ws/identify.ts +++ b/src/ws/identify.ts @@ -1,5 +1,6 @@ import { DiscordGatewayOpcodes } from "../types/codes/gateway_opcodes.ts"; import { closeWS } from "./close_ws.ts"; +import { sendShardMessage } from "./send_shard_message.ts"; import { ws } from "./ws.ts"; export async function identify(shardId: number, maxShards: number) { @@ -40,11 +41,10 @@ export async function identify(shardId: number, maxShards: number) { }); socket.onopen = () => { - ws.shards.get(shardId)?.queue.unshift({ + sendShardMessage(shardId, { op: DiscordGatewayOpcodes.Identify, d: { ...ws.identifyPayload, shard: [shardId, maxShards] }, - }); - ws.processQueue(shardId); + }, true); }; return new Promise((resolve, reject) => { diff --git a/src/ws/send_shard_message.ts b/src/ws/send_shard_message.ts new file mode 100644 index 000000000..1603c088f --- /dev/null +++ b/src/ws/send_shard_message.ts @@ -0,0 +1,18 @@ +import { DiscordenoShard, WebSocketRequest, ws } from "./ws.ts"; + +export function sendShardMessage( + shard: number | DiscordenoShard, + message: WebSocketRequest, + highPriority = false, +) { + if (typeof shard === "number") shard = ws.shards.get(shard)!; + if (!shard) return; + + if (!highPriority) { + shard.queue.push(message); + } else { + shard.queue.unshift(message); + } + + ws.processQueue(shard.id); +} From 2ce185a6964d8cb041253b70cd397e70afb30c6f Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 16 Apr 2021 19:15:01 +0200 Subject: [PATCH 04/78] Update heartbeat.ts --- src/ws/heartbeat.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/ws/heartbeat.ts b/src/ws/heartbeat.ts index 29576ac4c..133b95982 100644 --- a/src/ws/heartbeat.ts +++ b/src/ws/heartbeat.ts @@ -12,20 +12,21 @@ export async function heartbeat(shardId: number, interval: number) { ws.log("HEARTBEATING_DETAILS", { shardId, interval, shard }); + // The first heartbeat is special so we send it without setInterval: https://discord.com/developers/docs/topics/gateway#heartbeating + await delay(Math.floor(shard.heartbeat.interval * Math.random())); + + if (shard.ws.readyState !== WebSocket.OPEN) return; + + shard.ws.send(JSON.stringify({ + op: DiscordGatewayOpcodes.Heartbeat, + d: shard.previousSequenceNumber, + })); + shard.heartbeat.keepAlive = true; shard.heartbeat.acknowledged = false; shard.heartbeat.lastSentAt = Date.now(); shard.heartbeat.interval = interval; - // The first heartbeat is special so we send it without setInterval: https://discord.com/developers/docs/topics/gateway#heartbeating - await delay(Math.floor(shard.heartbeat.interval * Math.random())); - - shard.queue.unshift({ - op: DiscordGatewayOpcodes.Heartbeat, - d: shard.previousSequenceNumber, - }); - ws.processQueue(shard.id); - shard.heartbeat.intervalId = setInterval(() => { ws.log("DEBUG", `Running setInterval in heartbeat file.`); const currentShard = ws.shards.get(shardId); @@ -50,11 +51,11 @@ export async function heartbeat(shardId: number, interval: number) { if (currentShard.ws.readyState !== WebSocket.OPEN) return; + currentShard.heartbeat.acknowledged = false; + currentShard.ws.send(JSON.stringify({ op: DiscordGatewayOpcodes.Heartbeat, d: currentShard.previousSequenceNumber, })); - - currentShard.heartbeat.acknowledged = false; }, shard.heartbeat.interval); } From 6a0ab380e74431259bfac09e31c9501d8845f73a Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 16 Apr 2021 19:15:12 +0200 Subject: [PATCH 05/78] Update resume.ts --- src/ws/resume.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/ws/resume.ts b/src/ws/resume.ts index 9e6ae9223..4be26a0ac 100644 --- a/src/ws/resume.ts +++ b/src/ws/resume.ts @@ -1,13 +1,11 @@ import { DiscordGatewayOpcodes } from "../types/codes/gateway_opcodes.ts"; import { closeWS } from "./close_ws.ts"; +import { sendShardMessage } from "./send_shard_message.ts"; import { ws } from "./ws.ts"; export async function resume(shardId: number) { ws.log("RESUMING", { shardId }); - // CREATE A SHARD - const socket = await ws.createShard(shardId); - // NOW WE HANDLE RESUMING THIS SHARD // Get the old data for this shard necessary for resuming const oldShard = ws.shards.get(shardId); @@ -19,6 +17,9 @@ export async function resume(shardId: number) { clearInterval(oldShard.heartbeat.intervalId); } + // CREATE A SHARD + const socket = await ws.createShard(shardId); + const sessionId = oldShard?.sessionId || ""; const previousSequenceNumber = oldShard?.previousSequenceNumber || 0; @@ -47,15 +48,13 @@ export async function resume(shardId: number) { // Resume on open socket.onopen = () => { - ws.shards.get(shardId)?.queue.unshift({ + sendShardMessage(shardId, { op: DiscordGatewayOpcodes.Resume, d: { token: ws.identifyPayload.token, session_id: sessionId, seq: previousSequenceNumber, }, - }); - - ws.processQueue(shardId); + }, true); }; } From 320c9b4b91370d90f309fd407e154a3dec4cd539 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 16 Apr 2021 19:16:08 +0200 Subject: [PATCH 06/78] Update handle_on_message.ts --- src/ws/handle_on_message.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ws/handle_on_message.ts b/src/ws/handle_on_message.ts index a4145e33d..960c3cfeb 100644 --- a/src/ws/handle_on_message.ts +++ b/src/ws/handle_on_message.ts @@ -8,6 +8,7 @@ import { delay } from "../util/utils.ts"; import { decompressWith } from "./deps.ts"; import { identify } from "./identify.ts"; import { resume } from "./resume.ts"; +import { sendShardMessage } from "./send_shard_message.ts"; import { ws } from "./ws.ts"; /** Handler for handling every message event from websocket. */ @@ -38,11 +39,10 @@ export async function handleOnMessage(message: any, shardId: number) { shard.heartbeat.lastSentAt = Date.now(); // Discord randomly sends this requiring an immediate heartbeat back - shard.queue.unshift({ + sendShardMessage(shard, { op: DiscordGatewayOpcodes.Heartbeat, d: shard?.previousSequenceNumber, - }); - ws.processQueue(shard.id); + }, true); break; case DiscordGatewayOpcodes.Hello: ws.heartbeat( From b730e2044c388fa24f0cd538bcccbef62a89eef2 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 16 Apr 2021 20:45:39 +0200 Subject: [PATCH 07/78] order i guess --- src/handlers/members/GUILD_MEMBERS_CHUNK.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handlers/members/GUILD_MEMBERS_CHUNK.ts b/src/handlers/members/GUILD_MEMBERS_CHUNK.ts index c65cf50c3..75b2e7a51 100644 --- a/src/handlers/members/GUILD_MEMBERS_CHUNK.ts +++ b/src/handlers/members/GUILD_MEMBERS_CHUNK.ts @@ -1,8 +1,8 @@ import { cache, cacheHandlers } from "../../cache.ts"; import { structures } from "../../structures/mod.ts"; -import { Collection } from "../../util/collection.ts"; import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; import { DiscordGuildMembersChunk } from "../../types/members/guild_members_chunk.ts"; +import { Collection } from "../../util/collection.ts"; export async function handleGuildMembersChunk(data: DiscordGatewayPayload) { const payload = data.d as DiscordGuildMembersChunk; From 1a94f1913e1e8096750badb61a8225fda42b08b0 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 16 Apr 2021 20:45:55 +0200 Subject: [PATCH 08/78] add implementation --- src/helpers/members/fetch_members.ts | 34 +++++++++++++++------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/helpers/members/fetch_members.ts b/src/helpers/members/fetch_members.ts index 9a0428aad..164cd7b8a 100644 --- a/src/helpers/members/fetch_members.ts +++ b/src/helpers/members/fetch_members.ts @@ -1,8 +1,11 @@ +import { cache } from "../../cache.ts"; import { DiscordenoMember } from "../../structures/member.ts"; +import { DiscordGatewayOpcodes } from "../../types/codes/gateway_opcodes.ts"; import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts"; import { RequestGuildMembers } from "../../types/guilds/request_guild_members.ts"; import { Errors } from "../../types/misc/errors.ts"; import { Collection } from "../../util/collection.ts"; +import { sendShardMessage } from "../../ws/send_shard_message.ts"; import { ws } from "../../ws/ws.ts"; /** @@ -31,21 +34,20 @@ export function fetchMembers( } return new Promise((resolve) => { - return requestAllMembers(guildId, shardId, resolve, options); + const nonce = `${guildId}-${Date.now()}`; + cache.fetchAllMembersProcessingRequests.set(nonce, resolve); + + sendShardMessage(shardId, { + op: DiscordGatewayOpcodes.RequestGuildMembers, + d: { + guild_id: guildId, + // If a query is provided use it, OR if a limit is NOT provided use "" + query: options?.query || (options?.limit ? undefined : ""), + limit: options?.limit || 0, + presences: options?.presences || false, + user_ids: options?.userIds, + nonce, + }, + }); }) as Promise>; } - -// TODO: finish implementing this -function requestAllMembers( - _guildId: string, - _shardId: number, - _resolve: ( - value: - | Collection - | PromiseLike>, - ) => void, - // deno-lint-ignore no-explicit-any - _options: any, -): void { - throw new Error("Function not implemented."); -} From 1d1ef47e8afcd75eb2d45720c03547462d1c9de8 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 16 Apr 2021 20:46:05 +0200 Subject: [PATCH 09/78] dupe code ._. --- src/helpers/members/get_members_by_query.ts | 37 --------------------- 1 file changed, 37 deletions(-) delete mode 100644 src/helpers/members/get_members_by_query.ts diff --git a/src/helpers/members/get_members_by_query.ts b/src/helpers/members/get_members_by_query.ts deleted file mode 100644 index f0bd9b126..000000000 --- a/src/helpers/members/get_members_by_query.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { cacheHandlers } from "../../cache.ts"; -import { DiscordenoMember } from "../../structures/member.ts"; -import { Collection } from "../../util/collection.ts"; - -/** Returns guild member objects for the specified user by their nickname/username. - * - * ⚠️ **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, - name: string, - limit = 1, -) { - const guild = await cacheHandlers.get("guilds", guildId); - if (!guild) return; - - return new Promise((resolve) => { - return requestAllMembers(guild.id, guild.shardId, resolve, { - query: name, - limit, - }); - }) as Promise>; -} - -// TODO: implement this -function requestAllMembers( - _id: string, - _shardId: number, - _resolve: ( - value: - | Collection - | PromiseLike>, - ) => void, - _arg3: { query: string; limit: number }, -): void { - throw new Error("Function not implemented."); -} From d2bad949a1d05ab186ab33ea443ae7bb28fc4ded Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 16 Apr 2021 20:56:37 +0200 Subject: [PATCH 10/78] omit guildid --- src/helpers/members/fetch_members.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/members/fetch_members.ts b/src/helpers/members/fetch_members.ts index 164cd7b8a..c7638b8cf 100644 --- a/src/helpers/members/fetch_members.ts +++ b/src/helpers/members/fetch_members.ts @@ -19,7 +19,7 @@ import { ws } from "../../ws/ws.ts"; export function fetchMembers( guildId: string, shardId: number, - options?: RequestGuildMembers, + options?: Omit, ) { // You can request 1 member without the intent if ( From 5e38471175b542919b0ceff672dc6e5385697fc0 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 16 Apr 2021 21:01:58 +0200 Subject: [PATCH 11/78] uups remove removed thing --- src/helpers/members/fetch_members.ts | 2 +- src/helpers/mod.ts | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/helpers/members/fetch_members.ts b/src/helpers/members/fetch_members.ts index c7638b8cf..3d5034164 100644 --- a/src/helpers/members/fetch_members.ts +++ b/src/helpers/members/fetch_members.ts @@ -24,7 +24,7 @@ export function fetchMembers( // You can request 1 member without the intent if ( (!options?.limit || options.limit > 1) && - !(ws.identifyPayload.intents && DiscordGatewayIntents.GUILD_MEMBERS) + !(ws.identifyPayload.intents & DiscordGatewayIntents.GUILD_MEMBERS) ) { throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS); } diff --git a/src/helpers/mod.ts b/src/helpers/mod.ts index 49486d140..4a1b4de18 100644 --- a/src/helpers/mod.ts +++ b/src/helpers/mod.ts @@ -66,7 +66,6 @@ import { editMember } from "./members/edit_member.ts"; import { fetchMembers } from "./members/fetch_members.ts"; import { getMember } from "./members/get_member.ts"; import { getMembers } from "./members/get_members.ts"; -import { getMembersByQuery } from "./members/get_members_by_query.ts"; import { kick, kickMember } from "./members/kick_member.ts"; import { moveMember } from "./members/move_member.ts"; import { pruneMembers } from "./members/prune_members.ts"; @@ -190,7 +189,6 @@ export { getInvites, getMember, getMembers, - getMembersByQuery, getMessage, getMessages, getPins, @@ -316,7 +314,6 @@ export let helpers = { editMember, fetchMembers, getMember, - getMembersByQuery, getMembers, kickMember, moveMember, From f2ae9db4a467833a587ed3388347bfd24a6f9dee Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Thu, 22 Apr 2021 21:34:28 +0200 Subject: [PATCH 12/78] add application command permissions endpoint --- src/util/constants.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util/constants.ts b/src/util/constants.ts index e241097b0..2d188c57e 100644 --- a/src/util/constants.ts +++ b/src/util/constants.ts @@ -148,6 +148,8 @@ export const endpoints = { `${baseEndpoints.BASE_URL}/applications/${applicationId}/commands`, COMMANDS_GUILD: (applicationId: string, guildId: string) => `${baseEndpoints.BASE_URL}/applications/${applicationId}/guilds/${guildId}/commands`, + COMMANDS_PERMISSIONS: (applicationId: string, guildId: string) => + `${endpoints.COMMANDS_GUILD(applicationId, guildId)}/permissions`, COMMANDS_ID: (applicationId: string, commandId: string) => `${baseEndpoints.BASE_URL}/applications/${applicationId}/commands/${commandId}`, COMMANDS_GUILD_ID: ( From 9fa6afa0574431bb69d69aa510db601217fa2ae3 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Thu, 22 Apr 2021 21:34:30 +0200 Subject: [PATCH 13/78] Create get_slash_command_permissions.ts --- .../commands/get_slash_command_permissions.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/helpers/commands/get_slash_command_permissions.ts diff --git a/src/helpers/commands/get_slash_command_permissions.ts b/src/helpers/commands/get_slash_command_permissions.ts new file mode 100644 index 000000000..4d69204bf --- /dev/null +++ b/src/helpers/commands/get_slash_command_permissions.ts @@ -0,0 +1,12 @@ +import { applicationId } from "../../bot.ts"; +import { rest } from "../../rest/rest.ts"; +import { GuildApplicationCommandPermissions } from "../../types/interactions/guild_application_command_permissions.ts"; +import { endpoints } from "../../util/constants.ts"; + +/** Fetches command permissions for all commands for your application in a guild. Returns an array of GuildApplicationCommandPermissions objects. */ +export async function getSlashCommandPermissions(guildId: string) { + return await rest.runMethod( + "get", + endpoints.COMMANDS_PERMISSIONS(applicationId, guildId), + ); +} From 7a085f1cd65538f40f8a8d597a7f61350d3f67fe Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Wed, 28 Apr 2021 18:22:44 +0200 Subject: [PATCH 14/78] Update create_slash_command.ts --- src/helpers/commands/create_slash_command.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/commands/create_slash_command.ts b/src/helpers/commands/create_slash_command.ts index 2da719f56..c756570e5 100644 --- a/src/helpers/commands/create_slash_command.ts +++ b/src/helpers/commands/create_slash_command.ts @@ -21,7 +21,7 @@ import { */ export async function createSlashCommand( options: CreateGlobalApplicationCommand, - guildId: string, + guildId?: string, ) { validateSlashCommands([options], true); From ef7ae71f05fbaf693d1e64a6c0f644d20b101373 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Sun, 25 Apr 2021 16:32:04 +0200 Subject: [PATCH 15/78] Create edit_slash_command_permissions.ts --- .../commands/edit_slash_command_permissions.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/helpers/commands/edit_slash_command_permissions.ts diff --git a/src/helpers/commands/edit_slash_command_permissions.ts b/src/helpers/commands/edit_slash_command_permissions.ts new file mode 100644 index 000000000..5617f3a9d --- /dev/null +++ b/src/helpers/commands/edit_slash_command_permissions.ts @@ -0,0 +1,17 @@ +import { applicationId } from "../../bot.ts"; +import { rest } from "../../rest/rest.ts"; +import { ApplicationCommandPermissions } from "../../types/interactions/application_command_permissions.ts"; +import { endpoints } from "../../util/constants.ts"; + +/** Edits command permissions for a specific command for your application in a guild. */ +export async function editSlashCommandPermissions( + guildId: string, + commandId: string, + options: ApplicationCommandPermissions[], +) { + return await rest.runMethod( + "put", + endpoints.COMMANDS_PERMISSION(applicationId, guildId, commandId), + options, + ); +} From 79c236dde569125ab18dd947bbe9ec09afad0a1f Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Sun, 25 Apr 2021 16:33:03 +0100 Subject: [PATCH 16/78] Create get_slash_command_permission.ts --- .../commands/get_slash_command_permission.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/helpers/commands/get_slash_command_permission.ts diff --git a/src/helpers/commands/get_slash_command_permission.ts b/src/helpers/commands/get_slash_command_permission.ts new file mode 100644 index 000000000..f34362b9f --- /dev/null +++ b/src/helpers/commands/get_slash_command_permission.ts @@ -0,0 +1,15 @@ +import { applicationId } from "../../bot.ts"; +import { rest } from "../../rest/rest.ts"; +import { GuildApplicationCommandPermissions } from "../../types/interactions/guild_application_command_permissions.ts"; +import { endpoints } from "../../util/constants.ts"; + +/** Fetches command permissions for a specific command for your application in a guild. Returns a GuildApplicationCommandPermissions object. */ +export async function getSlashCommandPermission( + guildId: string, + commandId: string, +) { + return await rest.runMethod( + "get", + endpoints.COMMANDS_PERMISSION(applicationId, guildId, commandId), + ); +} From ae1361c31ed0cd97be1eacc18650d871d2e27a65 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Mon, 26 Apr 2021 20:23:56 +0100 Subject: [PATCH 17/78] Create batch_edit_slash_command_permissions.ts --- .../batch_edit_slash_command_permissions.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/helpers/commands/batch_edit_slash_command_permissions.ts diff --git a/src/helpers/commands/batch_edit_slash_command_permissions.ts b/src/helpers/commands/batch_edit_slash_command_permissions.ts new file mode 100644 index 000000000..cf1adfa46 --- /dev/null +++ b/src/helpers/commands/batch_edit_slash_command_permissions.ts @@ -0,0 +1,17 @@ +import { applicationId } from "../../bot.ts"; +import { rest } from "../../rest/rest.ts"; +import { ApplicationCommandPermissions } from "../../types/interactions/application_command_permissions.ts"; +import { endpoints } from "../../util/constants.ts"; +import { snakeKeysToCamelCase } from "../../util/utils.ts"; + +/** Batch edits permissions for all commands in a guild. Takes an array of partial GuildApplicationCommandPermissions objects including `id` and `permissions`. */ +export async function batchEditSlashCommandPermissions( + guildId: string, + options: { id: string; permissions: ApplicationCommandPermissions[] }[], +) { + return await rest.runMethod( + "put", + endpoints.COMMANDS_PERMISSIONS(applicationId, guildId), + snakeKeysToCamelCase(options), + ); +} From ee36ccacc4bbfeaf67113cfb7e7f837bb2ac3840 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Wed, 28 Apr 2021 16:45:08 +0200 Subject: [PATCH 18/78] Update message.ts --- src/structures/message.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/structures/message.ts b/src/structures/message.ts index 033ee223a..f1b745d9b 100644 --- a/src/structures/message.ts +++ b/src/structures/message.ts @@ -177,8 +177,10 @@ export async function createDiscordenoMessage(data: Message) { } export interface DiscordenoMessage - extends Omit { + extends Omit { // For better user experience + /** Id of the guild which the massage has been send in. Empty string if it a DM */ + guildId: string; /** Ids of users specifically mentioned in the message */ mentionedUserIds: string[]; /** Ids of roles specifically mentioned in this message */ From 0d7ba259a8c26c0f729661d27ede86af27753fa7 Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Wed, 28 Apr 2021 10:48:53 -0400 Subject: [PATCH 19/78] Update mod.ts --- mod.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/mod.ts b/mod.ts index a3f729ec0..c56b93ff0 100644 --- a/mod.ts +++ b/mod.ts @@ -6,6 +6,7 @@ export * from "./src/rest/mod.ts"; export * from "./src/structures/channel.ts"; export * from "./src/structures/guild.ts"; export * from "./src/structures/member.ts"; +export * from "./src/structures/message.ts"; export * from "./src/structures/mod.ts"; export * from "./src/structures/role.ts"; export * from "./src/types/mod.ts"; From 71d0f648e95cc0d770acd5a33ab463733dc26904 Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Wed, 28 Apr 2021 11:58:25 -0400 Subject: [PATCH 20/78] Update message.ts --- src/structures/message.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/structures/message.ts b/src/structures/message.ts index f1b745d9b..9f24937ee 100644 --- a/src/structures/message.ts +++ b/src/structures/message.ts @@ -155,6 +155,7 @@ export async function createDiscordenoMessage(data: Message) { ...props, /** The message id of the original message if this message was sent as a reply. If null, the original message was deleted. */ channelId: createNewProp(channelId), + content: createNewProp(data.content || ""), guildId: createNewProp(guildIdFinal), mentionedUserIds: createNewProp(mentions.map((m) => m.id)), mentionedRoleIds: createNewProp(mentionRoles), @@ -181,6 +182,8 @@ export interface DiscordenoMessage // For better user experience /** Id of the guild which the massage has been send in. Empty string if it a DM */ guildId: string; + /** The message content for this message. Empty string if no content was sent like an attachment only. */ + content: string; /** Ids of users specifically mentioned in the message */ mentionedUserIds: string[]; /** Ids of roles specifically mentioned in this message */ From 04b585c73916992bd502a03faef1eb51798bed95 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Wed, 28 Apr 2021 22:05:46 +0200 Subject: [PATCH 21/78] fix buggs --- src/helpers/commands/edit_slash_command_permissions.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/helpers/commands/edit_slash_command_permissions.ts b/src/helpers/commands/edit_slash_command_permissions.ts index 5617f3a9d..1ea764d8a 100644 --- a/src/helpers/commands/edit_slash_command_permissions.ts +++ b/src/helpers/commands/edit_slash_command_permissions.ts @@ -2,6 +2,7 @@ import { applicationId } from "../../bot.ts"; import { rest } from "../../rest/rest.ts"; import { ApplicationCommandPermissions } from "../../types/interactions/application_command_permissions.ts"; import { endpoints } from "../../util/constants.ts"; +import { camelKeysToSnakeCase } from "../../util/utils.ts"; /** Edits command permissions for a specific command for your application in a guild. */ export async function editSlashCommandPermissions( @@ -12,6 +13,6 @@ export async function editSlashCommandPermissions( return await rest.runMethod( "put", endpoints.COMMANDS_PERMISSION(applicationId, guildId, commandId), - options, + { permissions: camelKeysToSnakeCase(options) }, ); } From 32cb0dfdcc88939b52459785c4e18cc57edd0f6a Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Wed, 28 Apr 2021 22:05:53 +0200 Subject: [PATCH 22/78] Update constants.ts --- src/util/constants.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/util/constants.ts b/src/util/constants.ts index 2d188c57e..eed6df6f1 100644 --- a/src/util/constants.ts +++ b/src/util/constants.ts @@ -150,6 +150,14 @@ export const endpoints = { `${baseEndpoints.BASE_URL}/applications/${applicationId}/guilds/${guildId}/commands`, COMMANDS_PERMISSIONS: (applicationId: string, guildId: string) => `${endpoints.COMMANDS_GUILD(applicationId, guildId)}/permissions`, + COMMANDS_PERMISSION: ( + applicationId: string, + guildId: string, + commandId: string, + ) => + `${ + endpoints.COMMANDS_GUILD(applicationId, guildId) + }/${commandId}/permissions`, COMMANDS_ID: (applicationId: string, commandId: string) => `${baseEndpoints.BASE_URL}/applications/${applicationId}/commands/${commandId}`, COMMANDS_GUILD_ID: ( From 37de4b3922a226d0205c5aa6ba3ead509e001c01 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Wed, 28 Apr 2021 22:12:59 +0200 Subject: [PATCH 23/78] Update mod.ts --- src/helpers/mod.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/helpers/mod.ts b/src/helpers/mod.ts index 22799a964..f4e539e79 100644 --- a/src/helpers/mod.ts +++ b/src/helpers/mod.ts @@ -120,6 +120,8 @@ import { editDiscovery } from "./discovery/edit_discovery.ts"; import { getDiscoveryCategories } from "./discovery/get_discovery_categories.ts"; import { removeDiscoverySubcategory } from "./discovery/remove_discovery_subcategory.ts"; import { validDiscoveryTerm } from "./discovery/valid_discovery_term.ts"; +import { getSlashCommandPermission } from "./commands/get_slash_command_permission.ts"; +import { getSlashCommandPermissions } from "./commands/get_slash_command_permissions.ts"; export { addDiscoverySubcategory, @@ -206,6 +208,8 @@ export { getReactions, getRoles, getSlashCommand, + getSlashCommandPermission, + getSlashCommandPermissions, getSlashCommands, getTemplate, getUser, @@ -272,6 +276,8 @@ export let helpers = { deleteSlashCommand, deleteSlashResponse, editSlashResponse, + getSlashCommandPermission, + getSlashCommandPermissions, sendInteractionResponse, getSlashCommand, getSlashCommands, From d244d83a6a87525c7f60d0078a13aa5494b9371a Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Wed, 28 Apr 2021 22:22:23 +0200 Subject: [PATCH 24/78] Update mod.ts --- src/helpers/mod.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/helpers/mod.ts b/src/helpers/mod.ts index f4e539e79..9e952dd81 100644 --- a/src/helpers/mod.ts +++ b/src/helpers/mod.ts @@ -16,12 +16,20 @@ import { swapChannels } from "./channels/swap_channels.ts"; import { createSlashCommand } from "./commands/create_slash_command.ts"; import { deleteSlashCommand } from "./commands/delete_slash_command.ts"; import { deleteSlashResponse } from "./commands/delete_slash_response.ts"; +import { editSlashCommandPermissions } from "./commands/edit_slash_command_permissions.ts"; import { editSlashResponse } from "./commands/edit_slash_response.ts"; import { getSlashCommand } from "./commands/get_slash_command.ts"; import { getSlashCommands } from "./commands/get_slash_commands.ts"; +import { getSlashCommandPermission } from "./commands/get_slash_command_permission.ts"; +import { getSlashCommandPermissions } from "./commands/get_slash_command_permissions.ts"; import { sendInteractionResponse } from "./commands/send_interaction_response.ts"; import { upsertSlashCommand } from "./commands/upsert_slash_command.ts"; import { upsertSlashCommands } from "./commands/upsert_slash_commands.ts"; +import { addDiscoverySubcategory } from "./discovery/add_discovery_subcategory.ts"; +import { editDiscovery } from "./discovery/edit_discovery.ts"; +import { getDiscoveryCategories } from "./discovery/get_discovery_categories.ts"; +import { removeDiscoverySubcategory } from "./discovery/remove_discovery_subcategory.ts"; +import { validDiscoveryTerm } from "./discovery/valid_discovery_term.ts"; import { createEmoji } from "./emojis/create_emoji.ts"; import { deleteEmoji } from "./emojis/delete_emoji.ts"; import { editEmoji } from "./emojis/edit_emoji.ts"; @@ -115,13 +123,6 @@ import { executeWebhook } from "./webhooks/execute_webhook.ts"; import { getWebhook } from "./webhooks/get_webhook.ts"; import { getWebhooks } from "./webhooks/get_webhooks.ts"; import { getWebhookWithToken } from "./webhooks/get_webhook_with_token.ts"; -import { addDiscoverySubcategory } from "./discovery/add_discovery_subcategory.ts"; -import { editDiscovery } from "./discovery/edit_discovery.ts"; -import { getDiscoveryCategories } from "./discovery/get_discovery_categories.ts"; -import { removeDiscoverySubcategory } from "./discovery/remove_discovery_subcategory.ts"; -import { validDiscoveryTerm } from "./discovery/valid_discovery_term.ts"; -import { getSlashCommandPermission } from "./commands/get_slash_command_permission.ts"; -import { getSlashCommandPermissions } from "./commands/get_slash_command_permissions.ts"; export { addDiscoverySubcategory, @@ -278,6 +279,9 @@ export let helpers = { editSlashResponse, getSlashCommandPermission, getSlashCommandPermissions, + batchEditSlashCommandPermissions, + editSlashCommandPermissions, + editSlashCommandPermission, sendInteractionResponse, getSlashCommand, getSlashCommands, From 7e5176aa3ad949fe8dc5075b0bcf189226d14e34 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Wed, 28 Apr 2021 22:34:21 +0200 Subject: [PATCH 25/78] Update mod.ts --- src/helpers/mod.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/helpers/mod.ts b/src/helpers/mod.ts index 9e952dd81..71a16d577 100644 --- a/src/helpers/mod.ts +++ b/src/helpers/mod.ts @@ -13,6 +13,7 @@ import { getPins } from "./channels/get_pins.ts"; import { isChannelSynced } from "./channels/is_channel_synced.ts"; import { startTyping } from "./channels/start_typing.ts"; import { swapChannels } from "./channels/swap_channels.ts"; +import { batchEditSlashCommandPermissions } from "./commands/batch_edit_slash_command_permissions.ts"; import { createSlashCommand } from "./commands/create_slash_command.ts"; import { deleteSlashCommand } from "./commands/delete_slash_command.ts"; import { deleteSlashResponse } from "./commands/delete_slash_response.ts"; @@ -132,6 +133,7 @@ export { avatarURL, ban, banMember, + batchEditSlashCommandPermissions, categoryChildren, channelOverwriteHasPermission, createChannel, @@ -281,7 +283,6 @@ export let helpers = { getSlashCommandPermissions, batchEditSlashCommandPermissions, editSlashCommandPermissions, - editSlashCommandPermission, sendInteractionResponse, getSlashCommand, getSlashCommands, From a84ede2a001725d6e3ff32db678e1ddb91944fad Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Thu, 29 Apr 2021 09:04:02 +0200 Subject: [PATCH 26/78] wrong converter --- src/helpers/commands/batch_edit_slash_command_permissions.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helpers/commands/batch_edit_slash_command_permissions.ts b/src/helpers/commands/batch_edit_slash_command_permissions.ts index cf1adfa46..514b546b7 100644 --- a/src/helpers/commands/batch_edit_slash_command_permissions.ts +++ b/src/helpers/commands/batch_edit_slash_command_permissions.ts @@ -2,7 +2,7 @@ import { applicationId } from "../../bot.ts"; import { rest } from "../../rest/rest.ts"; import { ApplicationCommandPermissions } from "../../types/interactions/application_command_permissions.ts"; import { endpoints } from "../../util/constants.ts"; -import { snakeKeysToCamelCase } from "../../util/utils.ts"; +import { camelKeysToSnakeCase } from "../../util/utils.ts"; /** Batch edits permissions for all commands in a guild. Takes an array of partial GuildApplicationCommandPermissions objects including `id` and `permissions`. */ export async function batchEditSlashCommandPermissions( @@ -12,6 +12,6 @@ export async function batchEditSlashCommandPermissions( return await rest.runMethod( "put", endpoints.COMMANDS_PERMISSIONS(applicationId, guildId), - snakeKeysToCamelCase(options), + camelKeysToSnakeCase(options), ); } From c0a549a634cd2cd98a6d7f6af688652a36084cde Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Thu, 29 Apr 2021 11:16:31 +0200 Subject: [PATCH 27/78] Update tell_cluster_to_identify.ts --- src/ws/tell_cluster_to_identify.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/ws/tell_cluster_to_identify.ts b/src/ws/tell_cluster_to_identify.ts index f89721c48..518724994 100644 --- a/src/ws/tell_cluster_to_identify.ts +++ b/src/ws/tell_cluster_to_identify.ts @@ -1,4 +1,3 @@ -import { closeWS } from "./close_ws.ts"; import { ws } from "./ws.ts"; /** Allows users to hook in and change to communicate to different clusters across different servers or anything they like. For example using redis pubsub to talk to other servers. */ @@ -7,11 +6,5 @@ export async function tellClusterToIdentify( shardId: number, _bucketId: number, ) { - // When resharding this may exist already - const oldShard = ws.shards.get(shardId); await ws.identify(shardId, ws.maxShards); - - if (oldShard) { - closeWS(oldShard.ws, 3063, "Resharded!"); - } } From 5bdb35f16fc1ac17c034174b36aae9c640d69ac9 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Thu, 29 Apr 2021 11:16:34 +0200 Subject: [PATCH 28/78] Update bot.ts --- src/bot.ts | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/bot.ts b/src/bot.ts index 76026c9d1..670bb98c9 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -69,24 +69,24 @@ export function setApplicationId(id: string) { * * Advanced Devs: This function will allow you to have an insane amount of customization potential as when you get to large bots you need to be able to optimize every tiny detail to make you bot work the way you need. */ -export async function startBigBrainBot(config: BigBrainBotConfig) { - authorization = `Bot ${config.token}`; - rest.token = `Bot ${config.token}`; +export async function startBigBrainBot(options: BigBrainBotConfig) { + authorization = `Bot ${options.token}`; + rest.token = `Bot ${options.token}`; - if (config.secretKey) secretKey = config.secretKey; - if (config.restURL) baseEndpoints.BASE_URL = config.restURL; - if (config.cdnURL) baseEndpoints.CDN_URL = config.cdnURL; - if (config.eventHandlers) eventHandlers = config.eventHandlers; + if (options.secretKey) secretKey = options.secretKey; + if (options.restURL) baseEndpoints.BASE_URL = options.restURL; + if (options.cdnURL) baseEndpoints.CDN_URL = options.cdnURL; + if (options.eventHandlers) eventHandlers = options.eventHandlers; // PROXY DOESNT NEED US SPAWNING SHARDS - if (!config.wsPort) { - ws.identifyPayload.token = `Bot ${config.token}`; + if (!options.wsPort) { + ws.identifyPayload.token = `Bot ${options.token}`; - if (config.compress) { - ws.identifyPayload.compress = config.compress; + if (options.compress) { + ws.identifyPayload.compress = options.compress; } - ws.identifyPayload.intents = config.intents.reduce( + ws.identifyPayload.intents = options.intents.reduce( ( bits, next, @@ -98,15 +98,14 @@ export async function startBigBrainBot(config: BigBrainBotConfig) { // Initial API connection to get info about bots connection ws.botGatewayData = await getGatewayBot(); - console.log(ws.botGatewayData); - ws.maxShards = ws.maxShards || config.lastShardId || + ws.maxShards = ws.maxShards || ws.botGatewayData.shards; - ws.lastShardId = config.lastShardId || ws.botGatewayData.shards; + ws.lastShardId = options.lastShardId || ws.botGatewayData.shards; // Explicitly append gateway version and encoding ws.botGatewayData.url += `?v=${GATEWAY_VERSION}&encoding=json`; proxyWSURL = ws.botGatewayData.url; - ws.spawnShards(config.firstShardId); + ws.spawnShards(options.firstShardId); } } @@ -122,6 +121,8 @@ export interface BigBrainBotConfig extends BotConfig { firstShardId: number; /** The last shard to start for this worker. By default it will be 25 + the firstShardId. */ lastShardId?: number; + /** The maximum shard Id number. Useful for zero-downtime updates or resharding. */ + maxShards?: number; /** This can be used to forward the ws handling to a proxy. It will disable the sharding done by the bot side. */ wsPort?: number; /** This can be used to forward the REST handling to a proxy. */ From 680a9c896efa50638a2aad30d91fe6e373f982a3 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 12:12:16 +0200 Subject: [PATCH 29/78] Update fetch_members.ts --- src/helpers/members/fetch_members.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/members/fetch_members.ts b/src/helpers/members/fetch_members.ts index 3d5034164..aee4ed00c 100644 --- a/src/helpers/members/fetch_members.ts +++ b/src/helpers/members/fetch_members.ts @@ -2,7 +2,7 @@ import { cache } from "../../cache.ts"; import { DiscordenoMember } from "../../structures/member.ts"; import { DiscordGatewayOpcodes } from "../../types/codes/gateway_opcodes.ts"; import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts"; -import { RequestGuildMembers } from "../../types/guilds/request_guild_members.ts"; +import type { RequestGuildMembers } from "../../types/guilds/request_guild_members.ts"; import { Errors } from "../../types/misc/errors.ts"; import { Collection } from "../../util/collection.ts"; import { sendShardMessage } from "../../ws/send_shard_message.ts"; From 379d332492e2d4e28f27df2a2f5a583924abf34f Mon Sep 17 00:00:00 2001 From: ayntee Date: Fri, 30 Apr 2021 16:03:26 +0400 Subject: [PATCH 30/78] Complete some TODOs --- src/helpers/guilds/get_widget.ts | 7 +++-- .../guilds/modify_guild_welcome_screen.ts | 2 +- src/types/guilds/update_others_voice_state.ts | 6 ++-- src/types/guilds/update_self_voice_state.ts | 8 ++++-- src/ws/create_shard.ts | 28 +++++++++---------- 5 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/helpers/guilds/get_widget.ts b/src/helpers/guilds/get_widget.ts index c685b8088..adcc4989d 100644 --- a/src/helpers/guilds/get_widget.ts +++ b/src/helpers/guilds/get_widget.ts @@ -1,5 +1,6 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; +import { DiscordGuildWidget } from "../../types/guilds/guild_widget.ts"; import { Errors } from "../../types/misc/errors.ts"; import { endpoints } from "../../util/constants.ts"; @@ -11,6 +12,8 @@ export async function getWidget(guildId: string, options?: { force: boolean }) { if (!guild?.widgetEnabled) throw new Error(Errors.GUILD_WIDGET_NOT_ENABLED); } - // TODO: add return type - return await rest.runMethod("get", `${endpoints.GUILD_WIDGET(guildId)}.json`); + return await rest.runMethod( + "get", + `${endpoints.GUILD_WIDGET(guildId)}.json`, + ); } diff --git a/src/types/guilds/modify_guild_welcome_screen.ts b/src/types/guilds/modify_guild_welcome_screen.ts index d983043af..f7757e761 100644 --- a/src/types/guilds/modify_guild_welcome_screen.ts +++ b/src/types/guilds/modify_guild_welcome_screen.ts @@ -10,7 +10,7 @@ export interface ModifyGuildWelcomeScreen { description?: string | null; } -// TODO: add documentation link +/** https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen */ export type DiscordModifyGuildWelcomeScreen = SnakeCasedPropertiesDeep< ModifyGuildWelcomeScreen >; diff --git a/src/types/guilds/update_others_voice_state.ts b/src/types/guilds/update_others_voice_state.ts index 6b4c5aa8f..deb0904f2 100644 --- a/src/types/guilds/update_others_voice_state.ts +++ b/src/types/guilds/update_others_voice_state.ts @@ -1,4 +1,4 @@ -import { SnakeCaseProps } from "../util.ts"; +import { SnakeCasedProperties } from "../util.ts"; export interface UpdateOthersVoiceState { /** The id of the channel the user is currently in */ @@ -7,7 +7,7 @@ export interface UpdateOthersVoiceState { suppress?: boolean; } -// TODO: add corresponding link to the resource -export type DiscordUpdateOthersVoiceState = SnakeCaseProps< +/** https://discord.com/developers/docs/resources/guild#update-user-voice-state */ +export type DiscordUpdateOthersVoiceState = SnakeCasedProperties< UpdateOthersVoiceState >; diff --git a/src/types/guilds/update_self_voice_state.ts b/src/types/guilds/update_self_voice_state.ts index 120b60c8e..fcc6fbda3 100644 --- a/src/types/guilds/update_self_voice_state.ts +++ b/src/types/guilds/update_self_voice_state.ts @@ -1,4 +1,4 @@ -import { SnakeCaseProps } from "../util.ts"; +import { SnakeCasedProperties } from "../util.ts"; export interface UpdateSelfVoiceState { /** The id of the channel the user is currently in */ @@ -9,5 +9,7 @@ export interface UpdateSelfVoiceState { requestToSpeakTimestamp?: string | null; } -// TODO: add corresponding link to the resource -export type DiscordUpdateSelfVoiceState = SnakeCaseProps; +/** https://discord.com/developers/docs/resources/guild#update-current-user-voice-state */ +export type DiscordUpdateSelfVoiceState = SnakeCasedProperties< + UpdateSelfVoiceState +>; diff --git a/src/ws/create_shard.ts b/src/ws/create_shard.ts index cecbc20a0..a4b90af7a 100644 --- a/src/ws/create_shard.ts +++ b/src/ws/create_shard.ts @@ -1,3 +1,4 @@ +import { DiscordGatewayCloseEventCodes } from "../types/codes/gateway_close_event_codes.ts"; import { identify } from "./identify.ts"; import { resume } from "./resume.ts"; import { ws } from "./ws.ts"; @@ -33,25 +34,24 @@ export async function createShard(shardId: number) { return ws.log("CLOSED_RECONNECT", { shardId, payload: event }); } - // TODO: ENUM FOR THESE CODES? switch (event.code) { - case 4001: - case 4002: - case 4004: - case 4005: - case 4010: - case 4011: - case 4012: - case 4013: - case 4014: + case DiscordGatewayCloseEventCodes.UnknownOpcode: + case DiscordGatewayCloseEventCodes.DecodeError: + case DiscordGatewayCloseEventCodes.AuthenticationFailed: + case DiscordGatewayCloseEventCodes.AlreadyAuthenticated: + case DiscordGatewayCloseEventCodes.InvalidShard: + case DiscordGatewayCloseEventCodes.ShardingRequired: + case DiscordGatewayCloseEventCodes.InvalidApiVersion: + case DiscordGatewayCloseEventCodes.InvalidIntents: + case DiscordGatewayCloseEventCodes.DisallowedIntents: throw new Error( event.reason || "Discord gave no reason! GG! You broke Discord!", ); // THESE ERRORS CAN NO BE RESUMED! THEY MUST RE-IDENTIFY! - case 4003: - case 4007: - case 4008: - case 4009: + case DiscordGatewayCloseEventCodes.NotAuthenticated: + case DiscordGatewayCloseEventCodes.InvalidSeq: + case DiscordGatewayCloseEventCodes.RateLimited: + case DiscordGatewayCloseEventCodes.SessionTimedOut: identify(shardId, ws.maxShards); break; default: From c50fb39b42f8e2c5d58c3f73ed859b5fd1d93fa4 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 15:01:32 +0200 Subject: [PATCH 31/78] deleteServer to deleteGuild --- src/helpers/guilds/{delete_server.ts => delete_guild.ts} | 5 ++--- src/helpers/mod.ts | 6 +++--- src/structures/guild.ts | 6 +++--- tests/guilds/delete_server.ts | 6 +++--- tests/ws/start_bot.ts | 4 ++-- 5 files changed, 13 insertions(+), 14 deletions(-) rename src/helpers/guilds/{delete_server.ts => delete_guild.ts} (68%) diff --git a/src/helpers/guilds/delete_server.ts b/src/helpers/guilds/delete_guild.ts similarity index 68% rename from src/helpers/guilds/delete_server.ts rename to src/helpers/guilds/delete_guild.ts index 8dcf42eaf..496ac3088 100644 --- a/src/helpers/guilds/delete_server.ts +++ b/src/helpers/guilds/delete_guild.ts @@ -1,9 +1,8 @@ import { rest } from "../../rest/rest.ts"; import { endpoints } from "../../util/constants.ts"; -/** Delete a guild permanently. User must be owner. Returns 204 No Content on success. Fires a Guild Delete Gateway event. - */ -export async function deleteServer(guildId: string) { +/** Delete a guild permanently. User must be owner. Returns 204 No Content on success. Fires a Guild Delete Gateway event. */ +export async function deleteGuild(guildId: string) { return await rest.runMethod( "delete", endpoints.GUILDS_BASE(guildId), diff --git a/src/helpers/mod.ts b/src/helpers/mod.ts index 6991542d3..ee1de11cb 100644 --- a/src/helpers/mod.ts +++ b/src/helpers/mod.ts @@ -38,7 +38,7 @@ import { emojiURL } from "./emojis/emoji_url.ts"; import { getEmoji } from "./emojis/get_emoji.ts"; import { getEmojis } from "./emojis/get_emojis.ts"; import { createGuild } from "./guilds/create_guild.ts"; -import { deleteServer } from "./guilds/delete_server.ts"; +import { deleteGuild } from "./guilds/delete_guild.ts"; import { editGuild } from "./guilds/edit_guild.ts"; import { editWelcomeScreen } from "./guilds/edit_welcome_screen.ts"; import { editWidget } from "./guilds/edit_widget.ts"; @@ -147,13 +147,13 @@ export { deleteChannel, deleteChannelOverwrite, deleteEmoji, + deleteGuild, deleteGuildTemplate, deleteIntegration, deleteInvite, deleteMessage, deleteMessages, deleteRole, - deleteServer, deleteSlashCommand, deleteSlashResponse, deleteWebhook, @@ -295,7 +295,7 @@ export let helpers = { // guilds categoryChildren, createGuild, - deleteServer, + deleteGuild, editGuild, editWidget, editWelcomeScreen, diff --git a/src/structures/guild.ts b/src/structures/guild.ts index 4dda13665..562440c25 100644 --- a/src/structures/guild.ts +++ b/src/structures/guild.ts @@ -1,6 +1,6 @@ import { botId, eventHandlers } from "../bot.ts"; import { cache, cacheHandlers } from "../cache.ts"; -import { deleteServer } from "../helpers/guilds/delete_server.ts"; +import { deleteGuild } from "../helpers/guilds/delete_guild.ts"; import { editGuild } from "../helpers/guilds/edit_guild.ts"; import { getAuditLogs } from "../helpers/guilds/get_audit_logs.ts"; import { getBan } from "../helpers/guilds/get_ban.ts"; @@ -79,7 +79,7 @@ const baseGuild: Partial = { return guildSplashURL(this.id!, this.splash!, size, format); }, delete() { - return deleteServer(this.id!); + return deleteGuild(this.id!); }, edit(options) { return editGuild(this.id!, options); @@ -272,7 +272,7 @@ export interface DiscordenoGuild extends format?: DiscordImageFormat, ): string | undefined; /** Delete a guild permanently. User must be owner. Returns 204 No Content on success. Fires a Guild Delete Gateway event. */ - delete(): ReturnType; + delete(): ReturnType; /** Leave a guild */ leave(): ReturnType; /** Edit the server. Requires the MANAGE_GUILD permission. */ diff --git a/tests/guilds/delete_server.ts b/tests/guilds/delete_server.ts index 96dd306d9..52c2b9955 100644 --- a/tests/guilds/delete_server.ts +++ b/tests/guilds/delete_server.ts @@ -1,7 +1,7 @@ import { cache } from "../../src/cache.ts"; -import { deleteServer } from "../../src/helpers/guilds/delete_server.ts"; -import { defaultTestOptions, tempData } from "../ws/start_bot.ts"; +import { deleteGuild } from "../../src/helpers/guilds/delete_guild.ts"; import { delayUntil } from "../util/delay_until.ts"; +import { defaultTestOptions, tempData } from "../ws/start_bot.ts"; Deno.test({ name: "[guild] delete a guild", @@ -13,7 +13,7 @@ Deno.test({ throw new Error("The guild was not cached so impossible to delete."); } - await deleteServer(tempData.guildId); + await deleteGuild(tempData.guildId); await delayUntil(10000, () => !cache.guilds.has(tempData.guildId)); if (cache.guilds.has(tempData.guildId)) { diff --git a/tests/ws/start_bot.ts b/tests/ws/start_bot.ts index f6abcfc97..50992e855 100644 --- a/tests/ws/start_bot.ts +++ b/tests/ws/start_bot.ts @@ -1,6 +1,6 @@ import { botId, startBot } from "../../src/bot.ts"; import { cache } from "../../src/cache.ts"; -import { deleteServer } from "../../src/helpers/guilds/delete_server.ts"; +import { deleteGuild } from "../../src/helpers/guilds/delete_guild.ts"; import { delay } from "../../src/util/utils.ts"; import { ws } from "../../src/ws/ws.ts"; import { assertExists } from "../deps.ts"; @@ -49,7 +49,7 @@ Deno.test({ // DELETE GUILDS IF LESS THAN 10 SERVERS AS SAFETY MEASURE if (cache.guilds.size <= 10) { - for (const guild of cache.guilds.values()) await deleteServer(guild.id); + for (const guild of cache.guilds.values()) await deleteGuild(guild.id); } // Assertions From b28ab09f7e6bd403d017e16a2b6a0a97826565f4 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 15:01:44 +0200 Subject: [PATCH 32/78] remove rawGateway --- src/types/discordeno/eventHandlers.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/types/discordeno/eventHandlers.ts b/src/types/discordeno/eventHandlers.ts index f60fda6e2..8dba6659e 100644 --- a/src/types/discordeno/eventHandlers.ts +++ b/src/types/discordeno/eventHandlers.ts @@ -161,8 +161,6 @@ export interface EventHandlers { ) => unknown; /** Sent before every event execution. Discordeno will not await its execution. */ raw?: (data: GatewayPayload) => unknown; - // TODO: remove this? - // rawGateway?: (data: unknown) => unknown; /** Sent when all shards went ready. */ ready?: () => unknown; /** Sent when a user adds a reaction to a message. */ From 7aab8a803096780075cb5d5e9904c89f987bdeeb Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 15:04:44 +0200 Subject: [PATCH 33/78] add: addToCache option --- src/helpers/members/get_members.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/helpers/members/get_members.ts b/src/helpers/members/get_members.ts index b51fff45a..202c4a70d 100644 --- a/src/helpers/members/get_members.ts +++ b/src/helpers/members/get_members.ts @@ -19,7 +19,10 @@ import { ws } from "../../ws/ws.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?: ListGuildMembers) { +export async function getMembers( + guildId: string, + options?: ListGuildMembers & { addToCache?: boolean }, +) { if (!(ws.identifyPayload.intents && DiscordGatewayIntents.GUILD_MEMBERS)) { throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS); } @@ -61,11 +64,13 @@ export async function getMembers(guildId: string, options?: ListGuildMembers) { guildId, ); - await cacheHandlers.set( - "members", - discordenoMember.id, - discordenoMember, - ); + if (options?.addToCache !== false) { + await cacheHandlers.set( + "members", + discordenoMember.id, + discordenoMember, + ); + } return discordenoMember; }), From 5b314d0b9ec05b00d2694969ca59a3efbfad0548 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 15:13:46 +0200 Subject: [PATCH 34/78] typos --- src/util/permissions.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/permissions.ts b/src/util/permissions.ts index 3607a561f..1eb5b65a9 100644 --- a/src/util/permissions.ts +++ b/src/util/permissions.ts @@ -201,9 +201,9 @@ export async function getMissingGuildPermissions( member: string | DiscordenoMember, permissions: PermissionStrings[], ) { - // First we need the role permissino bits this member has + // First we need the role permission bits this member has const permissionBits = await calculateBasePermissions(guild, member); - // Second returnn the members missing permissions + // Second return the members missing permissions return missingPermissions(permissionBits, permissions); } From a7de104b9afd5c152f12dc1539c9fe5efd907480 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 15:13:58 +0200 Subject: [PATCH 35/78] calculatePermissions should take a string --- src/helpers/channels/clone_channel.ts | 4 ++-- src/util/permissions.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/helpers/channels/clone_channel.ts b/src/helpers/channels/clone_channel.ts index 76ca0a7b0..e84e039e0 100644 --- a/src/helpers/channels/clone_channel.ts +++ b/src/helpers/channels/clone_channel.ts @@ -29,8 +29,8 @@ export async function cloneChannel(channelId: string, reason?: string) { ) => ({ id: overwrite.id, type: overwrite.type, - allow: calculatePermissions(BigInt(overwrite.allow)), - deny: calculatePermissions(BigInt(overwrite.deny)), + allow: calculatePermissions(overwrite.allow), + deny: calculatePermissions(overwrite.deny), })), }; diff --git a/src/util/permissions.ts b/src/util/permissions.ts index 1eb5b65a9..90e187562 100644 --- a/src/util/permissions.ts +++ b/src/util/permissions.ts @@ -268,13 +268,13 @@ export function requireBotChannelPermissions( } /** This function converts a bitwise string to permission strings */ -export function calculatePermissions(permissionBits: bigint) { +export function calculatePermissions(permissionBits: string) { return Object.keys(DiscordBitwisePermissionFlags).filter((permission) => { // Since Object.keys() not only returns the permission names but also the bit values we need to return false if it is a Number if (Number(permission)) return false; // Check if permissionBits has this permission return ( - permissionBits & + BigInt(permissionBits) & BigInt(DiscordBitwisePermissionFlags[permission as PermissionStrings]) ); }) as PermissionStrings[]; From 8c347747dd0c91af3cc0efa99a9705d6910011c8 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 15:22:48 +0200 Subject: [PATCH 36/78] delete: removeUserReaction --- src/helpers/messages/remove_reaction.ts | 17 ++++++++++-- src/helpers/messages/remove_user_reaction.ts | 29 -------------------- src/helpers/mod.ts | 3 -- src/structures/message.ts | 9 ++++-- tests/messages/remove_user_reaction.ts | 11 ++------ 5 files changed, 24 insertions(+), 45 deletions(-) delete mode 100644 src/helpers/messages/remove_user_reaction.ts diff --git a/src/helpers/messages/remove_reaction.ts b/src/helpers/messages/remove_reaction.ts index b8bd2f707..1be275af9 100644 --- a/src/helpers/messages/remove_reaction.ts +++ b/src/helpers/messages/remove_reaction.ts @@ -1,12 +1,18 @@ import { rest } from "../../rest/rest.ts"; import { endpoints } from "../../util/constants.ts"; +import { requireBotChannelPermissions } from "../../util/permissions.ts"; -/** Removes a reaction from the bot on this message. Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. */ +/** Removes a reaction from the given user on this message, defaults to bot. Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. */ export async function removeReaction( channelId: string, messageId: string, reaction: string, + userId?: string, ) { + if (userId) { + await requireBotChannelPermissions(channelId, ["MANAGE_MESSAGES"]); + } + if (reaction.startsWith("<:")) { reaction = reaction.substring(2, reaction.length - 1); } else if (reaction.startsWith("( "delete", - endpoints.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction), + userId + ? endpoints.CHANNEL_MESSAGE_REACTION_USER( + channelId, + messageId, + reaction, + userId, + ) + : endpoints.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction), ); } diff --git a/src/helpers/messages/remove_user_reaction.ts b/src/helpers/messages/remove_user_reaction.ts deleted file mode 100644 index 7f5b67dfd..000000000 --- a/src/helpers/messages/remove_user_reaction.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { rest } from "../../rest/rest.ts"; -import { endpoints } from "../../util/constants.ts"; -import { requireBotChannelPermissions } from "../../util/permissions.ts"; - -/** Removes a reaction from the specified user on this message. Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. */ -export async function removeUserReaction( - channelId: string, - messageId: string, - reaction: string, - userId: string, -) { - await requireBotChannelPermissions(channelId, ["MANAGE_MESSAGES"]); - - if (reaction.startsWith("<:")) { - reaction = reaction.substring(2, reaction.length - 1); - } else if (reaction.startsWith("( - "delete", - endpoints.CHANNEL_MESSAGE_REACTION_USER( - channelId, - messageId, - reaction, - userId, - ), - ); -} diff --git a/src/helpers/mod.ts b/src/helpers/mod.ts index ee1de11cb..483f7378f 100644 --- a/src/helpers/mod.ts +++ b/src/helpers/mod.ts @@ -93,7 +93,6 @@ import { publishMessage } from "./messages/publish_message.ts"; import { removeAllReactions } from "./messages/remove_all_reactions.ts"; import { removeReaction } from "./messages/remove_reaction.ts"; import { removeReactionEmoji } from "./messages/remove_reaction_emoji.ts"; -import { removeUserReaction } from "./messages/remove_user_reaction.ts"; import { sendMessage } from "./messages/send_message.ts"; import { unpin, unpinMessage } from "./messages/unpin_message.ts"; import { editBotStatus } from "./misc/edit_bot_status.ts"; @@ -240,7 +239,6 @@ export { removeReaction, removeReactionEmoji, removeRole, - removeUserReaction, sendDirectMessage, sendInteractionResponse, sendMessage, @@ -361,7 +359,6 @@ export let helpers = { removeAllReactions, removeReactionEmoji, removeReaction, - removeUserReaction, sendMessage, unpinMessage, // misc diff --git a/src/structures/message.ts b/src/structures/message.ts index 9f24937ee..add15b8c4 100644 --- a/src/structures/message.ts +++ b/src/structures/message.ts @@ -121,8 +121,8 @@ const baseMessage: Partial = { removeReactionEmoji(reaction) { return removeReactionEmoji(this.channelId!, this.id!, reaction); }, - removeReaction(reaction) { - return removeReaction(this.channelId!, this.id!, reaction); + removeReaction(reaction, userId) { + return removeReaction(this.channelId!, this.id!, reaction, userId); }, }; @@ -255,5 +255,8 @@ export interface DiscordenoMessage /** Remove all reactions */ removeReactionEmoji(reaction: string): ReturnType; /** Remove all reactions */ - removeReaction(reaction: string): ReturnType; + removeReaction( + reaction: string, + userId?: string, + ): ReturnType; } diff --git a/tests/messages/remove_user_reaction.ts b/tests/messages/remove_user_reaction.ts index 0662738b4..4c3859c03 100644 --- a/tests/messages/remove_user_reaction.ts +++ b/tests/messages/remove_user_reaction.ts @@ -1,12 +1,7 @@ -import { - addReaction, - cache, - removeUserReaction, - sendMessage, -} from "../../mod.ts"; -import { defaultTestOptions, tempData } from "../ws/start_bot.ts"; +import { addReaction, cache, removeReaction, sendMessage } from "../../mod.ts"; import { assertEquals, assertExists } from "../deps.ts"; import { delayUntil } from "../util/delay_until.ts"; +import { defaultTestOptions, tempData } from "../ws/start_bot.ts"; async function ifItFailsBlameWolf(type: "getter" | "raw") { const message = await sendMessage(tempData.channelId, "Hello World!"); @@ -32,7 +27,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") { assertEquals(await cache.messages.get(message.id)?.reactions?.length, 1); if (type === "raw") { - await removeUserReaction( + await removeReaction( message.channelId, message.id, "❤", From 9d26a26ae6dbbbde0e64e046f85d299198f31134 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 15:23:11 +0200 Subject: [PATCH 37/78] fix: message structure remove reaction wrong comments --- src/structures/message.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/structures/message.ts b/src/structures/message.ts index add15b8c4..6e8f22bdf 100644 --- a/src/structures/message.ts +++ b/src/structures/message.ts @@ -250,11 +250,11 @@ export interface DiscordenoMessage timeout?: number, reason?: string, ): Promise; - /** Remove all reactions */ + /** Removes all reactions for all emojis on this message */ removeAllReactions(): ReturnType; - /** Remove all reactions */ + /** Removes all reactions for a single emoji on this message */ removeReactionEmoji(reaction: string): ReturnType; - /** Remove all reactions */ + /** Removes a reaction from the given user on this message, defaults to bot */ removeReaction( reaction: string, userId?: string, From ce5f8909730cfcd89cb9f7ecd4a85a3b1ff81c7d Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 15:32:08 +0200 Subject: [PATCH 38/78] change removeUserReaction tests --- tests/messages/remove_reaction.ts | 29 ++++++++++-- tests/messages/remove_user_reaction.ts | 64 -------------------------- tests/mod.ts | 1 - 3 files changed, 25 insertions(+), 69 deletions(-) delete mode 100644 tests/messages/remove_user_reaction.ts diff --git a/tests/messages/remove_reaction.ts b/tests/messages/remove_reaction.ts index 3bf96826c..722631769 100644 --- a/tests/messages/remove_reaction.ts +++ b/tests/messages/remove_reaction.ts @@ -1,9 +1,9 @@ import { addReaction, cache, removeReaction, sendMessage } from "../../mod.ts"; -import { defaultTestOptions, tempData } from "../ws/start_bot.ts"; import { assertEquals, assertExists } from "../deps.ts"; import { delayUntil } from "../util/delay_until.ts"; +import { defaultTestOptions, tempData } from "../ws/start_bot.ts"; -async function ifItFailsBlameWolf(type: "getter" | "raw") { +async function ifItFailsBlameWolf(type: "getter" | "raw", user = false) { const message = await sendMessage(tempData.channelId, "Hello World!"); // Assertions @@ -27,9 +27,14 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") { assertEquals(await cache.messages.get(message.id)?.reactions?.length, 1); if (type === "raw") { - await removeReaction(message.channelId, message.id, "❤"); + await removeReaction( + message.channelId, + message.id, + "❤", + user ? message.author.id : undefined, + ); } else { - await message.removeReaction("❤"); + await message.removeReaction("❤", user ? message.author.id : undefined); } // Delay the execution by 5 seconds to allow MESSAGE_REACTION_REMOVE_ALL event to be processed @@ -57,3 +62,19 @@ Deno.test({ }, ...defaultTestOptions, }); + +Deno.test({ + name: "[message] remove a user reaction", + async fn() { + await ifItFailsBlameWolf("raw", true); + }, + ...defaultTestOptions, +}); + +Deno.test({ + name: "[message] message.removeReaction with user", + async fn() { + await ifItFailsBlameWolf("getter", true); + }, + ...defaultTestOptions, +}); diff --git a/tests/messages/remove_user_reaction.ts b/tests/messages/remove_user_reaction.ts deleted file mode 100644 index 4c3859c03..000000000 --- a/tests/messages/remove_user_reaction.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { addReaction, cache, removeReaction, sendMessage } from "../../mod.ts"; -import { assertEquals, assertExists } from "../deps.ts"; -import { delayUntil } from "../util/delay_until.ts"; -import { defaultTestOptions, tempData } from "../ws/start_bot.ts"; - -async function ifItFailsBlameWolf(type: "getter" | "raw") { - const message = await sendMessage(tempData.channelId, "Hello World!"); - - // Assertions - assertExists(message); - // Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed - await delayUntil(10000, () => cache.messages.has(message.id)); - // Make sure the message was created. - if (!cache.messages.has(message.id)) { - throw new Error("The message seemed to be sent but it was not cached."); - } - - // Add reactions to the message - await addReaction(message.channelId, message.id, "❤"); - // Delay the execution by 5 seconds to allow MESSAGE_REACTION_ALL event to be processed - await delayUntil( - 10000, - () => cache.messages.get(message.id)?.reactions?.length === 1, - ); - - // Be sure that the message has the reactions - assertEquals(await cache.messages.get(message.id)?.reactions?.length, 1); - - if (type === "raw") { - await removeReaction( - message.channelId, - message.id, - "❤", - message.author.id, - ); - } else { - //await message.removeUserReaction("❤", message.author.id); - } - - // Delay the execution by 5 seconds to allow MESSAGE_REACTION_REMOVE_ALL event to be processed - await delayUntil( - 10000, - () => cache.messages.get(message.id)?.reactions === undefined, - ); - - // Check if the reactions has been deleted - assertEquals(await cache.messages.get(message.id)?.reactions, undefined); -} - -Deno.test({ - name: "[message] remove a user reaction", - async fn() { - await ifItFailsBlameWolf("raw"); - }, - ...defaultTestOptions, -}); -/* -Deno.test({ - name: "[message] message.removeReaction()", - async fn() { - await ifItFailsBlameWolf("getter"); - }, - ...defaultTestOptions, -});*/ diff --git a/tests/mod.ts b/tests/mod.ts index e1240004b..34fbc07bd 100644 --- a/tests/mod.ts +++ b/tests/mod.ts @@ -48,7 +48,6 @@ import "./messages/add_reactions.ts"; import "./messages/remove_all_reactions.ts"; import "./messages/remove_reaction.ts"; import "./messages/remove_reaction_emoji.ts"; -import "./messages/remove_user_reaction.ts"; import "./messages/create_message.ts"; import "./messages/delete_message.ts"; import "./messages/delete_messages.ts"; From 2c36797dae537da5f4d0c150bc818c8661af51b9 Mon Sep 17 00:00:00 2001 From: ayntee Date: Fri, 30 Apr 2021 19:37:13 +0400 Subject: [PATCH 39/78] Update src/helpers/guilds/get_widget.ts --- src/helpers/guilds/get_widget.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/guilds/get_widget.ts b/src/helpers/guilds/get_widget.ts index adcc4989d..d1daaec71 100644 --- a/src/helpers/guilds/get_widget.ts +++ b/src/helpers/guilds/get_widget.ts @@ -12,7 +12,7 @@ export async function getWidget(guildId: string, options?: { force: boolean }) { if (!guild?.widgetEnabled) throw new Error(Errors.GUILD_WIDGET_NOT_ENABLED); } - return await rest.runMethod( + return await rest.runMethod( "get", `${endpoints.GUILD_WIDGET(guildId)}.json`, ); From 6b576c75fe2fce224e991f206fd0028ab83187ca Mon Sep 17 00:00:00 2001 From: ayntee Date: Fri, 30 Apr 2021 19:37:57 +0400 Subject: [PATCH 40/78] Update src/helpers/guilds/get_widget.ts --- src/helpers/guilds/get_widget.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/helpers/guilds/get_widget.ts b/src/helpers/guilds/get_widget.ts index d1daaec71..deb28b3d9 100644 --- a/src/helpers/guilds/get_widget.ts +++ b/src/helpers/guilds/get_widget.ts @@ -12,6 +12,7 @@ export async function getWidget(guildId: string, options?: { force: boolean }) { if (!guild?.widgetEnabled) throw new Error(Errors.GUILD_WIDGET_NOT_ENABLED); } + // TODO: add return type return await rest.runMethod( "get", `${endpoints.GUILD_WIDGET(guildId)}.json`, From 5ef685811b3b5ea20343a6c6aec7d79e4efb646c Mon Sep 17 00:00:00 2001 From: ayntee Date: Fri, 30 Apr 2021 19:38:23 +0400 Subject: [PATCH 41/78] Update src/helpers/guilds/get_widget.ts --- src/helpers/guilds/get_widget.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/helpers/guilds/get_widget.ts b/src/helpers/guilds/get_widget.ts index deb28b3d9..bce3f1adc 100644 --- a/src/helpers/guilds/get_widget.ts +++ b/src/helpers/guilds/get_widget.ts @@ -1,6 +1,5 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; -import { DiscordGuildWidget } from "../../types/guilds/guild_widget.ts"; import { Errors } from "../../types/misc/errors.ts"; import { endpoints } from "../../util/constants.ts"; From 5a526c809b18a17c7422fe61434bdd7e7f53620f Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 18:57:44 +0200 Subject: [PATCH 42/78] to an option object --- src/helpers/messages/remove_reaction.ts | 8 ++++---- src/structures/message.ts | 2 +- tests/messages/remove_reaction.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/helpers/messages/remove_reaction.ts b/src/helpers/messages/remove_reaction.ts index 1be275af9..36866d010 100644 --- a/src/helpers/messages/remove_reaction.ts +++ b/src/helpers/messages/remove_reaction.ts @@ -7,9 +7,9 @@ export async function removeReaction( channelId: string, messageId: string, reaction: string, - userId?: string, + options?: { userId?: string }, ) { - if (userId) { + if (options?.userId) { await requireBotChannelPermissions(channelId, ["MANAGE_MESSAGES"]); } @@ -21,12 +21,12 @@ export async function removeReaction( return await rest.runMethod( "delete", - userId + options?.userId ? endpoints.CHANNEL_MESSAGE_REACTION_USER( channelId, messageId, reaction, - userId, + options.userId, ) : endpoints.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction), ); diff --git a/src/structures/message.ts b/src/structures/message.ts index 6e8f22bdf..014e6ea37 100644 --- a/src/structures/message.ts +++ b/src/structures/message.ts @@ -122,7 +122,7 @@ const baseMessage: Partial = { return removeReactionEmoji(this.channelId!, this.id!, reaction); }, removeReaction(reaction, userId) { - return removeReaction(this.channelId!, this.id!, reaction, userId); + return removeReaction(this.channelId!, this.id!, reaction, { userId }); }, }; diff --git a/tests/messages/remove_reaction.ts b/tests/messages/remove_reaction.ts index 722631769..0d02e83ef 100644 --- a/tests/messages/remove_reaction.ts +++ b/tests/messages/remove_reaction.ts @@ -31,7 +31,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw", user = false) { message.channelId, message.id, "❤", - user ? message.author.id : undefined, + user ? { userId: message.author.id } : undefined, ); } else { await message.removeReaction("❤", user ? message.author.id : undefined); From 41a401a32ebcb61f32abab2749ecf62a84c596ee Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 19:17:02 +0200 Subject: [PATCH 43/78] remove Discord* audit log types --- src/types/audit_log/audit_log.ts | 5 +---- src/types/audit_log/audit_log_change.ts | 5 +---- src/types/audit_log/audit_log_change_value.ts | 7 +------ src/types/audit_log/audit_log_entry.ts | 5 +---- src/types/audit_log/get_guild_audit_log.ts | 7 +------ src/types/audit_log/optional_audit_entry_info.ts | 8 +------- 6 files changed, 6 insertions(+), 31 deletions(-) diff --git a/src/types/audit_log/audit_log.ts b/src/types/audit_log/audit_log.ts index bc335f694..41ccff42b 100644 --- a/src/types/audit_log/audit_log.ts +++ b/src/types/audit_log/audit_log.ts @@ -1,9 +1,9 @@ import { Integration } from "../integration/integration.ts"; import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { Webhook } from "../webhooks/webhook.ts"; import { AuditLogEntry } from "./audit_log_entry.ts"; +/** https://discord.com/developers/docs/resources/audit-log#audit-log-object */ export interface AuditLog { /** List of webhooks found in the audit log */ webhooks: Webhook[]; @@ -14,6 +14,3 @@ export interface AuditLog { /** List of partial integration objects */ integrations: Partial[]; } - -/** https://discord.com/developers/docs/resources/audit-log#audit-log-object */ -export type DiscordAuditLog = SnakeCasedPropertiesDeep; diff --git a/src/types/audit_log/audit_log_change.ts b/src/types/audit_log/audit_log_change.ts index 55e3b7a19..7ded886b4 100644 --- a/src/types/audit_log/audit_log_change.ts +++ b/src/types/audit_log/audit_log_change.ts @@ -1,6 +1,6 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { AuditLogChangeValue } from "./audit_log_change_value.ts"; +/** https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-structure */ export interface AuditLogChange { /** New value of the key */ newValue?: AuditLogChangeValue; @@ -9,6 +9,3 @@ export interface AuditLogChange { /** Name of audit log change key */ key: string; } - -/** https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-structure */ -export type DiscordAuditLogChange = SnakeCasedPropertiesDeep; diff --git a/src/types/audit_log/audit_log_change_value.ts b/src/types/audit_log/audit_log_change_value.ts index c1372004c..6a779b2c1 100644 --- a/src/types/audit_log/audit_log_change_value.ts +++ b/src/types/audit_log/audit_log_change_value.ts @@ -1,7 +1,7 @@ import { Overwrite } from "../channels/overwrite.ts"; import { Role } from "../permissions/role.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; +/** https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-structure */ export type AuditLogChangeValue = | { newValue: string; @@ -83,8 +83,3 @@ export type AuditLogChangeValue = oldValue: string | number; key: "type"; }; - -/** https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-structure */ -export type DiscordAuditLogChangeValue = SnakeCasedPropertiesDeep< - AuditLogChangeValue ->; diff --git a/src/types/audit_log/audit_log_entry.ts b/src/types/audit_log/audit_log_entry.ts index 9b804d1f1..ee85ed25d 100644 --- a/src/types/audit_log/audit_log_entry.ts +++ b/src/types/audit_log/audit_log_entry.ts @@ -1,8 +1,8 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { AuditLogChange } from "./audit_log_change.ts"; import { DiscordAuditLogEvents } from "./audit_log_events.ts"; import { OptionalAuditEntryInfo } from "./optional_audit_entry_info.ts"; +/** https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-entry-structure */ export interface AuditLogEntry { /** id of the affected entity (webhook, user, role, etc.) */ targetId: string | null; @@ -19,6 +19,3 @@ export interface AuditLogEntry { /** The reason for the change (0-512 characters) */ reason?: string; } - -/** https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-entry-structure */ -export type DiscordAuditLogEntry = SnakeCasedPropertiesDeep; diff --git a/src/types/audit_log/get_guild_audit_log.ts b/src/types/audit_log/get_guild_audit_log.ts index ef2fab575..6d5e853c6 100644 --- a/src/types/audit_log/get_guild_audit_log.ts +++ b/src/types/audit_log/get_guild_audit_log.ts @@ -1,6 +1,6 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { DiscordAuditLogEvents } from "./audit_log_events.ts"; +/** https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log-query-string-parameters */ export interface GetGuildAuditLog { /** Filter the log for actions made by a user */ userId: string; @@ -11,8 +11,3 @@ export interface GetGuildAuditLog { /** How many entries are returned (default 50, minimum 1, maximum 100) */ limit: number; } - -/** https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log-query-string-parameters */ -export type DiscordGetGuildAuditLog = SnakeCasedPropertiesDeep< - GetGuildAuditLog ->; diff --git a/src/types/audit_log/optional_audit_entry_info.ts b/src/types/audit_log/optional_audit_entry_info.ts index ec89b1a6d..cfd9057ca 100644 --- a/src/types/audit_log/optional_audit_entry_info.ts +++ b/src/types/audit_log/optional_audit_entry_info.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info */ export interface OptionalAuditEntryInfo { /** Number of days after which inactive members were kicked */ deleteMemberDays: string; @@ -18,8 +17,3 @@ export interface OptionalAuditEntryInfo { /** Name of the role if type is "0" (not present if type is "1") */ roleName: string; } - -/** https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info */ -export type DiscordOptionalAuditEntryInfo = SnakeCasedPropertiesDeep< - OptionalAuditEntryInfo ->; From b1564bc57c638ac25d17bfb6c892ca1edbb37b69 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 19:19:04 +0200 Subject: [PATCH 44/78] remove Discord* for channel types --- src/types/channels/channel.ts | 10 ++-------- src/types/channels/channel_mention.ts | 6 +----- src/types/channels/channel_pins_update.ts | 8 +------- src/types/channels/followed_channel.ts | 6 +----- src/types/channels/modify_channel.ts | 2 ++ src/types/channels/overwrite.ts | 2 ++ 6 files changed, 9 insertions(+), 25 deletions(-) diff --git a/src/types/channels/channel.ts b/src/types/channels/channel.ts index 9361bbeb3..e71377410 100644 --- a/src/types/channels/channel.ts +++ b/src/types/channels/channel.ts @@ -1,9 +1,9 @@ import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { DiscordChannelTypes } from "./channel_types.ts"; -import { DiscordOverwrite, Overwrite } from "./overwrite.ts"; +import { Overwrite } from "./overwrite.ts"; import { DiscordVideoQualityModes } from "./video_quality_modes.ts"; +/** https://discord.com/developers/docs/resources/channel#channel-object */ export interface Channel { /** The id of the channel */ id: string; @@ -46,9 +46,3 @@ export interface Channel { /** The camera video quality mode of the voice channel, 1 when not present */ videoQualityMode?: DiscordVideoQualityModes; } - -/** https://discord.com/developers/docs/resources/channel#channel-object */ -export interface DiscordChannel - extends SnakeCasedPropertiesDeep> { - permission_overwrites?: DiscordOverwrite[]; -} diff --git a/src/types/channels/channel_mention.ts b/src/types/channels/channel_mention.ts index f6ec4def0..9acc8bf91 100644 --- a/src/types/channels/channel_mention.ts +++ b/src/types/channels/channel_mention.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/resources/channel#channel-mention-object */ export interface ChannelMention { /** id of the channel */ id: string; @@ -10,6 +9,3 @@ export interface ChannelMention { /** The name of the channel */ name: string; } - -/** https://discord.com/developers/docs/resources/channel#channel-mention-object */ -export type DiscordChannelMention = SnakeCasedPropertiesDeep; diff --git a/src/types/channels/channel_pins_update.ts b/src/types/channels/channel_pins_update.ts index 65de83815..5483f155d 100644 --- a/src/types/channels/channel_pins_update.ts +++ b/src/types/channels/channel_pins_update.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/topics/gateway#channel-pins-update */ export interface ChannelPinsUpdate { /** The id of the guild */ guildId?: string; @@ -8,8 +7,3 @@ export interface ChannelPinsUpdate { /** The time at which the most recent pinned message was pinned */ lastPinTimestamp?: string | null; } - -/** https://discord.com/developers/docs/topics/gateway#channel-pins-update */ -export type DiscordChannelPinsUpdate = SnakeCasedPropertiesDeep< - ChannelPinsUpdate ->; diff --git a/src/types/channels/followed_channel.ts b/src/types/channels/followed_channel.ts index c293c5316..2b86ced62 100644 --- a/src/types/channels/followed_channel.ts +++ b/src/types/channels/followed_channel.ts @@ -1,11 +1,7 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/resources/channel#followed-channel-object */ export interface FollowedChannel { /** Source message id */ channelId: string; /** Created target webhook id */ webhookId: string; } - -/** https://discord.com/developers/docs/resources/channel#followed-channel-object */ -export type DiscordFollowedChannel = SnakeCasedPropertiesDeep; diff --git a/src/types/channels/modify_channel.ts b/src/types/channels/modify_channel.ts index fcb9ecaff..b6defe24b 100644 --- a/src/types/channels/modify_channel.ts +++ b/src/types/channels/modify_channel.ts @@ -37,3 +37,5 @@ export interface DiscordModifyChannel extends > { permission_overwrites?: DiscordOverwrite[]; } + +//TODO: check this diff --git a/src/types/channels/overwrite.ts b/src/types/channels/overwrite.ts index 3e3e5f21d..533246e75 100644 --- a/src/types/channels/overwrite.ts +++ b/src/types/channels/overwrite.ts @@ -17,3 +17,5 @@ export interface DiscordOverwrite extends Omit { allow: string; deny: string; } + +// TODO: check this From 20cd0e004c8d6d1c9e87b0318e506b704499bcd0 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 19:21:07 +0200 Subject: [PATCH 45/78] remove Discord* types from discovery --- src/types/discovery/add_guild_discovery_subcategory.ts | 6 ------ src/types/discovery/discovery_category.ts | 7 +------ src/types/discovery/discovery_metadata.ts | 8 +------- src/types/discovery/discovery_name.ts | 3 +-- src/types/discovery/modify_guild_discovery_metadata.ts | 7 +------ .../discovery/validate_discovery_search_term_params.ts | 5 +---- 6 files changed, 5 insertions(+), 31 deletions(-) diff --git a/src/types/discovery/add_guild_discovery_subcategory.ts b/src/types/discovery/add_guild_discovery_subcategory.ts index af38cb9fc..9b1f580a7 100644 --- a/src/types/discovery/add_guild_discovery_subcategory.ts +++ b/src/types/discovery/add_guild_discovery_subcategory.ts @@ -1,12 +1,6 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - export interface AddGuildDiscoverySubcategory { /** The guild Id of the subcategory was added to */ guildId: string; /** The Id of the subcategory added */ categoryId: number; } - -export type DiscordAddGuildDiscoverySubcategory = SnakeCasedPropertiesDeep< - AddGuildDiscoverySubcategory ->; diff --git a/src/types/discovery/discovery_category.ts b/src/types/discovery/discovery_category.ts index 64701227b..8b82e25cc 100644 --- a/src/types/discovery/discovery_category.ts +++ b/src/types/discovery/discovery_category.ts @@ -1,6 +1,6 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { DiscoveryName } from "./discovery_name.ts"; +//TODO: add docs link export interface DiscoveryCategory { /** Numeric id of the category */ id: number; @@ -9,8 +9,3 @@ export interface DiscoveryCategory { /** Whether this category can be set as a guild's primary category */ isPrimary: boolean; } - -//TODO: add docs link -export type DiscordDiscoveryCategory = SnakeCasedPropertiesDeep< - DiscoveryCategory ->; diff --git a/src/types/discovery/discovery_metadata.ts b/src/types/discovery/discovery_metadata.ts index 117bf3869..3d8571761 100644 --- a/src/types/discovery/discovery_metadata.ts +++ b/src/types/discovery/discovery_metadata.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +// TODO: add docs link export interface DiscoveryMetadata { /** The guild Id */ guildId: string; @@ -16,8 +15,3 @@ export interface DiscoveryMetadata { /** Ids of up to 5 discovery subcategories set for this guild */ categoryIds: number[]; } - -// TODO: add docs link -export type DiscordDiscoveryMetadata = SnakeCasedPropertiesDeep< - DiscoveryMetadata ->; diff --git a/src/types/discovery/discovery_name.ts b/src/types/discovery/discovery_name.ts index d2e9479d6..58199327f 100644 --- a/src/types/discovery/discovery_name.ts +++ b/src/types/discovery/discovery_name.ts @@ -1,8 +1,7 @@ +//TODO: add docs link export interface DiscoveryName { /** The name in English */ default: string; /** The name in other languages */ localizations?: Record; } - -export type DiscordDiscoveryName = DiscoveryName; diff --git a/src/types/discovery/modify_guild_discovery_metadata.ts b/src/types/discovery/modify_guild_discovery_metadata.ts index 1a91138a1..e517bfdea 100644 --- a/src/types/discovery/modify_guild_discovery_metadata.ts +++ b/src/types/discovery/modify_guild_discovery_metadata.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +// TODO: add docs link export interface ModifyGuildDiscoveryMetadata { /** The id of the primary discovery category. Default: 0 */ primaryCategoryId?: number | null; @@ -8,7 +7,3 @@ export interface ModifyGuildDiscoveryMetadata { /** Whether guild info is shown when custom emojis are clicked. Default: true */ emojiDiscoverabilityEnabled?: boolean | null; } - -export type DiscordModifyGuildDiscoveryMetadata = SnakeCasedPropertiesDeep< - ModifyGuildDiscoveryMetadata ->; diff --git a/src/types/discovery/validate_discovery_search_term_params.ts b/src/types/discovery/validate_discovery_search_term_params.ts index 18d3e409b..8ad447206 100644 --- a/src/types/discovery/validate_discovery_search_term_params.ts +++ b/src/types/discovery/validate_discovery_search_term_params.ts @@ -1,8 +1,5 @@ +// TODO: add docs link export interface ValidateDiscoverySearchTermParams { /** The search term to check */ term: string; } - -// TODO: add docs link -export type DiscordValidateDiscoverySearchTermParams = - ValidateDiscoverySearchTermParams; From 16666d80d91a8ea41c48d8e0e783e211405479d8 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 19:22:15 +0200 Subject: [PATCH 46/78] remove Discord* types from embeds --- src/types/embeds/embed.ts | 4 +--- src/types/embeds/embed_author.ts | 6 +----- src/types/embeds/embed_field.ts | 4 +--- src/types/embeds/embed_footer.ts | 6 +----- src/types/embeds/embed_image.ts | 6 +----- src/types/embeds/embed_provider.ts | 4 +--- src/types/embeds/embed_thumbnail.ts | 6 +----- src/types/embeds/embed_video.ts | 6 +----- 8 files changed, 8 insertions(+), 34 deletions(-) diff --git a/src/types/embeds/embed.ts b/src/types/embeds/embed.ts index 5f63bf982..9b8a27970 100644 --- a/src/types/embeds/embed.ts +++ b/src/types/embeds/embed.ts @@ -7,6 +7,7 @@ import { EmbedThumbnail } from "./embed_thumbnail.ts"; import { DiscordEmbedTypes } from "./embed_types.ts"; import { EmbedVideo } from "./embed_video.ts"; +/** https://discord.com/developers/docs/resources/channel#embed-object */ export interface Embed { /** Title of embed */ title?: string; @@ -35,6 +36,3 @@ export interface Embed { /** Fields information */ fields?: EmbedField[]; } - -/** https://discord.com/developers/docs/resources/channel#embed-object */ -export type DiscordEmbed = Embed; diff --git a/src/types/embeds/embed_author.ts b/src/types/embeds/embed_author.ts index c6ff2bf25..4ec07a7e9 100644 --- a/src/types/embeds/embed_author.ts +++ b/src/types/embeds/embed_author.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure */ export interface EmbedAuthor { /** Name of author */ name?: string; @@ -10,6 +9,3 @@ export interface EmbedAuthor { /** A proxied url of author icon */ proxyIconUrl?: string; } - -/** https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure */ -export type DiscordEmbedAuthor = SnakeCasedPropertiesDeep; diff --git a/src/types/embeds/embed_field.ts b/src/types/embeds/embed_field.ts index 02ee5ee23..6d009d4d6 100644 --- a/src/types/embeds/embed_field.ts +++ b/src/types/embeds/embed_field.ts @@ -1,3 +1,4 @@ +/** https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure */ export interface EmbedField { /** Name of the field */ name: string; @@ -6,6 +7,3 @@ export interface EmbedField { /** Whether or not this field should display inline */ inline?: boolean; } - -/** https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure */ -export type DiscordEmbedField = EmbedField; diff --git a/src/types/embeds/embed_footer.ts b/src/types/embeds/embed_footer.ts index 9ccfe268d..a90aa10e1 100644 --- a/src/types/embeds/embed_footer.ts +++ b/src/types/embeds/embed_footer.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure */ export interface EmbedFooter { /** Footer text */ text: string; @@ -8,6 +7,3 @@ export interface EmbedFooter { /** A proxied url of footer icon */ proxyIconUrl?: string; } - -/** https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure */ -export type DiscordEmbedFooter = SnakeCasedPropertiesDeep; diff --git a/src/types/embeds/embed_image.ts b/src/types/embeds/embed_image.ts index 2255c47bc..0b010c56a 100644 --- a/src/types/embeds/embed_image.ts +++ b/src/types/embeds/embed_image.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure */ export interface EmbedImage { /** Source url of image (only supports http(s) and attachments) */ url?: string; @@ -10,6 +9,3 @@ export interface EmbedImage { /** Width of image */ width?: number; } - -/** https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure */ -export type DiscordEmbedImage = SnakeCasedPropertiesDeep; diff --git a/src/types/embeds/embed_provider.ts b/src/types/embeds/embed_provider.ts index 4af0b9e18..afac6dff5 100644 --- a/src/types/embeds/embed_provider.ts +++ b/src/types/embeds/embed_provider.ts @@ -1,9 +1,7 @@ +export type DiscordEmbedProvider = EmbedProvider; export interface EmbedProvider { /** Name of provider */ name?: string; /** Url of provider */ url?: string; } - -/** https://discord.com/developers/docs/resources/channel#embed-object-embed-provider-structure */ -export type DiscordEmbedProvider = EmbedProvider; diff --git a/src/types/embeds/embed_thumbnail.ts b/src/types/embeds/embed_thumbnail.ts index ee715a4f4..824c6f085 100644 --- a/src/types/embeds/embed_thumbnail.ts +++ b/src/types/embeds/embed_thumbnail.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure */ export interface EmbedThumbnail { /** Source url of thumbnail (only supports http(s) and attachments) */ url?: string; @@ -10,6 +9,3 @@ export interface EmbedThumbnail { /** Width of thumbnail */ width?: number; } - -/** https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure */ -export type DiscordEmbedThumbnail = SnakeCasedPropertiesDeep; diff --git a/src/types/embeds/embed_video.ts b/src/types/embeds/embed_video.ts index 468c494d0..c2d8c63d2 100644 --- a/src/types/embeds/embed_video.ts +++ b/src/types/embeds/embed_video.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure */ export interface EmbedVideo { /** Source url of video */ url?: string; @@ -10,6 +9,3 @@ export interface EmbedVideo { /** Width of video */ width?: number; } - -/** https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure */ -export type DiscordEmbedVideo = SnakeCasedPropertiesDeep; From 6fc14ff2181b27f4782df5f790d57cff491da03a Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 19:22:45 +0200 Subject: [PATCH 47/78] remove Discord* types from emojis --- src/types/emojis/create_guild_emoji.ts | 4 +--- src/types/emojis/emoji.ts | 5 +---- src/types/emojis/guild_emojis_update.ts | 7 +------ src/types/emojis/modify_guild_emoji.ts | 4 +--- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/types/emojis/create_guild_emoji.ts b/src/types/emojis/create_guild_emoji.ts index 3424e9af9..98959d4c8 100644 --- a/src/types/emojis/create_guild_emoji.ts +++ b/src/types/emojis/create_guild_emoji.ts @@ -1,3 +1,4 @@ +/** https://discord.com/developers/docs/resources/emoji#create-guild-emoji */ export interface CreateGuildEmoji { /** Name of the emoji */ name: string; @@ -6,6 +7,3 @@ export interface CreateGuildEmoji { /** Roles allowed to use this emoji */ roles: string[]; } - -/** https://discord.com/developers/docs/resources/emoji#create-guild-emoji */ -export type DiscordCreateGuildEmojis = CreateGuildEmoji; diff --git a/src/types/emojis/emoji.ts b/src/types/emojis/emoji.ts index abeb3f368..5609db102 100644 --- a/src/types/emojis/emoji.ts +++ b/src/types/emojis/emoji.ts @@ -1,6 +1,6 @@ import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; +/** https://discord.com/developers/docs/resources/emoji#emoji-object-emoji-structure */ export interface Emoji { /** Emoji id */ id: string | null; @@ -19,6 +19,3 @@ export interface Emoji { /** Whether this emoji can be used, may be false due to loss of Server Boosts */ available?: boolean; } - -/** https://discord.com/developers/docs/resources/emoji#emoji-object-emoji-structure */ -export type DiscordEmoji = SnakeCasedPropertiesDeep; diff --git a/src/types/emojis/guild_emojis_update.ts b/src/types/emojis/guild_emojis_update.ts index d7990f61b..65ede6d26 100644 --- a/src/types/emojis/guild_emojis_update.ts +++ b/src/types/emojis/guild_emojis_update.ts @@ -1,14 +1,9 @@ import { Emoji } from "../emojis/emoji.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; +/** https://discord.com/developers/docs/topics/gateway#guild-emojis-update */ export interface GuildEmojisUpdate { /** id of the guild */ guildId: string; /** Array of emojis */ emojis: Emoji[]; } - -/** https://discord.com/developers/docs/topics/gateway#guild-emojis-update */ -export type DiscordGuildEmojisUpdate = SnakeCasedPropertiesDeep< - GuildEmojisUpdate ->; diff --git a/src/types/emojis/modify_guild_emoji.ts b/src/types/emojis/modify_guild_emoji.ts index 319280c41..5da4bc0da 100644 --- a/src/types/emojis/modify_guild_emoji.ts +++ b/src/types/emojis/modify_guild_emoji.ts @@ -1,9 +1,7 @@ +/** https://discord.com/developers/docs/resources/emoji#modify-guild-emoji */ export interface ModifyGuildEmoji { /** Name of the emoji */ name?: string; /** Roles allowed to use this emoji */ roles?: string[] | null; } - -/** https://discord.com/developers/docs/resources/emoji#modify-guild-emoji */ -export type DiscordModifyGuildEmoji = ModifyGuildEmoji; From aa27e922347e3064fe15c7f9e017c20ab27865e2 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 19:26:41 +0200 Subject: [PATCH 48/78] remove Discord* gateway types --- src/types/gateway/gateway_url_params.ts | 4 +--- src/types/gateway/get_gateway_bot.ts | 5 +---- src/types/gateway/identify.ts | 5 +---- src/types/gateway/ready.ts | 2 +- src/types/gateway/resume.ts | 4 +--- src/types/gateway/session_start_limit.ts | 8 +------- src/types/gateway/status_update.ts | 5 +---- 7 files changed, 7 insertions(+), 26 deletions(-) diff --git a/src/types/gateway/gateway_url_params.ts b/src/types/gateway/gateway_url_params.ts index 67be76115..7beb1971a 100644 --- a/src/types/gateway/gateway_url_params.ts +++ b/src/types/gateway/gateway_url_params.ts @@ -1,3 +1,4 @@ +/** https://discord.com/developers/docs/topics/gateway#connecting-gateway-url-params */ export interface GatewayURLParams { /** Gateway version to use */ v: string; @@ -6,6 +7,3 @@ export interface GatewayURLParams { /** The (optional) compression of gateway packets */ compress?: string; } - -/** https://discord.com/developers/docs/topics/gateway#connecting-gateway-url-params */ -export type DiscordGatewayURLParams = GatewayURLParams; diff --git a/src/types/gateway/get_gateway_bot.ts b/src/types/gateway/get_gateway_bot.ts index d7e5954e6..c1ed12069 100644 --- a/src/types/gateway/get_gateway_bot.ts +++ b/src/types/gateway/get_gateway_bot.ts @@ -1,6 +1,6 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { SessionStartLimit } from "./session_start_limit.ts"; +/** https://discord.com/developers/docs/topics/gateway#get-gateway-bot */ export interface GetGatewayBot { /** The WSS URL that can be used for connecting to the gateway */ url: string; @@ -9,6 +9,3 @@ export interface GetGatewayBot { /** Information on the current session start limit */ sessionStartLimit: SessionStartLimit; } - -/** https://discord.com/developers/docs/topics/gateway#get-gateway-bot */ -export type DiscordGetGatewayBot = SnakeCasedPropertiesDeep; diff --git a/src/types/gateway/identify.ts b/src/types/gateway/identify.ts index 4eb45dbdf..adf566206 100644 --- a/src/types/gateway/identify.ts +++ b/src/types/gateway/identify.ts @@ -1,7 +1,7 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { IdentifyConnectionProperties } from "./identify_connection_properties.ts"; import { StatusUpdate } from "./status_update.ts"; +/** https://discord.com/developers/docs/topics/gateway#identify */ export interface Identify { /** Authentication token */ token: string; @@ -18,6 +18,3 @@ export interface Identify { /** The Gateway Intents you wish to receive */ intents: number; } - -/** https://discord.com/developers/docs/topics/gateway#identify */ -export type DiscordIdentify = SnakeCasedPropertiesDeep; diff --git a/src/types/gateway/ready.ts b/src/types/gateway/ready.ts index 258ff3429..e5aafb694 100644 --- a/src/types/gateway/ready.ts +++ b/src/types/gateway/ready.ts @@ -3,6 +3,7 @@ import { Application } from "../oauth2/application.ts"; import { User } from "../users/user.ts"; import { SnakeCasedPropertiesDeep } from "../util.ts"; +/** https://discord.com/developers/docs/topics/gateway#ready */ export interface Ready { /** Gateway version */ v: number; @@ -20,5 +21,4 @@ export interface Ready { application: Partial & Pick; } -/** https://discord.com/developers/docs/topics/gateway#ready */ export type DiscordReady = SnakeCasedPropertiesDeep; diff --git a/src/types/gateway/resume.ts b/src/types/gateway/resume.ts index bd6b626c3..8d04d0aa5 100644 --- a/src/types/gateway/resume.ts +++ b/src/types/gateway/resume.ts @@ -1,3 +1,4 @@ +/** https://discord.com/developers/docs/topics/gateway#resume */ export interface Resume { /** Session token */ token: string; @@ -6,6 +7,3 @@ export interface Resume { /** Last sequence number received */ seq: number; } - -/** https://discord.com/developers/docs/topics/gateway#resume */ -export type DiscordResume = Resume; diff --git a/src/types/gateway/session_start_limit.ts b/src/types/gateway/session_start_limit.ts index 01bbac11b..c45bb8767 100644 --- a/src/types/gateway/session_start_limit.ts +++ b/src/types/gateway/session_start_limit.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/topics/gateway#session-start-limit-object */ export interface SessionStartLimit { /** The total number of session starts the current user is allowed */ total: number; @@ -10,8 +9,3 @@ export interface SessionStartLimit { /** The number of identify requests allowed per 5 seconds */ maxConcurrency: number; } - -/** https://discord.com/developers/docs/topics/gateway#session-start-limit-object */ -export type DiscordSessionStartLimit = SnakeCasedPropertiesDeep< - SessionStartLimit ->; diff --git a/src/types/gateway/status_update.ts b/src/types/gateway/status_update.ts index 3f034ee81..27f65b9ca 100644 --- a/src/types/gateway/status_update.ts +++ b/src/types/gateway/status_update.ts @@ -1,7 +1,7 @@ import { Activity } from "../misc/activity.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { DiscordStatusTypes } from "./status_types.ts"; +/** https://discord.com/developers/docs/topics/gateway#update-status */ export interface StatusUpdate { /** Unix time (in milliseconds) of when the client went idle, or null if the client is not idle */ since: number | null; @@ -12,6 +12,3 @@ export interface StatusUpdate { /** Whether or not the client is afk */ afk: boolean; } - -/** https://discord.com/developers/docs/topics/gateway#update-status */ -export type DiscordStatusUpdate = SnakeCasedPropertiesDeep; From fe81cc1ea32c9f548482b2f3bf132de1fb5b4d97 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 19:34:16 +0200 Subject: [PATCH 49/78] remove Discord* types for guilds --- src/types/guilds/ban.ts | 5 +---- src/types/guilds/begin_guild_prune.ts | 6 +----- src/types/guilds/create_guild.ts | 5 +---- src/types/guilds/create_guild_ban.ts | 6 +----- src/types/guilds/create_guild_channel.ts | 1 + src/types/guilds/create_guild_role.ts | 1 + src/types/guilds/get_guild.ts | 6 +----- src/types/guilds/get_guild_prune_count.ts | 8 +------- src/types/guilds/get_guild_widget_image.ts | 4 +--- src/types/guilds/guild.ts | 5 +---- src/types/guilds/guild_ban_add_remove.ts | 7 +------ src/types/guilds/guild_ban_remove.ts | 5 +---- src/types/guilds/guild_features.ts | 3 ++- src/types/guilds/guild_member.ts | 10 ++-------- src/types/guilds/guild_preview.ts | 5 +---- src/types/guilds/guild_role_create.ts | 5 +---- src/types/guilds/guild_role_delete.ts | 6 +----- src/types/guilds/guild_role_update.ts | 5 +---- src/types/guilds/guild_widget.ts | 6 +----- src/types/guilds/list_guild_members.ts | 4 +--- src/types/guilds/modify_current_user_nick.ts | 4 +--- src/types/guilds/modify_guild.ts | 5 +---- src/types/guilds/modify_guild_channel_position.ts | 4 +--- src/types/guilds/modify_guild_member.ts | 8 +------- src/types/guilds/modify_guild_role.ts | 2 ++ src/types/guilds/modify_guild_role_positions.ts | 4 +--- src/types/guilds/modify_guild_welcome_screen.ts | 7 +------ src/types/guilds/request_guild_members.ts | 8 +------- src/types/guilds/unavailable_guild.ts | 7 +------ src/types/guilds/update_others_voice_state.ts | 8 +------- src/types/guilds/update_self_voice_state.ts | 8 +------- src/types/guilds/welcome_screen.ts | 5 +---- src/types/guilds/welcome_screen_channel.ts | 8 +------- 33 files changed, 36 insertions(+), 145 deletions(-) diff --git a/src/types/guilds/ban.ts b/src/types/guilds/ban.ts index 5fc4c5842..aad8022ec 100644 --- a/src/types/guilds/ban.ts +++ b/src/types/guilds/ban.ts @@ -1,12 +1,9 @@ import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; +/** https://discord.com/developers/docs/resources/guild#ban-object */ export interface Ban { /** The reason for the ban */ reason: string | null; /** The banned user */ user: User; } - -/** https://discord.com/developers/docs/resources/guild#ban-object */ -export type DiscordBan = SnakeCasedPropertiesDeep; diff --git a/src/types/guilds/begin_guild_prune.ts b/src/types/guilds/begin_guild_prune.ts index f93bf63dc..cb6c2b677 100644 --- a/src/types/guilds/begin_guild_prune.ts +++ b/src/types/guilds/begin_guild_prune.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/resources/guild#begin-guild-prune */ export interface BeginGuildPrune { /** Number of days to prune (1 or more), default: 7 */ days?: number; @@ -8,6 +7,3 @@ export interface BeginGuildPrune { /** Role(s) ro include, default: none */ includeRoles?: string[]; } - -/** https://discord.com/developers/docs/resources/guild#begin-guild-prune */ -export type DiscordBeginGuildPrune = SnakeCasedPropertiesDeep; diff --git a/src/types/guilds/create_guild.ts b/src/types/guilds/create_guild.ts index d8d50adcb..f0978015d 100644 --- a/src/types/guilds/create_guild.ts +++ b/src/types/guilds/create_guild.ts @@ -1,11 +1,11 @@ import { Channel } from "../channels/channel.ts"; import { Role } from "../permissions/role.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { DiscordDefaultMessageNotificationLevels } from "./default_message_notification_levels.ts"; import { DiscordExplicitContentFilterLevels } from "./explicit_content_filter_levels.ts"; import { DiscordSystemChannelFlags } from "./system_channel_flags.ts"; import { DiscordVerificationLevels } from "./verification_levels.ts"; +/** https://discord.com/developers/docs/resources/guild#create-guild */ export interface CreateGuild { /** Name of the guild (2-100 characters) */ name: string; @@ -32,6 +32,3 @@ export interface CreateGuild { /** System channel flags */ systemChannelFlags?: DiscordSystemChannelFlags; } - -/** https://discord.com/developers/docs/resources/guild#create-guild */ -export type DiscordCreateGuild = SnakeCasedPropertiesDeep; diff --git a/src/types/guilds/create_guild_ban.ts b/src/types/guilds/create_guild_ban.ts index beb2fb837..f5fd9d63d 100644 --- a/src/types/guilds/create_guild_ban.ts +++ b/src/types/guilds/create_guild_ban.ts @@ -1,11 +1,7 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/resources/guild#create-guild-ban */ export interface CreateGuildBan { /** Number of days to delete messages for (0-7) */ deleteMessageDays?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7; /** Reason for the ban */ reason?: string; } - -/** https://discord.com/developers/docs/resources/guild#create-guild-ban */ -export type DiscordCreateGuildBan = SnakeCasedPropertiesDeep; diff --git a/src/types/guilds/create_guild_channel.ts b/src/types/guilds/create_guild_channel.ts index 82ff9d9f8..d6fe506d0 100644 --- a/src/types/guilds/create_guild_channel.ts +++ b/src/types/guilds/create_guild_channel.ts @@ -32,3 +32,4 @@ export interface DiscordCreateGuildChannel extends > { permission_overwrites: DiscordOverwrite[]; } +// TODO: check this diff --git a/src/types/guilds/create_guild_role.ts b/src/types/guilds/create_guild_role.ts index d1be99b30..2183a0f7d 100644 --- a/src/types/guilds/create_guild_role.ts +++ b/src/types/guilds/create_guild_role.ts @@ -18,3 +18,4 @@ export interface DiscordCreateGuildRole extends Omit { permissions?: string; } +// TODO: check this diff --git a/src/types/guilds/get_guild.ts b/src/types/guilds/get_guild.ts index b56abc303..b6845f3c5 100644 --- a/src/types/guilds/get_guild.ts +++ b/src/types/guilds/get_guild.ts @@ -1,9 +1,5 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/resources/guild#get-guild */ export interface GetGuildQuery { /** When true, will return approximate member and presence counts for the guild */ withCounts?: boolean; } - -/** https://discord.com/developers/docs/resources/guild#get-guild */ -export type DiscordGetGuildQuery = SnakeCasedPropertiesDeep; diff --git a/src/types/guilds/get_guild_prune_count.ts b/src/types/guilds/get_guild_prune_count.ts index f0eb6636a..cd80efa1d 100644 --- a/src/types/guilds/get_guild_prune_count.ts +++ b/src/types/guilds/get_guild_prune_count.ts @@ -1,13 +1,7 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/resources/guild#get-guild-prune-count */ export interface GetGuildPruneCountQuery { /** Number of days to count prune for (1 or more), default: 7 */ days?: number; /** Role(s) to include, default: none */ includeRoles: string | string[]; } - -/** https://discord.com/developers/docs/resources/guild#get-guild-prune-count */ -export type DiscordGetGuildPruneCountQuery = SnakeCasedPropertiesDeep< - GetGuildPruneCountQuery ->; diff --git a/src/types/guilds/get_guild_widget_image.ts b/src/types/guilds/get_guild_widget_image.ts index f6219ee1a..ca759e27c 100644 --- a/src/types/guilds/get_guild_widget_image.ts +++ b/src/types/guilds/get_guild_widget_image.ts @@ -1,9 +1,7 @@ import { DiscordGetGuildWidgetImageStyleOptions } from "./get_guild_widget_image_style_options.ts"; +/** https://discord.com/developers/docs/resources/guild#get-guild-widget-image-query-string-params */ export interface GetGuildWidgetImageQuery { /** Style of the widget returned, default: shield */ style?: DiscordGetGuildWidgetImageStyleOptions; } - -/** https://discord.com/developers/docs/resources/guild#get-guild-widget-image-query-string-params */ -export type DiscordGetGuildWidgetImage = GetGuildWidgetImageQuery; diff --git a/src/types/guilds/guild.ts b/src/types/guilds/guild.ts index c346f9f22..52f879a36 100644 --- a/src/types/guilds/guild.ts +++ b/src/types/guilds/guild.ts @@ -2,7 +2,6 @@ import { Channel } from "../channels/channel.ts"; import { Emoji } from "../emojis/emoji.ts"; import { PresenceUpdate } from "../misc/presence_update.ts"; import { Role } from "../permissions/role.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { VoiceState } from "../voice/voice_state.ts"; import { DiscordDefaultMessageNotificationLevels } from "./default_message_notification_levels.ts"; import { DiscordExplicitContentFilterLevels } from "./explicit_content_filter_levels.ts"; @@ -14,6 +13,7 @@ import { DiscordSystemChannelFlags } from "./system_channel_flags.ts"; import { DiscordVerificationLevels } from "./verification_levels.ts"; import { WelcomeScreen } from "./welcome_screen.ts"; +/** https://discord.com/developers/docs/resources/guild#guild-object */ export interface Guild { /** Guild id */ id: string; @@ -108,6 +108,3 @@ export interface Guild { /** The welcome screen of a Community guild, shown to new members, returned when in the invite object */ welcomeScreen?: WelcomeScreen; } - -/** https://discord.com/developers/docs/resources/guild#guild-object */ -export type DiscordGuild = SnakeCasedPropertiesDeep; diff --git a/src/types/guilds/guild_ban_add_remove.ts b/src/types/guilds/guild_ban_add_remove.ts index 988368946..2f1426a75 100644 --- a/src/types/guilds/guild_ban_add_remove.ts +++ b/src/types/guilds/guild_ban_add_remove.ts @@ -1,14 +1,9 @@ import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; +/** https://discord.com/developers/docs/topics/gateway#guild-ban-add */ export interface GuildBanAddRemove { /** id of the guild */ guildId: string; /** The banned user */ user: User; } - -/** https://discord.com/developers/docs/topics/gateway#guild-ban-add */ -export type DiscordGuildBanAddRemove = SnakeCasedPropertiesDeep< - GuildBanAddRemove ->; diff --git a/src/types/guilds/guild_ban_remove.ts b/src/types/guilds/guild_ban_remove.ts index c88a16207..62f3fdef2 100644 --- a/src/types/guilds/guild_ban_remove.ts +++ b/src/types/guilds/guild_ban_remove.ts @@ -1,12 +1,9 @@ import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; +/** https://discord.com/developers/docs/topics/gateway#guild-ban-remove */ export interface GuildBanRemove { /** id of the guild */ guildId: string; /** The unbanned user */ user: User; } - -/** https://discord.com/developers/docs/topics/gateway#guild-ban-remove */ -export type DiscordGuildBanRemove = SnakeCasedPropertiesDeep; diff --git a/src/types/guilds/guild_features.ts b/src/types/guilds/guild_features.ts index 3ba9fa4cc..259afe4c9 100644 --- a/src/types/guilds/guild_features.ts +++ b/src/types/guilds/guild_features.ts @@ -17,7 +17,8 @@ export enum DiscordGuildFeatures { /** Guild has access to create news channels */ NEWS = "NEWS", /** Guild is able to be discovered in the directory */ - DISCOVERABLE = "DISCOVERABLE", /** guild cannot be discoverable */ + DISCOVERABLE = "DISCOVERABLE", + /** guild cannot be discoverable */ DISCOVERABLE_DISABLED = "DISCOVERABLE_DISABLED", /** Guild is able to be featured in the directory */ FEATURABLE = "FEATURABLE", diff --git a/src/types/guilds/guild_member.ts b/src/types/guilds/guild_member.ts index 86c4a2053..cc13d095e 100644 --- a/src/types/guilds/guild_member.ts +++ b/src/types/guilds/guild_member.ts @@ -1,6 +1,6 @@ import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; +/** https://discord.com/developers/docs/resources/guild#guild-member-object */ export interface GuildMember { /** The user this guild member represents */ user?: User; @@ -20,13 +20,7 @@ export interface GuildMember { pending?: boolean; } -/** https://discord.com/developers/docs/resources/guild#guild-member-object */ -export type DiscordGuildMember = SnakeCasedPropertiesDeep; - // We use these types much since user always exists unless its a `CREATE_MESSAGE` or `MESSAGE_UPDATE` event -export type GuildMemberWithUser = Omit & { user: User }; /** https://discord.com/developers/docs/resources/guild#guild-member-object */ -export type DiscordGuildMemberWithUser = SnakeCasedPropertiesDeep< - GuildMemberWithUser ->; +export type GuildMemberWithUser = Omit & { user: User }; diff --git a/src/types/guilds/guild_preview.ts b/src/types/guilds/guild_preview.ts index e9d96f372..57e17fc3e 100644 --- a/src/types/guilds/guild_preview.ts +++ b/src/types/guilds/guild_preview.ts @@ -1,7 +1,7 @@ import { Emoji } from "../emojis/emoji.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { DiscordGuildFeatures } from "./guild_features.ts"; +/** https://discord.com/developers/docs/resources/guild#guild-preview-object */ export interface GuildPreview { /** Guild id */ id: string; @@ -24,6 +24,3 @@ export interface GuildPreview { /** The description for the guild, if the guild is discoverable */ description: string | null; } - -/** https://discord.com/developers/docs/resources/guild#guild-preview-object */ -export type DiscordGuildPreview = SnakeCasedPropertiesDeep; diff --git a/src/types/guilds/guild_role_create.ts b/src/types/guilds/guild_role_create.ts index 3cb806398..f93ed1623 100644 --- a/src/types/guilds/guild_role_create.ts +++ b/src/types/guilds/guild_role_create.ts @@ -1,12 +1,9 @@ import { Role } from "../permissions/role.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; +/** https://discord.com/developers/docs/topics/gateway#guild-role-create */ export interface GuildRoleCreate { /** The id of the guild */ guildId: string; /** The role created */ role: Role; } - -/** https://discord.com/developers/docs/topics/gateway#guild-role-create */ -export type DiscordGuildRoleCreate = SnakeCasedPropertiesDeep; diff --git a/src/types/guilds/guild_role_delete.ts b/src/types/guilds/guild_role_delete.ts index ed0987640..fef68f8fb 100644 --- a/src/types/guilds/guild_role_delete.ts +++ b/src/types/guilds/guild_role_delete.ts @@ -1,11 +1,7 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/topics/gateway#guild-role-delete */ export interface GuildRoleDelete { /** id of the guild */ guildId: string; /** id of the role */ roleId: string; } - -/** https://discord.com/developers/docs/topics/gateway#guild-role-delete */ -export type DiscordGuildRoleDelete = SnakeCasedPropertiesDeep; diff --git a/src/types/guilds/guild_role_update.ts b/src/types/guilds/guild_role_update.ts index e306621a8..bed4c25ed 100644 --- a/src/types/guilds/guild_role_update.ts +++ b/src/types/guilds/guild_role_update.ts @@ -1,12 +1,9 @@ import { Role } from "../permissions/role.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; +/** https://discord.com/developers/docs/topics/gateway#guild-role-update */ export interface GuildRoleUpdate { /** The id of the guild */ guildId: string; /** The role updated */ role: Role; } - -/** https://discord.com/developers/docs/topics/gateway#guild-role-update */ -export type DiscordGuildRoleUpdate = SnakeCasedPropertiesDeep; diff --git a/src/types/guilds/guild_widget.ts b/src/types/guilds/guild_widget.ts index 8bb8ffc92..0852161cf 100644 --- a/src/types/guilds/guild_widget.ts +++ b/src/types/guilds/guild_widget.ts @@ -1,11 +1,7 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/resources/guild#guild-widget-object-guild-widget-structure */ export interface GuildWidget { /** Whether the widget is enabled */ enabled: boolean; /** The widget channel id */ channelId: string | null; } - -/** https://discord.com/developers/docs/resources/guild#guild-widget-object-guild-widget-structure */ -export type DiscordGuildWidget = SnakeCasedPropertiesDeep; diff --git a/src/types/guilds/list_guild_members.ts b/src/types/guilds/list_guild_members.ts index ce297344b..d8785ca2a 100644 --- a/src/types/guilds/list_guild_members.ts +++ b/src/types/guilds/list_guild_members.ts @@ -1,9 +1,7 @@ +/** https://discord.com/developers/docs/resources/guild#list-guild-members */ export interface ListGuildMembers { /** Max number of members to return (1-1000). Default: 1 */ limit?: number; /** The highest user id in the previous page. Default: 0 */ after?: string; } - -/** https://discord.com/developers/docs/resources/guild#list-guild-members */ -export type DiscordListGuildMembers = ListGuildMembers; diff --git a/src/types/guilds/modify_current_user_nick.ts b/src/types/guilds/modify_current_user_nick.ts index 0bb25da7d..e497b8a75 100644 --- a/src/types/guilds/modify_current_user_nick.ts +++ b/src/types/guilds/modify_current_user_nick.ts @@ -1,7 +1,5 @@ +/** https://discord.com/developers/docs/resources/guild#modify-current-user-nick */ export interface ModifyCurrentUserNick { /** Value to set users nickname to. Requires the CHANGENICKNAME permission */ nick?: string | null; } - -/** https://discord.com/developers/docs/resources/guild#modify-current-user-nick */ -export type DiscordModifyCurrentUserNick = ModifyCurrentUserNick; diff --git a/src/types/guilds/modify_guild.ts b/src/types/guilds/modify_guild.ts index 27ceb3f48..3f3b95b63 100644 --- a/src/types/guilds/modify_guild.ts +++ b/src/types/guilds/modify_guild.ts @@ -1,10 +1,10 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { DiscordDefaultMessageNotificationLevels } from "./default_message_notification_levels.ts"; import { DiscordExplicitContentFilterLevels } from "./explicit_content_filter_levels.ts"; import { DiscordGuildFeatures } from "./guild_features.ts"; import { DiscordSystemChannelFlags } from "./system_channel_flags.ts"; import { DiscordVerificationLevels } from "./verification_levels.ts"; +/** https://discord.com/developers/docs/resources/guild#modify-guild */ export interface ModifyGuild { /** Guild name */ name?: string; @@ -43,6 +43,3 @@ export interface ModifyGuild { /** Enabled guild features */ features?: DiscordGuildFeatures[]; } - -/** https://discord.com/developers/docs/resources/guild#modify-guild */ -export type DiscordModifyGuild = SnakeCasedPropertiesDeep; diff --git a/src/types/guilds/modify_guild_channel_position.ts b/src/types/guilds/modify_guild_channel_position.ts index f23f4fd5a..646cce814 100644 --- a/src/types/guilds/modify_guild_channel_position.ts +++ b/src/types/guilds/modify_guild_channel_position.ts @@ -1,4 +1,5 @@ // TODO: most likely it is but check if lockPositions and parentId really are optional +/** https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions */ export interface ModifyGuildChannelPositions { /** Channel id */ id: string; @@ -9,6 +10,3 @@ export interface ModifyGuildChannelPositions { /** The new parent ID for the channel that is moved */ parentId?: string | null; } - -/** https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions */ -export type DiscordModifyGuildChannelPositions = ModifyGuildChannelPositions; diff --git a/src/types/guilds/modify_guild_member.ts b/src/types/guilds/modify_guild_member.ts index e7756ea07..ceb423dfa 100644 --- a/src/types/guilds/modify_guild_member.ts +++ b/src/types/guilds/modify_guild_member.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/resources/guild#modify-guild-member */ export interface ModifyGuildMember { /** Value to set users nickname to. Requires the `MANAGE_NICKNAMES` permission */ nick?: string | null; @@ -12,8 +11,3 @@ export interface ModifyGuildMember { /** Id of channel to move user to (if they are connected to voice). Requires the `MOVE_MEMBERS` permission */ channelId: string | null; } - -/** https://discord.com/developers/docs/resources/guild#modify-guild-member */ -export type DiscordModifyGuildMember = SnakeCasedPropertiesDeep< - ModifyGuildMember ->; diff --git a/src/types/guilds/modify_guild_role.ts b/src/types/guilds/modify_guild_role.ts index a23d92329..cb5e09006 100644 --- a/src/types/guilds/modify_guild_role.ts +++ b/src/types/guilds/modify_guild_role.ts @@ -18,3 +18,5 @@ export interface DiscordModifyGuildRole extends Omit { permissions?: string | null; } + +// TODO: check this diff --git a/src/types/guilds/modify_guild_role_positions.ts b/src/types/guilds/modify_guild_role_positions.ts index d709e6370..66d3b7dff 100644 --- a/src/types/guilds/modify_guild_role_positions.ts +++ b/src/types/guilds/modify_guild_role_positions.ts @@ -1,9 +1,7 @@ +/** https://discord.com/developers/docs/resources/guild#modify-guild-role-positions */ export interface ModifyGuildRolePositions { /** Role id */ id: string; /** Sorting position of the role */ position?: number | null; } - -/** https://discord.com/developers/docs/resources/guild#modify-guild-role-positions */ -export type DiscordModifyGuildRolePositions = ModifyGuildRolePositions; diff --git a/src/types/guilds/modify_guild_welcome_screen.ts b/src/types/guilds/modify_guild_welcome_screen.ts index f7757e761..d63f64fba 100644 --- a/src/types/guilds/modify_guild_welcome_screen.ts +++ b/src/types/guilds/modify_guild_welcome_screen.ts @@ -1,6 +1,6 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { WelcomeScreenChannel } from "./welcome_screen_channel.ts"; +/** https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen */ export interface ModifyGuildWelcomeScreen { /** Whether the welcome screen is enabled */ enabled?: boolean | null; @@ -9,8 +9,3 @@ export interface ModifyGuildWelcomeScreen { /** The server description to show in the welcome screen */ description?: string | null; } - -/** https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen */ -export type DiscordModifyGuildWelcomeScreen = SnakeCasedPropertiesDeep< - ModifyGuildWelcomeScreen ->; diff --git a/src/types/guilds/request_guild_members.ts b/src/types/guilds/request_guild_members.ts index 89d29feea..98cd10472 100644 --- a/src/types/guilds/request_guild_members.ts +++ b/src/types/guilds/request_guild_members.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/topics/gateway#request-guild-members */ export interface RequestGuildMembers { /** id of the guild to get members for */ guildId: string; @@ -14,8 +13,3 @@ export interface RequestGuildMembers { /** Nonce to identify the Guild Members Chunk response */ nonce?: string; } - -/** https://discord.com/developers/docs/topics/gateway#request-guild-members */ -export type DiscordRequestGuildMembers = SnakeCasedPropertiesDeep< - RequestGuildMembers ->; diff --git a/src/types/guilds/unavailable_guild.ts b/src/types/guilds/unavailable_guild.ts index d52f8c5fe..25de4d61a 100644 --- a/src/types/guilds/unavailable_guild.ts +++ b/src/types/guilds/unavailable_guild.ts @@ -1,9 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { Guild } from "./guild.ts"; -export type UnavailableGuild = Pick; - /** https://discord.com/developers/docs/resources/guild#unavailable-guild-object */ -export type DiscordUnavailableGuild = SnakeCasedPropertiesDeep< - UnavailableGuild ->; +export type UnavailableGuild = Pick; diff --git a/src/types/guilds/update_others_voice_state.ts b/src/types/guilds/update_others_voice_state.ts index deb0904f2..87f524582 100644 --- a/src/types/guilds/update_others_voice_state.ts +++ b/src/types/guilds/update_others_voice_state.ts @@ -1,13 +1,7 @@ -import { SnakeCasedProperties } from "../util.ts"; - +/** https://discord.com/developers/docs/resources/guild#update-user-voice-state */ export interface UpdateOthersVoiceState { /** The id of the channel the user is currently in */ channelId: string; /** Toggles the user's suppress state */ suppress?: boolean; } - -/** https://discord.com/developers/docs/resources/guild#update-user-voice-state */ -export type DiscordUpdateOthersVoiceState = SnakeCasedProperties< - UpdateOthersVoiceState ->; diff --git a/src/types/guilds/update_self_voice_state.ts b/src/types/guilds/update_self_voice_state.ts index fcc6fbda3..475a55a75 100644 --- a/src/types/guilds/update_self_voice_state.ts +++ b/src/types/guilds/update_self_voice_state.ts @@ -1,5 +1,4 @@ -import { SnakeCasedProperties } from "../util.ts"; - +/** https://discord.com/developers/docs/resources/guild#update-current-user-voice-state */ export interface UpdateSelfVoiceState { /** The id of the channel the user is currently in */ channelId: string; @@ -8,8 +7,3 @@ export interface UpdateSelfVoiceState { /** Sets the user's request to speak */ requestToSpeakTimestamp?: string | null; } - -/** https://discord.com/developers/docs/resources/guild#update-current-user-voice-state */ -export type DiscordUpdateSelfVoiceState = SnakeCasedProperties< - UpdateSelfVoiceState ->; diff --git a/src/types/guilds/welcome_screen.ts b/src/types/guilds/welcome_screen.ts index 092b35ebb..f13f319fe 100644 --- a/src/types/guilds/welcome_screen.ts +++ b/src/types/guilds/welcome_screen.ts @@ -1,12 +1,9 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { WelcomeScreenChannel } from "./welcome_screen_channel.ts"; +/** https://discord.com/developers/docs/resources/guild#welcome-screen-object-welcome-screen-structure */ export interface WelcomeScreen { /** The server description shown in the welcome screen */ description: string | null; /** The channels shown in the welcome screen, up to 5 */ welcomeChannels: WelcomeScreenChannel[]; } - -/** https://discord.com/developers/docs/resources/guild#welcome-screen-object-welcome-screen-structure */ -export type DiscordWelcomeScreen = SnakeCasedPropertiesDeep; diff --git a/src/types/guilds/welcome_screen_channel.ts b/src/types/guilds/welcome_screen_channel.ts index 0b44d9c94..3abfd3802 100644 --- a/src/types/guilds/welcome_screen_channel.ts +++ b/src/types/guilds/welcome_screen_channel.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/resources/guild#welcome-screen-object-welcome-screen-channel-structure */ export interface WelcomeScreenChannel { /** The channel's id */ channelId: string; @@ -10,8 +9,3 @@ export interface WelcomeScreenChannel { /** The emoji name if custom, the unicode character if standard, or `null` if no emoji is set */ emojiName: string | null; } - -/** https://discord.com/developers/docs/resources/guild#welcome-screen-object-welcome-screen-channel-structure */ -export type DiscordWelcomeScreenChannel = SnakeCasedPropertiesDeep< - WelcomeScreenChannel ->; From cc97ccad0351d517311639a8a5d2bdce84a75b97 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 19:34:30 +0200 Subject: [PATCH 50/78] remove Discord* types for integrations --- src/types/integration/guild_integrations_update.ts | 8 +------- src/types/integration/integration.ts | 5 +---- src/types/integration/integration_account.ts | 4 +--- src/types/integration/integration_application.ts | 7 +------ src/types/integration/integration_create_update.ts | 7 +------ src/types/integration/integration_delete.ts | 8 +------- 6 files changed, 6 insertions(+), 33 deletions(-) diff --git a/src/types/integration/guild_integrations_update.ts b/src/types/integration/guild_integrations_update.ts index e29351c75..764bbe9cb 100644 --- a/src/types/integration/guild_integrations_update.ts +++ b/src/types/integration/guild_integrations_update.ts @@ -1,11 +1,5 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/topics/gateway#guild-integrations-update */ export interface GuildIntegrationsUpdate { /** id of the guild whose integrations were updated */ guildId: string; } - -/** https://discord.com/developers/docs/topics/gateway#guild-integrations-update */ -export type DiscordGuildIntegrationsUpdate = SnakeCasedPropertiesDeep< - GuildIntegrationsUpdate ->; diff --git a/src/types/integration/integration.ts b/src/types/integration/integration.ts index 0ddb7e7aa..8da189369 100644 --- a/src/types/integration/integration.ts +++ b/src/types/integration/integration.ts @@ -1,9 +1,9 @@ import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { IntegrationAccount } from "./integration_account.ts"; import { IntegrationApplication } from "./integration_application.ts"; import { DiscordIntegrationExpireBehaviors } from "./integration_expire_behaviors.ts"; +/** https://discord.com/developers/docs/resources/guild#integration-object-integration-structure */ export interface Integration { /** Integration Id */ id: string; @@ -36,6 +36,3 @@ export interface Integration { /** The bot/OAuth2 application for discord integrations */ application?: IntegrationApplication; } - -/** https://discord.com/developers/docs/resources/guild#integration-object-integration-structure */ -export type DiscordIntegration = SnakeCasedPropertiesDeep; diff --git a/src/types/integration/integration_account.ts b/src/types/integration/integration_account.ts index d22707860..35ceb8497 100644 --- a/src/types/integration/integration_account.ts +++ b/src/types/integration/integration_account.ts @@ -1,9 +1,7 @@ +/** https://discord.com/developers/docs/resources/guild#integration-account-object-integration-account-structure */ export interface IntegrationAccount { /** Id of the account */ id: string; /** Name of the account */ name: string; } - -/** https://discord.com/developers/docs/resources/guild#integration-account-object-integration-account-structure */ -export type DiscordIntegrationAccount = IntegrationAccount; diff --git a/src/types/integration/integration_application.ts b/src/types/integration/integration_application.ts index 0b20531b3..1b3d20ade 100644 --- a/src/types/integration/integration_application.ts +++ b/src/types/integration/integration_application.ts @@ -1,6 +1,6 @@ import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; +/** https://discord.com/developers/docs/resources/guild#integration-application-object-integration-application-structure */ export interface IntegrationApplication { /** The id of the app */ id: string; @@ -15,8 +15,3 @@ export interface IntegrationApplication { /** The bot associated with this application */ bot?: User; } - -/** https://discord.com/developers/docs/resources/guild#integration-application-object-integration-application-structure */ -export type DiscordIntegrationApplication = SnakeCasedPropertiesDeep< - IntegrationApplication ->; diff --git a/src/types/integration/integration_create_update.ts b/src/types/integration/integration_create_update.ts index dda32b493..43a04ec67 100644 --- a/src/types/integration/integration_create_update.ts +++ b/src/types/integration/integration_create_update.ts @@ -1,12 +1,7 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { Integration } from "./integration.ts"; +/** https://github.com/discord/discord-api-docs/blob/master/docs/topics/Gateway.md#integration-create-event-additional-fields */ export interface IntegrationCreateUpdate extends Integration { /** Id of the guild */ guildId: string; } - -/** https://github.com/discord/discord-api-docs/blob/master/docs/topics/Gateway.md#integration-create-event-additional-fields */ -export type DiscordIntegrationCreateUpdate = SnakeCasedPropertiesDeep< - IntegrationCreateUpdate ->; diff --git a/src/types/integration/integration_delete.ts b/src/types/integration/integration_delete.ts index 83d090299..68f488ebe 100644 --- a/src/types/integration/integration_delete.ts +++ b/src/types/integration/integration_delete.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://github.com/discord/discord-api-docs/blob/master/docs/topics/Gateway.md#integration-delete-event-fields */ export interface IntegrationDelete { /** Integration id */ id: string; @@ -8,8 +7,3 @@ export interface IntegrationDelete { /** Id of the bot/OAuth2 application for this discord integration */ applicationId?: string; } - -/** https://github.com/discord/discord-api-docs/blob/master/docs/topics/Gateway.md#integration-delete-event-fields */ -export type DiscordIntegrationDelete = SnakeCasedPropertiesDeep< - IntegrationDelete ->; From 247985065406ffd927f176f9f244dacf335a31f7 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 19:36:29 +0200 Subject: [PATCH 51/78] remove Discord* types for interactions --- src/types/interactions/application_command.ts | 7 +------ .../interactions/application_command_callback_data.ts | 6 +----- .../application_command_create_update_delete.ts | 6 +----- .../interactions/application_command_interaction_data.ts | 7 +------ .../application_command_interaction_data_option.ts | 6 +----- src/types/interactions/application_command_option.ts | 7 +------ .../interactions/application_command_option_choice.ts | 5 +---- src/types/interactions/application_command_permissions.ts | 5 +---- .../interactions/create_global_application_command.ts | 7 +------ src/types/interactions/create_guild_application_command.ts | 7 +------ src/types/interactions/edit_global_application_command.ts | 7 +------ src/types/interactions/edit_guild_application_command.ts | 7 +------ .../interactions/guild_application_command_permissions.ts | 6 +----- src/types/interactions/interaction.ts | 5 +---- src/types/interactions/interaction_guild_member.ts | 7 +------ src/types/interactions/interaction_response.ts | 7 +------ src/types/interactions/message_interaction.ts | 7 +------ 17 files changed, 17 insertions(+), 92 deletions(-) diff --git a/src/types/interactions/application_command.ts b/src/types/interactions/application_command.ts index 24cae6c8d..d6ac55f86 100644 --- a/src/types/interactions/application_command.ts +++ b/src/types/interactions/application_command.ts @@ -1,6 +1,6 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { ApplicationCommandOption } from "./application_command_option.ts"; +/** https://discord.com/developers/docs/interactions/slash-commands#applicationcommand */ export interface ApplicationCommand { /** Unique id of the command */ id: string; @@ -15,8 +15,3 @@ export interface ApplicationCommand { /** Whether the command is enbaled by default when the app is added to a guild */ defaultPermission?: boolean; } - -/** https://discord.com/developers/docs/interactions/slash-commands#applicationcommand */ -export type DiscordApplicationCommand = SnakeCasedPropertiesDeep< - ApplicationCommand ->; diff --git a/src/types/interactions/application_command_callback_data.ts b/src/types/interactions/application_command_callback_data.ts index e5443854e..5844862d2 100644 --- a/src/types/interactions/application_command_callback_data.ts +++ b/src/types/interactions/application_command_callback_data.ts @@ -1,7 +1,7 @@ import { Embed } from "../embeds/embed.ts"; import { AllowedMentions } from "../messages/allowed_mentions.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; +/** https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata */ export interface InteractionApplicationCommandCallbackData { /** Is the response TTS */ tts?: boolean; @@ -14,7 +14,3 @@ export interface InteractionApplicationCommandCallbackData { /** Set to `64` to make your response ephemeral */ flags?: number; } - -/** https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata */ -export type DiscordInteractionApplicationCommandCallbackData = - SnakeCasedPropertiesDeep; diff --git a/src/types/interactions/application_command_create_update_delete.ts b/src/types/interactions/application_command_create_update_delete.ts index 83aaaba9a..2d5f57640 100644 --- a/src/types/interactions/application_command_create_update_delete.ts +++ b/src/types/interactions/application_command_create_update_delete.ts @@ -1,12 +1,8 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { ApplicationCommand } from "./application_command.ts"; +/** https://discord.com/developers/docs/topics/gateway#application-command-delete-application-command-extra-fields */ export interface ApplicationCommandCreateUpdateDelete extends ApplicationCommand { /** Id of the guild the command is in */ guildId?: string; } - -/** https://discord.com/developers/docs/topics/gateway#application-command-delete-application-command-extra-fields */ -export type DiscordApplicationCommandCreateUpdateDelete = - SnakeCasedPropertiesDeep; diff --git a/src/types/interactions/application_command_interaction_data.ts b/src/types/interactions/application_command_interaction_data.ts index 5074f1c29..d5653437a 100644 --- a/src/types/interactions/application_command_interaction_data.ts +++ b/src/types/interactions/application_command_interaction_data.ts @@ -1,7 +1,7 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { ApplicationCommandInteractionDataOption } from "./application_command_interaction_data_option.ts"; import { ApplicationCommandInteractionDataResolved } from "./application_command_interaction_data_resolved.ts"; +/** https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondata */ export interface ApplicationCommandInteractionData { /** The Id of the invoked command */ id: string; @@ -12,8 +12,3 @@ export interface ApplicationCommandInteractionData { /** The params + values from the user */ options?: ApplicationCommandInteractionDataOption[]; } - -/** https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondata */ -export type DiscordApplicationCommandInteractionData = SnakeCasedPropertiesDeep< - ApplicationCommandInteractionData ->; diff --git a/src/types/interactions/application_command_interaction_data_option.ts b/src/types/interactions/application_command_interaction_data_option.ts index 2915656b4..99421663d 100644 --- a/src/types/interactions/application_command_interaction_data_option.ts +++ b/src/types/interactions/application_command_interaction_data_option.ts @@ -1,6 +1,6 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { DiscordApplicationCommandOptionTypes } from "./application_command_option_types.ts"; +/** https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondataoption */ export interface ApplicationCommandInteractionDataOption { /** The name of the parameter */ name: string; @@ -11,7 +11,3 @@ export interface ApplicationCommandInteractionDataOption { /** Present if this option is a group or subcommand */ options?: ApplicationCommandInteractionDataOption[]; } - -/** https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondataoption */ -export type DiscordApplicationCommandInteractionDataOption = - SnakeCasedPropertiesDeep; diff --git a/src/types/interactions/application_command_option.ts b/src/types/interactions/application_command_option.ts index 1491c8898..c8ebbfb3d 100644 --- a/src/types/interactions/application_command_option.ts +++ b/src/types/interactions/application_command_option.ts @@ -1,7 +1,7 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { ApplicationCommandOptionChoice } from "./application_command_option_choice.ts"; import { DiscordApplicationCommandOptionTypes } from "./application_command_option_types.ts"; +/** https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoption */ export interface ApplicationCommandOption { /** Value of Application Command Option Type */ type: DiscordApplicationCommandOptionTypes; @@ -16,8 +16,3 @@ export interface ApplicationCommandOption { /** If the optino is a subcommand or subcommand group type, this nested options will be the parameters */ options?: ApplicationCommandOption[]; } - -/** https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoption */ -export type DiscordApplicationCommandOption = SnakeCasedPropertiesDeep< - ApplicationCommandOption ->; diff --git a/src/types/interactions/application_command_option_choice.ts b/src/types/interactions/application_command_option_choice.ts index 7bde91922..78f1846fd 100644 --- a/src/types/interactions/application_command_option_choice.ts +++ b/src/types/interactions/application_command_option_choice.ts @@ -1,10 +1,7 @@ +/** https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptionchoice */ export interface ApplicationCommandOptionChoice { /** 1-100 character choice name */ name: string; /** Value of the choice, up to 100 characters if string */ value: string | number; } - -/** https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptionchoice */ -export type DiscordApplicationCommandOptionChoice = - ApplicationCommandOptionChoice; diff --git a/src/types/interactions/application_command_permissions.ts b/src/types/interactions/application_command_permissions.ts index 48453dfeb..197ce20db 100644 --- a/src/types/interactions/application_command_permissions.ts +++ b/src/types/interactions/application_command_permissions.ts @@ -1,5 +1,6 @@ import { DiscordApplicationCommandPermissionTypes } from "./application_command_permission_types.ts"; +/** https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissions */ export interface ApplicationCommandPermissions { /** The id of the role or user */ id: string; @@ -8,7 +9,3 @@ export interface ApplicationCommandPermissions { /** `true` to allow, `false`, to disallow */ permission: boolean; } - -/** https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissions */ -export type DiscordApplicationCommandPermissions = - ApplicationCommandPermissions; diff --git a/src/types/interactions/create_global_application_command.ts b/src/types/interactions/create_global_application_command.ts index 760141db4..0779e8207 100644 --- a/src/types/interactions/create_global_application_command.ts +++ b/src/types/interactions/create_global_application_command.ts @@ -1,6 +1,6 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { ApplicationCommandOption } from "./application_command_option.ts"; +/** https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command-json-params */ export interface CreateGlobalApplicationCommand { /** 1-31 character name matching `^[\w-]{1,32}$` */ name: string; @@ -9,8 +9,3 @@ export interface CreateGlobalApplicationCommand { /** The parameters for the command */ options?: ApplicationCommandOption[]; } - -/** https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command-json-params */ -export type DiscordCreateGlobalApplicationCommand = SnakeCasedPropertiesDeep< - CreateGlobalApplicationCommand ->; diff --git a/src/types/interactions/create_guild_application_command.ts b/src/types/interactions/create_guild_application_command.ts index 8c6520826..1053452eb 100644 --- a/src/types/interactions/create_guild_application_command.ts +++ b/src/types/interactions/create_guild_application_command.ts @@ -1,6 +1,6 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { ApplicationCommandOption } from "./application_command_option.ts"; +/** https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command-json-params */ export interface CreateGuildApplicationCommand { /** 1-31 character name matching `^[\w-]{1,32}$` */ name: string; @@ -9,8 +9,3 @@ export interface CreateGuildApplicationCommand { /** The parameters for the command */ options?: ApplicationCommandOption[]; } - -/** https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command-json-params */ -export type DiscordCreateGuildApplicationCommand = SnakeCasedPropertiesDeep< - CreateGuildApplicationCommand ->; diff --git a/src/types/interactions/edit_global_application_command.ts b/src/types/interactions/edit_global_application_command.ts index a9cc2e088..da4f9a0b0 100644 --- a/src/types/interactions/edit_global_application_command.ts +++ b/src/types/interactions/edit_global_application_command.ts @@ -1,6 +1,6 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { ApplicationCommandOption } from "./application_command_option.ts"; +/** https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command-json-params */ export interface EditGlobalApplicationCommand { /** 1-31 character name matching `^[\w-]{1,32}$` */ name?: string; @@ -9,8 +9,3 @@ export interface EditGlobalApplicationCommand { /** The parameters for the command */ options?: ApplicationCommandOption[] | null; } - -/** https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command-json-params */ -export type DiscordEditGlobalApplicationCommand = SnakeCasedPropertiesDeep< - EditGlobalApplicationCommand ->; diff --git a/src/types/interactions/edit_guild_application_command.ts b/src/types/interactions/edit_guild_application_command.ts index d5139f065..e3c842694 100644 --- a/src/types/interactions/edit_guild_application_command.ts +++ b/src/types/interactions/edit_guild_application_command.ts @@ -1,6 +1,6 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { ApplicationCommandOption } from "./application_command_option.ts"; +/** https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command-json-params */ export interface EditGuildApplicationCommand { /** 1-31 character name matching `^[\w-]{1,32}$` */ name?: string; @@ -9,8 +9,3 @@ export interface EditGuildApplicationCommand { /** The parameters for the command */ options?: ApplicationCommandOption[] | null; } - -/** https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command-json-params */ -export type DiscordEditGuildApplicationCommand = SnakeCasedPropertiesDeep< - EditGuildApplicationCommand ->; diff --git a/src/types/interactions/guild_application_command_permissions.ts b/src/types/interactions/guild_application_command_permissions.ts index 6845e90d7..3f940e399 100644 --- a/src/types/interactions/guild_application_command_permissions.ts +++ b/src/types/interactions/guild_application_command_permissions.ts @@ -1,6 +1,6 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { ApplicationCommandPermissions } from "./application_command_permissions.ts"; +/** https://discord.com/developers/docs/interactions/slash-commands#guildapplicationcommandpermissions */ export interface GuildApplicationCommandPermissions { /** The id of the command */ id: string; @@ -11,7 +11,3 @@ export interface GuildApplicationCommandPermissions { /** The permissions for the command in the guild */ permissions: ApplicationCommandPermissions[]; } - -/** https://discord.com/developers/docs/interactions/slash-commands#guildapplicationcommandpermissions */ -export type DiscordGuildApplicationCommandPermissions = - SnakeCasedPropertiesDeep; diff --git a/src/types/interactions/interaction.ts b/src/types/interactions/interaction.ts index a2b8b66f7..32612abaf 100644 --- a/src/types/interactions/interaction.ts +++ b/src/types/interactions/interaction.ts @@ -1,9 +1,9 @@ import { GuildMemberWithUser } from "../guilds/guild_member.ts"; import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { ApplicationCommandInteractionData } from "./application_command_interaction_data.ts"; import { DiscordInteractionTypes } from "./interaction_types.ts"; +/** https://discord.com/developers/docs/interactions/slash-commands#interaction */ export interface Interaction { /** Id of the interaction */ id: string; @@ -26,6 +26,3 @@ export interface Interaction { /** Read-only property, always `1` */ version: 1; } - -/** https://discord.com/developers/docs/interactions/slash-commands#interaction */ -export type DiscordInteraction = SnakeCasedPropertiesDeep; diff --git a/src/types/interactions/interaction_guild_member.ts b/src/types/interactions/interaction_guild_member.ts index a37e50b9b..fb9cebc78 100644 --- a/src/types/interactions/interaction_guild_member.ts +++ b/src/types/interactions/interaction_guild_member.ts @@ -1,12 +1,7 @@ import { GuildMember } from "../guilds/guild_member.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; +/** https://discord.com/developers/docs/resources/guild#guild-member-object */ export interface InteractionGuildMember extends GuildMember { /** Total permissions of the member in the channel, including overrides, returned when in the interaction object */ permissions: string; } - -/** https://discord.com/developers/docs/resources/guild#guild-member-object */ -export type DiscordInteractionGuildMember = SnakeCasedPropertiesDeep< - InteractionGuildMember ->; diff --git a/src/types/interactions/interaction_response.ts b/src/types/interactions/interaction_response.ts index 044437e74..5460cbb4e 100644 --- a/src/types/interactions/interaction_response.ts +++ b/src/types/interactions/interaction_response.ts @@ -1,15 +1,10 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { InteractionApplicationCommandCallbackData } from "./application_command_callback_data.ts"; import { DiscordInteractionResponseTypes } from "./interaction_response_types.ts"; +/** https://discord.com/developers/docs/interactions/slash-commands#interaction-response */ export interface InteractionResponse { /** The type of response */ type: DiscordInteractionResponseTypes; /** An optional response message */ data?: InteractionApplicationCommandCallbackData; } - -/** https://discord.com/developers/docs/interactions/slash-commands#interaction-response */ -export type DiscordInteractionResponse = SnakeCasedPropertiesDeep< - InteractionResponse ->; diff --git a/src/types/interactions/message_interaction.ts b/src/types/interactions/message_interaction.ts index 2ceb98aca..c1471ede1 100644 --- a/src/types/interactions/message_interaction.ts +++ b/src/types/interactions/message_interaction.ts @@ -1,7 +1,7 @@ import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { DiscordInteractionTypes } from "./interaction_types.ts"; +/** https://discord.com/developers/docs/interactions/slash-commands#messageinteraction */ export interface MessageInteraction { /** Id of the interaction */ id: string; @@ -12,8 +12,3 @@ export interface MessageInteraction { /** The user who invoked the interaction */ user: User; } - -/** https://discord.com/developers/docs/interactions/slash-commands#messageinteraction */ -export type DiscordMessageInteraction = SnakeCasedPropertiesDeep< - MessageInteraction ->; From f7214fc9573ddd1f288d36d29dad228666432396 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 19:38:03 +0200 Subject: [PATCH 52/78] remove Discord* types for invites --- src/types/invites/get_invite.ts | 6 +----- src/types/invites/invite.ts | 5 +---- src/types/invites/invite_create.ts | 5 +---- src/types/invites/invite_delete.ts | 4 ---- src/types/invites/invite_metadata.ts | 5 +---- 5 files changed, 4 insertions(+), 21 deletions(-) diff --git a/src/types/invites/get_invite.ts b/src/types/invites/get_invite.ts index a7b9a4411..46a3caaad 100644 --- a/src/types/invites/get_invite.ts +++ b/src/types/invites/get_invite.ts @@ -1,9 +1,5 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/resources/invite#get-invite */ export interface GetInvite { /** Whether the invite should contain approximate member counts */ withCounts?: boolean; } - -/** https://discord.com/developers/docs/resources/invite#get-invite */ -export type DiscordGetInvite = SnakeCasedPropertiesDeep; diff --git a/src/types/invites/invite.ts b/src/types/invites/invite.ts index 30a4c3e22..f06dcb266 100644 --- a/src/types/invites/invite.ts +++ b/src/types/invites/invite.ts @@ -2,9 +2,9 @@ import { Channel } from "../channels/channel.ts"; import { Guild } from "../guilds/guild.ts"; import { Application } from "../oauth2/application.ts"; import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { DiscordTargetTypes } from "./target_types.ts"; +/** https://discord.com/developers/docs/resources/invite#invite-object */ export interface Invite { /** The invite code (unique Id) */ code: string; @@ -25,6 +25,3 @@ export interface Invite { /** Approximate count of total members */ approximateMemberCount?: number; } - -/** https://discord.com/developers/docs/resources/invite#invite-object */ -export type DiscordInvite = SnakeCasedPropertiesDeep; diff --git a/src/types/invites/invite_create.ts b/src/types/invites/invite_create.ts index cb194d5a4..3178946dc 100644 --- a/src/types/invites/invite_create.ts +++ b/src/types/invites/invite_create.ts @@ -1,8 +1,8 @@ import { Application } from "../oauth2/application.ts"; import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { DiscordTargetTypes } from "./target_types.ts"; +/** https://discord.com/developers/docs/topics/gateway#invite-create */ export interface InviteCreate { /** The channel the invite is for */ channelId: string; @@ -29,6 +29,3 @@ export interface InviteCreate { /** How many times the invite has been used (always will be 0) */ uses: number; } - -/** https://discord.com/developers/docs/topics/gateway#invite-create */ -export type DiscordInviteCreate = SnakeCasedPropertiesDeep; diff --git a/src/types/invites/invite_delete.ts b/src/types/invites/invite_delete.ts index df324bdd3..0f80aeae1 100644 --- a/src/types/invites/invite_delete.ts +++ b/src/types/invites/invite_delete.ts @@ -1,5 +1,3 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - /** https://discord.com/developers/docs/topics/gateway#invite-delete */ export interface InviteDelete { /** The channel of the invite */ @@ -9,5 +7,3 @@ export interface InviteDelete { /** The unique invite code */ code: string; } - -export type DiscordInviteDelete = SnakeCasedPropertiesDeep; diff --git a/src/types/invites/invite_metadata.ts b/src/types/invites/invite_metadata.ts index ec43a2414..61f1fc3bd 100644 --- a/src/types/invites/invite_metadata.ts +++ b/src/types/invites/invite_metadata.ts @@ -1,6 +1,6 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { Invite } from "./invite.ts"; +/** https://discord.com/developers/docs/resources/invite#invite-metadata-object */ export interface InviteMetadata extends Invite { /** Number of times this invite has been used */ uses: number; @@ -13,6 +13,3 @@ export interface InviteMetadata extends Invite { /** When this invite was created */ createdAt: string; } - -/** https://discord.com/developers/docs/resources/invite#invite-metadata-object */ -export type DiscordInviteMetadata = SnakeCasedPropertiesDeep; From e164c4b432957a16319e9983df1a18a316506383 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 19:39:46 +0200 Subject: [PATCH 53/78] remove Discord* types for members --- src/types/members/guild_member_add.ts | 5 +---- src/types/members/guild_member_remove.ts | 7 +------ src/types/members/guild_member_update.ts | 7 +------ src/types/members/guild_members_chunk.ts | 7 +------ src/types/members/search_guild_members.ts | 4 +--- 5 files changed, 5 insertions(+), 25 deletions(-) diff --git a/src/types/members/guild_member_add.ts b/src/types/members/guild_member_add.ts index a92d651d3..a39685228 100644 --- a/src/types/members/guild_member_add.ts +++ b/src/types/members/guild_member_add.ts @@ -1,10 +1,7 @@ import { GuildMemberWithUser } from "../guilds/guild_member.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; +/** https://discord.com/developers/docs/topics/gateway#guild-member-add */ export interface GuildMemberAdd extends GuildMemberWithUser { /** id of the guild */ guildId: string; } - -/** https://discord.com/developers/docs/topics/gateway#guild-member-add */ -export type DiscordGuildMemberAdd = SnakeCasedPropertiesDeep; diff --git a/src/types/members/guild_member_remove.ts b/src/types/members/guild_member_remove.ts index 21010be0c..ea791e6ff 100644 --- a/src/types/members/guild_member_remove.ts +++ b/src/types/members/guild_member_remove.ts @@ -1,14 +1,9 @@ import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; +/** https://discord.com/developers/docs/topics/gateway#guild-member-remove */ export interface GuildMemberRemove { /** The id of the guild */ guildId: string; /** The user who was removed */ user: User; } - -/** https://discord.com/developers/docs/topics/gateway#guild-member-remove */ -export type DiscordGuildMemberRemove = SnakeCasedPropertiesDeep< - GuildMemberRemove ->; diff --git a/src/types/members/guild_member_update.ts b/src/types/members/guild_member_update.ts index c78bb8caf..803318a10 100644 --- a/src/types/members/guild_member_update.ts +++ b/src/types/members/guild_member_update.ts @@ -1,6 +1,6 @@ import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; +/** https://discord.com/developers/docs/topics/gateway#guild-member-update */ export interface GuildMemberUpdate { /** The id of the guild */ guildId: string; @@ -21,8 +21,3 @@ export interface GuildMemberUpdate { /** whether the user is muted in voice channels */ mute?: boolean; } - -/** https://discord.com/developers/docs/topics/gateway#guild-member-update */ -export type DiscordGuildMemberUpdate = SnakeCasedPropertiesDeep< - GuildMemberUpdate ->; diff --git a/src/types/members/guild_members_chunk.ts b/src/types/members/guild_members_chunk.ts index d346550e4..a4b801f33 100644 --- a/src/types/members/guild_members_chunk.ts +++ b/src/types/members/guild_members_chunk.ts @@ -1,7 +1,7 @@ import { GuildMemberWithUser } from "../guilds/guild_member.ts"; import { PresenceUpdate } from "../misc/presence_update.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; +/** https://discord.com/developers/docs/topics/gateway#guild-members-chunk */ export interface GuildMembersChunk { /** The id of the guild */ guildId: string; @@ -18,8 +18,3 @@ export interface GuildMembersChunk { /** The nonce used in the Guild Members Request */ nonce?: string; } - -/** https://discord.com/developers/docs/topics/gateway#guild-members-chunk */ -export type DiscordGuildMembersChunk = SnakeCasedPropertiesDeep< - GuildMembersChunk ->; diff --git a/src/types/members/search_guild_members.ts b/src/types/members/search_guild_members.ts index 6a984618d..f7da50c16 100644 --- a/src/types/members/search_guild_members.ts +++ b/src/types/members/search_guild_members.ts @@ -1,9 +1,7 @@ +/** https://discord.com/developers/docs/resources/guild#search-guild-members-query-string-params */ export interface SearchGuildMembers { /** Query string to match username(s) and nickname(s) against */ query: string; /** Max number of members to return (1-1000). Default: 1 */ limit?: number; } - -/** https://discord.com/developers/docs/resources/guild#search-guild-members-query-string-params */ -export type DiscordSearchGuildMembers = SearchGuildMembers; From a381c19ea359a1a55d430b8a3a134ae9dc307742 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 19:42:21 +0200 Subject: [PATCH 54/78] remove Discord* types for messages --- src/types/messages/allowed_mentions.ts | 5 +---- src/types/messages/attachment.ts | 6 +----- src/types/messages/create_message.ts | 2 ++ src/types/messages/edit_message.ts | 5 +---- src/types/messages/get_messages.ts | 8 +++++--- src/types/messages/message.ts | 5 +---- src/types/messages/message_activity.ts | 5 +---- src/types/messages/message_delete.ts | 6 +----- src/types/messages/message_delete_bulk.ts | 8 +------- src/types/messages/message_get_reactions.ts | 4 +--- src/types/messages/message_reaction_add.ts | 7 +------ src/types/messages/message_reaction_remove.ts | 7 +------ src/types/messages/message_reaction_remove_all.ts | 7 +------ src/types/messages/message_reaction_remove_emoji.ts | 7 +------ src/types/messages/message_reference.ts | 8 +------- src/types/messages/message_sticker.ts | 5 +---- src/types/messages/reaction.ts | 4 +--- 17 files changed, 22 insertions(+), 77 deletions(-) diff --git a/src/types/messages/allowed_mentions.ts b/src/types/messages/allowed_mentions.ts index 8054ad286..f5e43a94d 100644 --- a/src/types/messages/allowed_mentions.ts +++ b/src/types/messages/allowed_mentions.ts @@ -1,6 +1,6 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { DiscordAllowedMentionsTypes } from "./allowed_mentions_types.ts"; +/** https://discord.com/developers/docs/resources/channel#allowed-mentions-object */ export interface AllowedMentions { /** An array of allowed mention types to parse from the content. */ parse?: DiscordAllowedMentionsTypes[]; @@ -11,6 +11,3 @@ export interface AllowedMentions { /** For replies, whether to mention the author of the message being replied to (default false) */ repliedUser?: boolean; } - -/** https://discord.com/developers/docs/resources/channel#allowed-mentions-object */ -export type DiscordAllowedMentions = SnakeCasedPropertiesDeep; diff --git a/src/types/messages/attachment.ts b/src/types/messages/attachment.ts index 638945348..62bc4fc07 100644 --- a/src/types/messages/attachment.ts +++ b/src/types/messages/attachment.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/resources/channel#attachment-object */ export interface Attachment { /** Attachment id */ id: string; @@ -18,6 +17,3 @@ export interface Attachment { /** Width of file (if image) */ width?: number | null; } - -/** https://discord.com/developers/docs/resources/channel#attachment-object */ -export type DiscordAttachment = SnakeCasedPropertiesDeep; diff --git a/src/types/messages/create_message.ts b/src/types/messages/create_message.ts index 1ec41fc32..e4cdcf7e4 100644 --- a/src/types/messages/create_message.ts +++ b/src/types/messages/create_message.ts @@ -25,3 +25,5 @@ export interface CreateMessage { export type DiscordCreateMessage = SnakeCasedPropertiesDeep< Omit >; + +// TODO: check this diff --git a/src/types/messages/edit_message.ts b/src/types/messages/edit_message.ts index fc586dab8..9b726a411 100644 --- a/src/types/messages/edit_message.ts +++ b/src/types/messages/edit_message.ts @@ -1,7 +1,7 @@ import { Embed } from "../embeds/embed.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { AllowedMentions } from "./allowed_mentions.ts"; +/** https://discord.com/developers/docs/resources/channel#edit-message-json-params */ export interface EditMessage { /** The new message contents (up to 2000 characters) */ content?: string | null; @@ -12,6 +12,3 @@ export interface EditMessage { /** Allowed mentions for the message */ allowedMentions?: AllowedMentions | null; } - -/** https://discord.com/developers/docs/resources/channel#edit-message-json-params */ -export type DiscordEditMessage = SnakeCasedPropertiesDeep; diff --git a/src/types/messages/get_messages.ts b/src/types/messages/get_messages.ts index 3c5767f99..9231d5577 100644 --- a/src/types/messages/get_messages.ts +++ b/src/types/messages/get_messages.ts @@ -1,28 +1,30 @@ +/** https://discord.com/developers/docs/resources/channel#get-channel-messages-query-string-params */ export interface GetMessagesLimit { /** Max number of messages to return (1-100) default 50 */ limit?: number; } +/** https://discord.com/developers/docs/resources/channel#get-channel-messages-query-string-params */ export interface GetMessagesAround extends GetMessagesLimit { /** Get messages around this message id */ around?: string; } +/** https://discord.com/developers/docs/resources/channel#get-channel-messages-query-string-params */ export interface GetMessagesBefore extends GetMessagesLimit { /** Get messages before this message id */ before?: string; } +/** https://discord.com/developers/docs/resources/channel#get-channel-messages-query-string-params */ export interface GetMessagesAfter extends GetMessagesLimit { /** Get messages after this message id */ after?: string; } +/** https://discord.com/developers/docs/resources/channel#get-channel-messages-query-string-params */ export type GetMessages = & GetMessagesLimit & GetMessagesAfter & GetMessagesBefore & GetMessagesAround; - -/** https://discord.com/developers/docs/resources/channel#get-channel-messages-query-string-params */ -export type DiscordGetMessages = GetMessages; diff --git a/src/types/messages/message.ts b/src/types/messages/message.ts index c00b23d62..8b16b5e90 100644 --- a/src/types/messages/message.ts +++ b/src/types/messages/message.ts @@ -4,7 +4,6 @@ import { GuildMember } from "../guilds/guild_member.ts"; import { MessageInteraction } from "../interactions/message_interaction.ts"; import { Application } from "../oauth2/application.ts"; import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { Attachment } from "./attachment.ts"; import { MessageActivity } from "./message_activity.ts"; import { MessageReference } from "./message_reference.ts"; @@ -12,6 +11,7 @@ import { MessageSticker } from "./message_sticker.ts"; import { DiscordMessageTypes } from "./message_types.ts"; import { DiscordReaction } from "./reaction.ts"; +/** https://discord.com/developers/docs/resources/channel#message-object */ export interface Message { /** id of the message */ id: string; @@ -83,6 +83,3 @@ export interface Message { /** Sent if the message is a response to an Interaction */ interaction?: MessageInteraction; } - -/** https://discord.com/developers/docs/resources/channel#message-object */ -export type DiscordMessage = SnakeCasedPropertiesDeep; diff --git a/src/types/messages/message_activity.ts b/src/types/messages/message_activity.ts index 6cadebd28..8feab94cf 100644 --- a/src/types/messages/message_activity.ts +++ b/src/types/messages/message_activity.ts @@ -1,12 +1,9 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { DiscordMessageActivityTypes } from "./message_activity_types.ts"; +/** https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure */ export interface MessageActivity { /** Type of message activity */ type: DiscordMessageActivityTypes; /** `party_id` from a Rich Presence event */ partyId?: string; } - -/** https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure */ -export type DiscordMessageActivity = SnakeCasedPropertiesDeep; diff --git a/src/types/messages/message_delete.ts b/src/types/messages/message_delete.ts index d292e9e62..222d0d8cf 100644 --- a/src/types/messages/message_delete.ts +++ b/src/types/messages/message_delete.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/topics/gateway#message-delete */ export interface MessageDelete { /** The id of the message */ id: string; @@ -8,6 +7,3 @@ export interface MessageDelete { /** The id of the guild */ guildId?: string; } - -/** https://discord.com/developers/docs/topics/gateway#message-delete */ -export type DiscordMessageDelete = SnakeCasedPropertiesDeep; diff --git a/src/types/messages/message_delete_bulk.ts b/src/types/messages/message_delete_bulk.ts index 9d1a0f163..e4994af86 100644 --- a/src/types/messages/message_delete_bulk.ts +++ b/src/types/messages/message_delete_bulk.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/topics/gateway#message-delete-bulk */ export interface MessageDeleteBulk { /** The ids of the messages */ ids: string[]; @@ -8,8 +7,3 @@ export interface MessageDeleteBulk { /** The id of the guild */ guildId?: string; } - -/** https://discord.com/developers/docs/topics/gateway#message-delete-bulk */ -export type DiscordMessageDeleteBulk = SnakeCasedPropertiesDeep< - MessageDeleteBulk ->; diff --git a/src/types/messages/message_get_reactions.ts b/src/types/messages/message_get_reactions.ts index 2a91ba4fb..615bfd030 100644 --- a/src/types/messages/message_get_reactions.ts +++ b/src/types/messages/message_get_reactions.ts @@ -1,9 +1,7 @@ +/** https://discord.com/developers/docs/resources/channel#get-reactions-query-string-params */ export interface GetReactions { /** Get users after this user Id */ after?: string; /** Max number of users to return (1-100) */ limit?: number; } - -/** https://discord.com/developers/docs/resources/channel#get-reactions-query-string-params */ -export type DiscordGetReactions = GetReactions; diff --git a/src/types/messages/message_reaction_add.ts b/src/types/messages/message_reaction_add.ts index af3530ff6..ef3709af3 100644 --- a/src/types/messages/message_reaction_add.ts +++ b/src/types/messages/message_reaction_add.ts @@ -1,7 +1,7 @@ import { Emoji } from "../emojis/emoji.ts"; import { GuildMemberWithUser } from "../guilds/guild_member.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; +/** https://discord.com/developers/docs/topics/gateway#message-reaction-add */ export interface MessageReactionAdd { /** The id of the user */ userId: string; @@ -16,8 +16,3 @@ export interface MessageReactionAdd { /** The emoji used to react */ emoji: Partial; } - -/** https://discord.com/developers/docs/topics/gateway#message-reaction-add */ -export type DiscordMessageReactionAdd = SnakeCasedPropertiesDeep< - MessageReactionAdd ->; diff --git a/src/types/messages/message_reaction_remove.ts b/src/types/messages/message_reaction_remove.ts index 8ffd7c996..1fa3f4ef8 100644 --- a/src/types/messages/message_reaction_remove.ts +++ b/src/types/messages/message_reaction_remove.ts @@ -1,9 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { MessageReactionAdd } from "./message_reaction_add.ts"; -export type MessageReactionRemove = Omit; - /** https://discord.com/developers/docs/topics/gateway#message-reaction-remove */ -export type DiscordMessageReactionRemove = SnakeCasedPropertiesDeep< - MessageReactionRemove ->; +export type MessageReactionRemove = Omit; diff --git a/src/types/messages/message_reaction_remove_all.ts b/src/types/messages/message_reaction_remove_all.ts index 6e7264889..b8f91f4bb 100644 --- a/src/types/messages/message_reaction_remove_all.ts +++ b/src/types/messages/message_reaction_remove_all.ts @@ -1,12 +1,7 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { MessageReactionAdd } from "./message_reaction_add.ts"; +/** https://discord.com/developers/docs/topics/gateway#message-reaction-remove-all */ export type MessageReactionRemoveAll = Pick< MessageReactionAdd, "channelId" | "messageId" | "guildId" >; - -/** https://discord.com/developers/docs/topics/gateway#message-reaction-remove-all */ -export type DiscordMessageReactionRemoveAll = SnakeCasedPropertiesDeep< - MessageReactionRemoveAll ->; diff --git a/src/types/messages/message_reaction_remove_emoji.ts b/src/types/messages/message_reaction_remove_emoji.ts index 6460ef99a..829bd0dae 100644 --- a/src/types/messages/message_reaction_remove_emoji.ts +++ b/src/types/messages/message_reaction_remove_emoji.ts @@ -1,12 +1,7 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { MessageReactionAdd } from "./message_reaction_add.ts"; +/** https://discord.com/developers/docs/topics/gateway#message-reaction-remove-emoji */ export type MessageReactionRemoveEmoji = Pick< MessageReactionAdd, "channelId" | "guildId" | "messageId" | "emoji" >; - -/** https://discord.com/developers/docs/topics/gateway#message-reaction-remove-emoji */ -export type DiscordMessageReactionRemoveEmoji = SnakeCasedPropertiesDeep< - MessageReactionRemoveEmoji ->; diff --git a/src/types/messages/message_reference.ts b/src/types/messages/message_reference.ts index ba2b143e8..7978e50cd 100644 --- a/src/types/messages/message_reference.ts +++ b/src/types/messages/message_reference.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure */ export interface MessageReference { /** id of the originating message */ messageId?: string; @@ -13,8 +12,3 @@ export interface MessageReference { /** When sending, whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message, default true */ failIfNotExists: boolean; } - -/** https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure */ -export type DiscordMessageReference = SnakeCasedPropertiesDeep< - MessageReference ->; diff --git a/src/types/messages/message_sticker.ts b/src/types/messages/message_sticker.ts index e7f3b2ff1..bcc369508 100644 --- a/src/types/messages/message_sticker.ts +++ b/src/types/messages/message_sticker.ts @@ -1,6 +1,6 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { DiscordMessageStickerFormatTypes } from "./message_sticker_format_types.ts"; +/** https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure */ export interface MessageSticker { /** id of the sticker */ id: string; @@ -25,6 +25,3 @@ export interface MessageSticker { /** Type of sticker format */ formatType: DiscordMessageStickerFormatTypes; } - -/** https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure */ -export type DiscordMessageSticker = SnakeCasedPropertiesDeep; diff --git a/src/types/messages/reaction.ts b/src/types/messages/reaction.ts index dbb30e28c..ff673f604 100644 --- a/src/types/messages/reaction.ts +++ b/src/types/messages/reaction.ts @@ -1,5 +1,6 @@ import { Emoji } from "../emojis/emoji.ts"; +/** https://discord.com/developers/docs/resources/channel#reaction-object */ export interface Reaction { /** Times this emoji has been used to react */ count: number; @@ -8,6 +9,3 @@ export interface Reaction { /** Emoji information */ emoji: Partial; } - -/** https://discord.com/developers/docs/resources/channel#reaction-object */ -export type DiscordReaction = Reaction; From bf32a1e7ffa75f42dbe1acdebd774c6b381d5694 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 19:43:06 +0200 Subject: [PATCH 55/78] wrong type --- src/types/messages/message.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types/messages/message.ts b/src/types/messages/message.ts index 8b16b5e90..5e7890a19 100644 --- a/src/types/messages/message.ts +++ b/src/types/messages/message.ts @@ -9,7 +9,7 @@ import { MessageActivity } from "./message_activity.ts"; import { MessageReference } from "./message_reference.ts"; import { MessageSticker } from "./message_sticker.ts"; import { DiscordMessageTypes } from "./message_types.ts"; -import { DiscordReaction } from "./reaction.ts"; +import { Reaction } from "./reaction.ts"; /** https://discord.com/developers/docs/resources/channel#message-object */ export interface Message { @@ -56,7 +56,7 @@ export interface Message { /** Any embedded content */ embeds: Embed[]; /** Reactions to the message */ - reactions?: DiscordReaction[]; + reactions?: Reaction[]; /** Used for validating a message was sent */ nonce?: number | string; /** Whether this message is pinned */ From fb5d0fa82e0ff35839aa94f73cbc099fbf228cf6 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 19:44:55 +0200 Subject: [PATCH 56/78] remove Discord* types for misc --- src/types/misc/activity.ts | 5 +---- src/types/misc/activity_assets.ts | 6 +----- src/types/misc/activity_button.ts | 6 ++---- src/types/misc/activity_emoji.ts | 4 +--- src/types/misc/activity_party.ts | 2 -- src/types/misc/activity_secrets.ts | 4 +--- src/types/misc/activity_timestamps.ts | 4 +--- src/types/misc/client_status.ts | 4 +--- src/types/misc/presence_update.ts | 5 +---- src/types/misc/typing_start.ts | 5 +---- 10 files changed, 10 insertions(+), 35 deletions(-) diff --git a/src/types/misc/activity.ts b/src/types/misc/activity.ts index abf020027..a56f6102d 100644 --- a/src/types/misc/activity.ts +++ b/src/types/misc/activity.ts @@ -1,4 +1,3 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { ActivityAssets } from "./activity_assets.ts"; import { ActivityButton } from "./activity_button.ts"; import { ActivityEmoji } from "./activity_emoji.ts"; @@ -7,6 +6,7 @@ import { ActivitySecrets } from "./activity_secrets.ts"; import { ActivityTimestamps } from "./activity_timestamps.ts"; import { DiscordActivityTypes } from "./activity_types.ts"; +/** https://discord.com/developers/docs/topics/gateway#activity-object */ export interface Activity { /** The activity's name */ name: string; @@ -39,6 +39,3 @@ export interface Activity { /** The custom buttons shown in the Rich Presence (max 2) */ buttons?: ActivityButton[]; } - -/** https://discord.com/developers/docs/topics/gateway#activity-object */ -export type DiscordActivity = SnakeCasedPropertiesDeep; diff --git a/src/types/misc/activity_assets.ts b/src/types/misc/activity_assets.ts index 84141aec5..41a742b17 100644 --- a/src/types/misc/activity_assets.ts +++ b/src/types/misc/activity_assets.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-assets */ export interface ActivityAssets { /** The id for a large asset of the activity, usually a snowflake */ largeImage?: string; @@ -10,6 +9,3 @@ export interface ActivityAssets { /** Text displayed when hovering over the small image of the activity */ smallText?: string; } - -/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-assets */ -export type DiscordActivityAssets = SnakeCasedPropertiesDeep; diff --git a/src/types/misc/activity_button.ts b/src/types/misc/activity_button.ts index 10e57fd72..7872c32e5 100644 --- a/src/types/misc/activity_button.ts +++ b/src/types/misc/activity_button.ts @@ -1,10 +1,8 @@ +// https://github.com/discord/discord-api-docs/pull/2219 +// TODO: add documentation link export interface ActivityButton { /** The text shown on the button (1-32 characters) */ label: string; /** The url opened when clicking the button (1-512 characters) */ url: string; } - -// https://github.com/discord/discord-api-docs/pull/2219 -// TODO: add documentation link -export type DiscordActivityButton = ActivityButton; diff --git a/src/types/misc/activity_emoji.ts b/src/types/misc/activity_emoji.ts index 8f9e6de77..3ca97ab3d 100644 --- a/src/types/misc/activity_emoji.ts +++ b/src/types/misc/activity_emoji.ts @@ -1,3 +1,4 @@ +/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-emoji */ export interface ActivityEmoji { /** The name of the emoji */ name: string; @@ -6,6 +7,3 @@ export interface ActivityEmoji { /** Whether this emoji is animated */ animated?: boolean; } - -/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-emoji */ -export type DiscordActivityEmoji = ActivityEmoji; diff --git a/src/types/misc/activity_party.ts b/src/types/misc/activity_party.ts index e3d53dba1..0a241f781 100644 --- a/src/types/misc/activity_party.ts +++ b/src/types/misc/activity_party.ts @@ -5,5 +5,3 @@ export interface ActivityParty { /** Used to show the party's current and maximum size */ size?: [currentSize: number, maxSize: number]; } - -export type DiscordActivityParty = ActivityParty; diff --git a/src/types/misc/activity_secrets.ts b/src/types/misc/activity_secrets.ts index b6d188eaa..e6d996a26 100644 --- a/src/types/misc/activity_secrets.ts +++ b/src/types/misc/activity_secrets.ts @@ -1,3 +1,4 @@ +/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-secrets */ export interface ActivitySecrets { /** The secret for joining a party */ join?: string; @@ -6,6 +7,3 @@ export interface ActivitySecrets { /** The secret for a specific instanced match */ match?: string; } - -/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-secrets */ -export type DiscordActivitySecrets = ActivitySecrets; diff --git a/src/types/misc/activity_timestamps.ts b/src/types/misc/activity_timestamps.ts index ac9bc3173..e60681c4b 100644 --- a/src/types/misc/activity_timestamps.ts +++ b/src/types/misc/activity_timestamps.ts @@ -1,9 +1,7 @@ +/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-timestamps */ export interface ActivityTimestamps { /** Unix time (in milliseconds) of when the activity started */ start?: number; /** Unix time (in milliseconds) of when the activity ends */ end?: number; } - -/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-timestamps */ -export type DiscordactivityTimestamps = ActivityTimestamps; diff --git a/src/types/misc/client_status.ts b/src/types/misc/client_status.ts index 52435ed89..6cf61c38f 100644 --- a/src/types/misc/client_status.ts +++ b/src/types/misc/client_status.ts @@ -1,3 +1,4 @@ +/** https://discord.com/developers/docs/topics/gateway#client-status-object */ export interface ClientStatus { /** The user's status set for an active desktop (Windows, Linux, Mac) application session */ desktop?: string; @@ -6,6 +7,3 @@ export interface ClientStatus { /** The user's status set for an active web (browser, bot account) application session */ web?: string; } - -/** https://discord.com/developers/docs/topics/gateway#client-status-object */ -export type DiscordClientStatus = ClientStatus; diff --git a/src/types/misc/presence_update.ts b/src/types/misc/presence_update.ts index dc7a30b1b..ca75d07b9 100644 --- a/src/types/misc/presence_update.ts +++ b/src/types/misc/presence_update.ts @@ -1,8 +1,8 @@ import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { Activity } from "./activity.ts"; import { ClientStatus } from "./client_status.ts"; +/** https://discord.com/developers/docs/topics/gateway#presence-update */ export interface PresenceUpdate { /** The user presence is being updated for */ user: User; @@ -15,6 +15,3 @@ export interface PresenceUpdate { /** User's platform-dependent status */ clientStatus: ClientStatus; } - -/** https://discord.com/developers/docs/topics/gateway#presence-update */ -export type DiscordPresenceUpdate = SnakeCasedPropertiesDeep; diff --git a/src/types/misc/typing_start.ts b/src/types/misc/typing_start.ts index 82f34f84d..4c23b7d2b 100644 --- a/src/types/misc/typing_start.ts +++ b/src/types/misc/typing_start.ts @@ -1,6 +1,6 @@ import { GuildMember } from "../guilds/guild_member.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; +/** https://discord.com/developers/docs/topics/gateway#typing-start */ export interface TypingStart { /** id of the channel */ channelId: string; @@ -13,6 +13,3 @@ export interface TypingStart { /** The member who started typing if this happened in a guild */ member?: GuildMember; } - -/** https://discord.com/developers/docs/topics/gateway#typing-start */ -export type DiscordTypingStart = SnakeCasedPropertiesDeep; From 628acfce6876ddc9d34b446032a800d5689c237e Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 19:45:23 +0200 Subject: [PATCH 57/78] remove Discord* types for oauth2 --- src/types/oauth2/application.ts | 5 +---- src/types/oauth2/bot_auth_query.ts | 7 +------ src/types/oauth2/get_current_authorization_information.ts | 7 +------ 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/types/oauth2/application.ts b/src/types/oauth2/application.ts index 43b71a119..0febc1ebc 100644 --- a/src/types/oauth2/application.ts +++ b/src/types/oauth2/application.ts @@ -1,8 +1,8 @@ import { Team } from "../teams/team.ts"; import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { DiscordApplicationFlags } from "./application_flags.ts"; +/** https://discord.com/developers/docs/topics/oauth2#application-object */ export interface Application { /** The id of the app */ id: string; @@ -41,6 +41,3 @@ export interface Application { /** The application's public flags */ flags: DiscordApplicationFlags; } - -/** https://discord.com/developers/docs/topics/oauth2#application-object */ -export type DiscordApplication = SnakeCasedPropertiesDeep; diff --git a/src/types/oauth2/bot_auth_query.ts b/src/types/oauth2/bot_auth_query.ts index 90137da04..301d6fb8a 100644 --- a/src/types/oauth2/bot_auth_query.ts +++ b/src/types/oauth2/bot_auth_query.ts @@ -1,6 +1,6 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { DiscordOAuth2Scopes } from "./scopes.ts"; +/** https://discord.com/developers/docs/topics/oauth2#bot-authorization-flow-bot-auth-parameters */ export interface BotAuthenticationFlowQuery { /** App's client id */ clientId: string; @@ -13,8 +13,3 @@ export interface BotAuthenticationFlowQuery { /** True or false—disallows the user from changing the guild dropdown */ disableGuildSelect: boolean; } - -/** https://discord.com/developers/docs/topics/oauth2#bot-authorization-flow-bot-auth-parameters */ -export type DiscordBotAuthenticationFlowQuery = SnakeCasedPropertiesDeep< - BotAuthenticationFlowQuery ->; diff --git a/src/types/oauth2/get_current_authorization_information.ts b/src/types/oauth2/get_current_authorization_information.ts index 0a8009c16..a56cc6ea2 100644 --- a/src/types/oauth2/get_current_authorization_information.ts +++ b/src/types/oauth2/get_current_authorization_information.ts @@ -1,8 +1,8 @@ import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { Application } from "./application.ts"; import { DiscordOAuth2Scopes } from "./scopes.ts"; +/** https://discord.com/developers/docs/topics/oauth2#get-current-authorization-information-response-structure */ export interface GetCurrentAuthorizationInformation { /** The current application */ application: Partial; @@ -13,8 +13,3 @@ export interface GetCurrentAuthorizationInformation { /** The user who has authorized, if the user has authorized with the `identify` scope */ user?: User; } - -/** https://discord.com/developers/docs/topics/oauth2#get-current-authorization-information-response-structure */ -export type DiscordGetCurrentAuthoriationInformation = SnakeCasedPropertiesDeep< - GetCurrentAuthorizationInformation ->; From c55fa127fd924030e2d5f8d5eb442bce7b33a920 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 19:45:52 +0200 Subject: [PATCH 58/78] remove Discord* types for permissions --- src/types/permissions/role.ts | 5 +---- src/types/permissions/role_tags.ts | 6 +----- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/types/permissions/role.ts b/src/types/permissions/role.ts index 7aa92fdb0..4191c3b20 100644 --- a/src/types/permissions/role.ts +++ b/src/types/permissions/role.ts @@ -1,6 +1,6 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { RoleTags } from "./role_tags.ts"; +/** https://discord.com/developers/docs/topics/permissions#role-object-role-structure */ export interface Role { /** Role id */ id: string; @@ -21,6 +21,3 @@ export interface Role { /** The tags this role has */ tags?: RoleTags; } - -/** https://discord.com/developers/docs/topics/permissions#role-object-role-structure */ -export type DiscordRole = SnakeCasedPropertiesDeep; diff --git a/src/types/permissions/role_tags.ts b/src/types/permissions/role_tags.ts index 4b2e31d0d..1bb175277 100644 --- a/src/types/permissions/role_tags.ts +++ b/src/types/permissions/role_tags.ts @@ -1,5 +1,4 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; - +/** https://discord.com/developers/docs/topics/permissions#role-object-role-tags-structure */ export interface RoleTags { /** The id of the bot this role belongs to */ botId?: string; @@ -8,6 +7,3 @@ export interface RoleTags { /** Whether this is the guild's premium subscriber role */ premiumSubscriber?: null; } - -/** https://discord.com/developers/docs/topics/permissions#role-object-role-tags-structure */ -export type DiscordRoleTags = SnakeCasedPropertiesDeep; From a8f76d0461d232a8f8ee12c1d884f59249e61855 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 19:46:12 +0200 Subject: [PATCH 59/78] remove Discord* types for teams --- src/types/teams/team.ts | 5 +---- src/types/teams/team_member.ts | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/types/teams/team.ts b/src/types/teams/team.ts index 1174cfd0a..bff45924c 100644 --- a/src/types/teams/team.ts +++ b/src/types/teams/team.ts @@ -1,6 +1,6 @@ -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { TeamMember } from "./team_member.ts"; +/** https://discord.com/developers/docs/topics/teams#data-models-team-object */ export interface Team { /** A hash of the image of the team's icon */ icon: string | null; @@ -11,6 +11,3 @@ export interface Team { /** The user id of the current team owner */ ownerUserId: string; } - -/** https://discord.com/developers/docs/topics/teams#data-models-team-object */ -export type DiscordTeam = SnakeCasedPropertiesDeep; diff --git a/src/types/teams/team_member.ts b/src/types/teams/team_member.ts index f3249bdbd..5191e1dba 100644 --- a/src/types/teams/team_member.ts +++ b/src/types/teams/team_member.ts @@ -1,7 +1,7 @@ import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; import { DiscordTeamMembershipStates } from "./team_membership_states.ts"; +/** https://discord.com/developers/docs/topics/teams#data-models-team-members-object */ export interface TeamMember { /** The user's membership state on the team */ membershipState: DiscordTeamMembershipStates; @@ -14,6 +14,3 @@ export interface TeamMember { & Partial & Pick; } - -/** https://discord.com/developers/docs/topics/teams#data-models-team-members-object */ -export type DiscordTeamMember = SnakeCasedPropertiesDeep; From 1f8b7930bd59833993740c75737cbc11287e7f70 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 30 Apr 2021 19:46:37 +0200 Subject: [PATCH 60/78] remove Discord* types for templates --- src/types/templates/create_guild_from_template.ts | 4 +--- src/types/templates/modify_guild_template.ts | 4 +--- src/types/templates/template.ts | 5 +---- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/types/templates/create_guild_from_template.ts b/src/types/templates/create_guild_from_template.ts index 5f2ec272a..cf2a059ed 100644 --- a/src/types/templates/create_guild_from_template.ts +++ b/src/types/templates/create_guild_from_template.ts @@ -1,9 +1,7 @@ +/** https://discord.com/developers/docs/resources/template#create-guild-from-template-json-params */ export interface CreateGuildFromTemplate { /** Name of the guild (2-100 characters) */ name: string; /** base64 128x128 image for the guild icon */ icon?: string; } - -/** https://discord.com/developers/docs/resources/template#create-guild-from-template-json-params */ -export type DiscordCreateGuildFromTemplate = CreateGuildFromTemplate; diff --git a/src/types/templates/modify_guild_template.ts b/src/types/templates/modify_guild_template.ts index 892c3cf44..664fb150f 100644 --- a/src/types/templates/modify_guild_template.ts +++ b/src/types/templates/modify_guild_template.ts @@ -1,9 +1,7 @@ +/** https://discord.com/developers/docs/resources/template#modify-guild-template */ export interface ModifyGuildTemplate { /** Name of the template (1-100 characters) */ name?: string; /** Description of the template (0-120 characters) */ description?: string | null; } - -/** https://discord.com/developers/docs/resources/template#modify-guild-template */ -export type DiscordModifyGuildTemplate = ModifyGuildTemplate; diff --git a/src/types/templates/template.ts b/src/types/templates/template.ts index 2e4920e9a..12bd382ff 100644 --- a/src/types/templates/template.ts +++ b/src/types/templates/template.ts @@ -1,7 +1,7 @@ import { Guild } from "../guilds/guild.ts"; import { User } from "../users/user.ts"; -import { SnakeCasedPropertiesDeep } from "../util.ts"; +/** https://discord.com/developers/docs/resources/template#template-object-template-structure */ export interface Template { /** The template code (unique Id) */ code: string; @@ -26,6 +26,3 @@ export interface Template { /** Whether the template has unsynced changes */ isDirty: boolean | null; } - -/** https://discord.com/developers/docs/resources/template#template-object-template-structure */ -export type DiscordTemplate = SnakeCasedPropertiesDeep