Merge branch 'main' of https://github.com/discordeno/discordeno into buttons-dropdowns

This commit is contained in:
Skillz
2021-05-01 08:20:04 -04:00
237 changed files with 630 additions and 997 deletions
+1 -1
View File
@@ -1 +1 @@
* @ayntee @Skillz4Killz @itohatweb * @Skillz4Killz @itohatweb
+1 -1
View File
@@ -17,7 +17,7 @@ jobs:
- name: Cache dependencies - name: Cache dependencies
run: deno cache --no-check mod.ts run: deno cache --no-check mod.ts
- name: Run test script for maintainers - name: Run test script for maintainers
if: ${{ github.actor == 'ayntee' || github.actor == 'Skillz4Killz' || github.actor == 'itohatweb' }} if: ${{ github.actor == 'Skillz4Killz' || github.actor == 'itohatweb' }}
run: deno test --unstable --coverage=coverage -A --no-check tests/mod.ts run: deno test --unstable --coverage=coverage -A --no-check tests/mod.ts
- name: Run test script if label added - name: Run test script if label added
if: ${{ github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == 'run-tests' }} if: ${{ github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == 'run-tests' }}
+1
View File
@@ -6,6 +6,7 @@ export * from "./src/rest/mod.ts";
export * from "./src/structures/channel.ts"; export * from "./src/structures/channel.ts";
export * from "./src/structures/guild.ts"; export * from "./src/structures/guild.ts";
export * from "./src/structures/member.ts"; export * from "./src/structures/member.ts";
export * from "./src/structures/message.ts";
export * from "./src/structures/mod.ts"; export * from "./src/structures/mod.ts";
export * from "./src/structures/role.ts"; export * from "./src/structures/role.ts";
export * from "./src/types/mod.ts"; export * from "./src/types/mod.ts";
+32 -19
View File
@@ -65,31 +65,42 @@ 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. * 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) { export async function startBigBrainBot(options: BigBrainBotConfig) {
if (data.secretKey) secretKey = data.secretKey; rest.token = `Bot ${options.token}`;
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) {
ws.identifyPayload.compress = data.compress;
}
ws.identifyPayload.intents = data.intents.reduce( if (options.secretKey) secretKey = options.secretKey;
( if (options.restURL) baseEndpoints.BASE_URL = options.restURL;
bits, if (options.cdnURL) baseEndpoints.CDN_URL = options.cdnURL;
next, if (options.eventHandlers) eventHandlers = options.eventHandlers;
) => (bits |= typeof next === "string"
? DiscordGatewayIntents[next]
: next),
0,
);
// PROXY DOESNT NEED US SPAWNING SHARDS // PROXY DOESNT NEED US SPAWNING SHARDS
if (!data.wsPort) { if (!options.wsPort) {
ws.identifyPayload.token = `Bot ${options.token}`;
if (options.compress) {
ws.identifyPayload.compress = options.compress;
}
ws.identifyPayload.intents = options.intents.reduce(
(
bits,
next,
) => (bits |= typeof next === "string"
? DiscordGatewayIntents[next]
: next),
0,
);
// Initial API connection to get info about bots connection // Initial API connection to get info about bots connection
ws.botGatewayData = await getGatewayBot(); ws.botGatewayData = await getGatewayBot();
ws.maxShards = ws.maxShards ||
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; proxyWSURL = ws.botGatewayData.url;
ws.spawnShards(data.firstShardId);
ws.spawnShards(options.firstShardId);
} }
} }
@@ -105,6 +116,8 @@ export interface BigBrainBotConfig extends BotConfig {
firstShardId: number; firstShardId: number;
/** The last shard to start for this worker. By default it will be 25 + the firstShardId. */ /** The last shard to start for this worker. By default it will be 25 + the firstShardId. */
lastShardId?: number; 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. */ /** This can be used to forward the ws handling to a proxy. It will disable the sharding done by the bot side. */
wsPort?: number; wsPort?: number;
/** This can be used to forward the REST handling to a proxy. */ /** This can be used to forward the REST handling to a proxy. */
+3 -8
View File
@@ -2,16 +2,11 @@ import { eventHandlers } from "../../bot.ts";
import { cacheHandlers } from "../../cache.ts"; import { cacheHandlers } from "../../cache.ts";
import { structures } from "../../structures/mod.ts"; import { structures } from "../../structures/mod.ts";
import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
import { import { VoiceState } from "../../types/voice/voice_state.ts";
DiscordVoiceState,
VoiceState,
} from "../../types/voice/voice_state.ts";
import { snakeKeysToCamelCase } from "../../util/utils.ts";
export async function handleVoiceStateUpdate(data: DiscordGatewayPayload) { export async function handleVoiceStateUpdate(data: DiscordGatewayPayload) {
const payload = snakeKeysToCamelCase<VoiceState>( const payload = data.d as VoiceState;
data.d as DiscordVoiceState,
);
if (!payload.guildId) return; if (!payload.guildId) return;
const guild = await cacheHandlers.get("guilds", payload.guildId); const guild = await cacheHandlers.get("guilds", payload.guildId);
+2 -2
View File
@@ -29,8 +29,8 @@ export async function cloneChannel(channelId: string, reason?: string) {
) => ({ ) => ({
id: overwrite.id, id: overwrite.id,
type: overwrite.type, type: overwrite.type,
allow: calculatePermissions(BigInt(overwrite.allow)), allow: calculatePermissions(overwrite.allow),
deny: calculatePermissions(BigInt(overwrite.deny)), deny: calculatePermissions(overwrite.deny),
})), })),
}; };
@@ -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 { 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(
guildId: string,
options: { id: string; permissions: ApplicationCommandPermissions[] }[],
) {
return await rest.runMethod(
"put",
endpoints.COMMANDS_PERMISSIONS(applicationId, guildId),
camelKeysToSnakeCase(options),
);
}
+1 -1
View File
@@ -21,7 +21,7 @@ import {
*/ */
export async function createSlashCommand( export async function createSlashCommand(
options: CreateGlobalApplicationCommand, options: CreateGlobalApplicationCommand,
guildId: string, guildId?: string,
) { ) {
validateSlashCommands([options], true); validateSlashCommands([options], true);
@@ -0,0 +1,18 @@
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(
guildId: string,
commandId: string,
options: ApplicationCommandPermissions[],
) {
return await rest.runMethod(
"put",
endpoints.COMMANDS_PERMISSION(applicationId, guildId, commandId),
{ permissions: camelKeysToSnakeCase(options) },
);
}
@@ -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<GuildApplicationCommandPermissions>(
"get",
endpoints.COMMANDS_PERMISSION(applicationId, guildId, commandId),
);
}
@@ -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<GuildApplicationCommandPermissions[]>(
"get",
endpoints.COMMANDS_PERMISSIONS(applicationId, guildId),
);
}
@@ -1,9 +1,9 @@
import { rest } from "../../rest/rest.ts"; import { rest } from "../../rest/rest.ts";
import { DiscordValidateDiscoverySearchTerm } from "../../types/discovery/validate_discovery_search_term.ts"; import { ValidateDiscoverySearchTerm } from "../../types/discovery/validate_discovery_search_term.ts";
import { endpoints } from "../../util/constants.ts"; import { endpoints } from "../../util/constants.ts";
export async function validDiscoveryTerm(term: string) { export async function validDiscoveryTerm(term: string) {
const result = await rest.runMethod<DiscordValidateDiscoverySearchTerm>( const result = await rest.runMethod<ValidateDiscoverySearchTerm>(
"get", "get",
endpoints.DISCOVERY_VALID_TERM, endpoints.DISCOVERY_VALID_TERM,
{ term }, { term },
@@ -1,9 +1,8 @@
import { rest } from "../../rest/rest.ts"; import { rest } from "../../rest/rest.ts";
import { endpoints } from "../../util/constants.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. /** 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) {
export async function deleteServer(guildId: string) {
return await rest.runMethod<undefined>( return await rest.runMethod<undefined>(
"delete", "delete",
endpoints.GUILDS_BASE(guildId), endpoints.GUILDS_BASE(guildId),
+1 -1
View File
@@ -12,5 +12,5 @@ export async function getWidget(guildId: string, options?: { force: boolean }) {
if (!guild?.widgetEnabled) throw new Error(Errors.GUILD_WIDGET_NOT_ENABLED); if (!guild?.widgetEnabled) throw new Error(Errors.GUILD_WIDGET_NOT_ENABLED);
} }
return await rest.runMethod("get", `${endpoints.GUILD_WIDGET(guildId)}.json`) as GuildWidgetDetails; return await rest.runMethod<GuildWidgetDetails>("get", `${endpoints.GUILD_WIDGET(guildId)}.json`);
} }
+21 -19
View File
@@ -1,8 +1,11 @@
import { cache } from "../../cache.ts";
import { DiscordenoMember } from "../../structures/member.ts"; import { DiscordenoMember } from "../../structures/member.ts";
import { DiscordGatewayOpcodes } from "../../types/codes/gateway_opcodes.ts";
import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.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 { Errors } from "../../types/misc/errors.ts";
import { Collection } from "../../util/collection.ts"; import { Collection } from "../../util/collection.ts";
import { sendShardMessage } from "../../ws/send_shard_message.ts";
import { ws } from "../../ws/ws.ts"; import { ws } from "../../ws/ws.ts";
/** /**
@@ -16,12 +19,12 @@ import { ws } from "../../ws/ws.ts";
export function fetchMembers( export function fetchMembers(
guildId: string, guildId: string,
shardId: number, shardId: number,
options?: RequestGuildMembers, options?: Omit<RequestGuildMembers, "guildId">,
) { ) {
// You can request 1 member without the intent // You can request 1 member without the intent
if ( if (
(!options?.limit || options.limit > 1) && (!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); throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
} }
@@ -31,21 +34,20 @@ export function fetchMembers(
} }
return new Promise((resolve) => { 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<Collection<string, DiscordenoMember>>; }) as Promise<Collection<string, DiscordenoMember>>;
} }
// TODO: finish implementing this
function requestAllMembers(
_guildId: string,
_shardId: number,
_resolve: (
value:
| Collection<string, DiscordenoMember>
| PromiseLike<Collection<string, DiscordenoMember>>,
) => void,
// deno-lint-ignore no-explicit-any
_options: any,
): void {
throw new Error("Function not implemented.");
}
+11 -6
View File
@@ -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 * 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. * 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)) { if (!(ws.identifyPayload.intents && DiscordGatewayIntents.GUILD_MEMBERS)) {
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS); throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
} }
@@ -61,11 +64,13 @@ export async function getMembers(guildId: string, options?: ListGuildMembers) {
guildId, guildId,
); );
await cacheHandlers.set( if (options?.addToCache !== false) {
"members", await cacheHandlers.set(
discordenoMember.id, "members",
discordenoMember, discordenoMember.id,
); discordenoMember,
);
}
return discordenoMember; return discordenoMember;
}), }),
@@ -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<Collection<string, DiscordenoMember>>;
}
// TODO: implement this
function requestAllMembers(
_id: string,
_shardId: number,
_resolve: (
value:
| Collection<string, DiscordenoMember>
| PromiseLike<Collection<string, DiscordenoMember>>,
) => void,
_arg3: { query: string; limit: number },
): void {
throw new Error("Function not implemented.");
}
+15 -2
View File
@@ -1,12 +1,18 @@
import { rest } from "../../rest/rest.ts"; import { rest } from "../../rest/rest.ts";
import { endpoints } from "../../util/constants.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( export async function removeReaction(
channelId: string, channelId: string,
messageId: string, messageId: string,
reaction: string, reaction: string,
options?: { userId?: string },
) { ) {
if (options?.userId) {
await requireBotChannelPermissions(channelId, ["MANAGE_MESSAGES"]);
}
if (reaction.startsWith("<:")) { if (reaction.startsWith("<:")) {
reaction = reaction.substring(2, reaction.length - 1); reaction = reaction.substring(2, reaction.length - 1);
} else if (reaction.startsWith("<a:")) { } else if (reaction.startsWith("<a:")) {
@@ -15,6 +21,13 @@ export async function removeReaction(
return await rest.runMethod<undefined>( return await rest.runMethod<undefined>(
"delete", "delete",
endpoints.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction), options?.userId
? endpoints.CHANNEL_MESSAGE_REACTION_USER(
channelId,
messageId,
reaction,
options.userId,
)
: endpoints.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction),
); );
} }
@@ -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("<a:")) {
reaction = reaction.substring(3, reaction.length - 1);
}
return await rest.runMethod<undefined>(
"delete",
endpoints.CHANNEL_MESSAGE_REACTION_USER(
channelId,
messageId,
reaction,
userId,
),
);
}
+2 -2
View File
@@ -5,7 +5,7 @@ import { DiscordChannelTypes } from "../../types/channels/channel_types.ts";
import { DiscordAllowedMentionsTypes } from "../../types/messages/allowed_mentions_types.ts"; import { DiscordAllowedMentionsTypes } from "../../types/messages/allowed_mentions_types.ts";
import { ButtonStyles } from "../../types/messages/components/button_styles.ts"; import { ButtonStyles } from "../../types/messages/components/button_styles.ts";
import { CreateMessage } from "../../types/messages/create_message.ts"; import { CreateMessage } from "../../types/messages/create_message.ts";
import { DiscordMessage, Message } from "../../types/messages/message.ts"; import { Message } from "../../types/messages/message.ts";
import { Errors } from "../../types/misc/errors.ts"; import { Errors } from "../../types/misc/errors.ts";
import { PermissionStrings } from "../../types/permissions/permission_strings.ts"; import { PermissionStrings } from "../../types/permissions/permission_strings.ts";
import { endpoints } from "../../util/constants.ts"; import { endpoints } from "../../util/constants.ts";
@@ -153,7 +153,7 @@ export async function sendMessage(
const result = await rest.runMethod<Message>( const result = await rest.runMethod<Message>(
"post", "post",
endpoints.CHANNEL_MESSAGES(channelId), endpoints.CHANNEL_MESSAGES(channelId),
camelKeysToSnakeCase<DiscordMessage>({ camelKeysToSnakeCase({
...content, ...content,
...(content.messageReference?.messageId ...(content.messageReference?.messageId
? { ? {
+2 -2
View File
@@ -1,6 +1,7 @@
import { eventHandlers } from "../../bot.ts"; import { eventHandlers } from "../../bot.ts";
import { DiscordGatewayOpcodes } from "../../types/codes/gateway_opcodes.ts"; import { DiscordGatewayOpcodes } from "../../types/codes/gateway_opcodes.ts";
import type { StatusUpdate } from "../../types/gateway/status_update.ts"; import type { StatusUpdate } from "../../types/gateway/status_update.ts";
import { sendShardMessage } from "../../ws/send_shard_message.ts";
import { ws } from "../../ws/ws.ts"; import { ws } from "../../ws/ws.ts";
export function editBotStatus(data: Omit<StatusUpdate, "afk" | "since">) { export function editBotStatus(data: Omit<StatusUpdate, "afk" | "since">) {
@@ -10,7 +11,7 @@ export function editBotStatus(data: Omit<StatusUpdate, "afk" | "since">) {
`Running forEach loop in editBotStatus function.`, `Running forEach loop in editBotStatus function.`,
); );
shard.queue.push({ sendShardMessage(shard, {
op: DiscordGatewayOpcodes.StatusUpdate, op: DiscordGatewayOpcodes.StatusUpdate,
d: { d: {
since: null, since: null,
@@ -18,6 +19,5 @@ export function editBotStatus(data: Omit<StatusUpdate, "afk" | "since">) {
...data, ...data,
}, },
}); });
ws.processQueue(shard.id);
}); });
} }
+19 -14
View File
@@ -13,15 +13,24 @@ import { getPins } from "./channels/get_pins.ts";
import { isChannelSynced } from "./channels/is_channel_synced.ts"; import { isChannelSynced } from "./channels/is_channel_synced.ts";
import { startTyping } from "./channels/start_typing.ts"; import { startTyping } from "./channels/start_typing.ts";
import { swapChannels } from "./channels/swap_channels.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 { createSlashCommand } from "./commands/create_slash_command.ts";
import { deleteSlashCommand } from "./commands/delete_slash_command.ts"; import { deleteSlashCommand } from "./commands/delete_slash_command.ts";
import { deleteSlashResponse } from "./commands/delete_slash_response.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 { editSlashResponse } from "./commands/edit_slash_response.ts";
import { getSlashCommand } from "./commands/get_slash_command.ts"; import { getSlashCommand } from "./commands/get_slash_command.ts";
import { getSlashCommands } from "./commands/get_slash_commands.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 { sendInteractionResponse } from "./commands/send_interaction_response.ts";
import { upsertSlashCommand } from "./commands/upsert_slash_command.ts"; import { upsertSlashCommand } from "./commands/upsert_slash_command.ts";
import { upsertSlashCommands } from "./commands/upsert_slash_commands.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 { createEmoji } from "./emojis/create_emoji.ts";
import { deleteEmoji } from "./emojis/delete_emoji.ts"; import { deleteEmoji } from "./emojis/delete_emoji.ts";
import { editEmoji } from "./emojis/edit_emoji.ts"; import { editEmoji } from "./emojis/edit_emoji.ts";
@@ -29,7 +38,7 @@ import { emojiURL } from "./emojis/emoji_url.ts";
import { getEmoji } from "./emojis/get_emoji.ts"; import { getEmoji } from "./emojis/get_emoji.ts";
import { getEmojis } from "./emojis/get_emojis.ts"; import { getEmojis } from "./emojis/get_emojis.ts";
import { createGuild } from "./guilds/create_guild.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 { editGuild } from "./guilds/edit_guild.ts";
import { editWelcomeScreen } from "./guilds/edit_welcome_screen.ts"; import { editWelcomeScreen } from "./guilds/edit_welcome_screen.ts";
import { editWidget } from "./guilds/edit_widget.ts"; import { editWidget } from "./guilds/edit_widget.ts";
@@ -66,7 +75,6 @@ import { editMember } from "./members/edit_member.ts";
import { fetchMembers } from "./members/fetch_members.ts"; import { fetchMembers } from "./members/fetch_members.ts";
import { getMember } from "./members/get_member.ts"; import { getMember } from "./members/get_member.ts";
import { getMembers } from "./members/get_members.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 { kick, kickMember } from "./members/kick_member.ts";
import { moveMember } from "./members/move_member.ts"; import { moveMember } from "./members/move_member.ts";
import { pruneMembers } from "./members/prune_members.ts"; import { pruneMembers } from "./members/prune_members.ts";
@@ -85,7 +93,6 @@ import { publishMessage } from "./messages/publish_message.ts";
import { removeAllReactions } from "./messages/remove_all_reactions.ts"; import { removeAllReactions } from "./messages/remove_all_reactions.ts";
import { removeReaction } from "./messages/remove_reaction.ts"; import { removeReaction } from "./messages/remove_reaction.ts";
import { removeReactionEmoji } from "./messages/remove_reaction_emoji.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 { sendMessage } from "./messages/send_message.ts";
import { unpin, unpinMessage } from "./messages/unpin_message.ts"; import { unpin, unpinMessage } from "./messages/unpin_message.ts";
import { editBotStatus } from "./misc/edit_bot_status.ts"; import { editBotStatus } from "./misc/edit_bot_status.ts";
@@ -115,11 +122,6 @@ import { executeWebhook } from "./webhooks/execute_webhook.ts";
import { getWebhook } from "./webhooks/get_webhook.ts"; import { getWebhook } from "./webhooks/get_webhook.ts";
import { getWebhooks } from "./webhooks/get_webhooks.ts"; import { getWebhooks } from "./webhooks/get_webhooks.ts";
import { getWebhookWithToken } from "./webhooks/get_webhook_with_token.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";
export { export {
addDiscoverySubcategory, addDiscoverySubcategory,
@@ -129,6 +131,7 @@ export {
avatarURL, avatarURL,
ban, ban,
banMember, banMember,
batchEditSlashCommandPermissions,
categoryChildren, categoryChildren,
channelOverwriteHasPermission, channelOverwriteHasPermission,
createChannel, createChannel,
@@ -143,13 +146,13 @@ export {
deleteChannel, deleteChannel,
deleteChannelOverwrite, deleteChannelOverwrite,
deleteEmoji, deleteEmoji,
deleteGuild,
deleteGuildTemplate, deleteGuildTemplate,
deleteIntegration, deleteIntegration,
deleteInvite, deleteInvite,
deleteMessage, deleteMessage,
deleteMessages, deleteMessages,
deleteRole, deleteRole,
deleteServer,
deleteSlashCommand, deleteSlashCommand,
deleteSlashResponse, deleteSlashResponse,
deleteWebhook, deleteWebhook,
@@ -198,7 +201,6 @@ export {
getInvites, getInvites,
getMember, getMember,
getMembers, getMembers,
getMembersByQuery,
getMessage, getMessage,
getMessages, getMessages,
getPins, getPins,
@@ -206,6 +208,8 @@ export {
getReactions, getReactions,
getRoles, getRoles,
getSlashCommand, getSlashCommand,
getSlashCommandPermission,
getSlashCommandPermissions,
getSlashCommands, getSlashCommands,
getTemplate, getTemplate,
getUser, getUser,
@@ -235,7 +239,6 @@ export {
removeReaction, removeReaction,
removeReactionEmoji, removeReactionEmoji,
removeRole, removeRole,
removeUserReaction,
sendDirectMessage, sendDirectMessage,
sendInteractionResponse, sendInteractionResponse,
sendMessage, sendMessage,
@@ -272,6 +275,10 @@ export let helpers = {
deleteSlashCommand, deleteSlashCommand,
deleteSlashResponse, deleteSlashResponse,
editSlashResponse, editSlashResponse,
getSlashCommandPermission,
getSlashCommandPermissions,
batchEditSlashCommandPermissions,
editSlashCommandPermissions,
sendInteractionResponse, sendInteractionResponse,
getSlashCommand, getSlashCommand,
getSlashCommands, getSlashCommands,
@@ -286,7 +293,7 @@ export let helpers = {
// guilds // guilds
categoryChildren, categoryChildren,
createGuild, createGuild,
deleteServer, deleteGuild,
editGuild, editGuild,
editWidget, editWidget,
editWelcomeScreen, editWelcomeScreen,
@@ -332,7 +339,6 @@ export let helpers = {
editMember, editMember,
fetchMembers, fetchMembers,
getMember, getMember,
getMembersByQuery,
getMembers, getMembers,
kickMember, kickMember,
moveMember, moveMember,
@@ -353,7 +359,6 @@ export let helpers = {
removeAllReactions, removeAllReactions,
removeReactionEmoji, removeReactionEmoji,
removeReaction, removeReaction,
removeUserReaction,
sendMessage, sendMessage,
unpinMessage, unpinMessage,
// misc // misc
+3 -3
View File
@@ -1,6 +1,6 @@
import { botId, eventHandlers } from "../bot.ts"; import { botId, eventHandlers } from "../bot.ts";
import { cache, cacheHandlers } from "../cache.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 { editGuild } from "../helpers/guilds/edit_guild.ts";
import { getAuditLogs } from "../helpers/guilds/get_audit_logs.ts"; import { getAuditLogs } from "../helpers/guilds/get_audit_logs.ts";
import { getBan } from "../helpers/guilds/get_ban.ts"; import { getBan } from "../helpers/guilds/get_ban.ts";
@@ -79,7 +79,7 @@ const baseGuild: Partial<DiscordenoGuild> = {
return guildSplashURL(this.id!, this.splash!, size, format); return guildSplashURL(this.id!, this.splash!, size, format);
}, },
delete() { delete() {
return deleteServer(this.id!); return deleteGuild(this.id!);
}, },
edit(options) { edit(options) {
return editGuild(this.id!, options); return editGuild(this.id!, options);
@@ -272,7 +272,7 @@ export interface DiscordenoGuild extends
format?: DiscordImageFormat, format?: DiscordImageFormat,
): string | undefined; ): string | undefined;
/** Delete a guild permanently. User must be owner. Returns 204 No Content on success. Fires a Guild Delete Gateway event. */ /** Delete a guild permanently. User must be owner. Returns 204 No Content on success. Fires a Guild Delete Gateway event. */
delete(): ReturnType<typeof deleteServer>; delete(): ReturnType<typeof deleteGuild>;
/** Leave a guild */ /** Leave a guild */
leave(): ReturnType<typeof leaveGuild>; leave(): ReturnType<typeof leaveGuild>;
/** Edit the server. Requires the MANAGE_GUILD permission. */ /** Edit the server. Requires the MANAGE_GUILD permission. */
+15 -7
View File
@@ -121,8 +121,8 @@ const baseMessage: Partial<DiscordenoMessage> = {
removeReactionEmoji(reaction) { removeReactionEmoji(reaction) {
return removeReactionEmoji(this.channelId!, this.id!, reaction); return removeReactionEmoji(this.channelId!, this.id!, reaction);
}, },
removeReaction(reaction) { removeReaction(reaction, userId) {
return removeReaction(this.channelId!, this.id!, reaction); return removeReaction(this.channelId!, this.id!, reaction, { userId });
}, },
}; };
@@ -155,6 +155,7 @@ export async function createDiscordenoMessage(data: Message) {
...props, ...props,
/** The message id of the original message if this message was sent as a reply. If null, the original message was deleted. */ /** 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), channelId: createNewProp(channelId),
content: createNewProp(data.content || ""),
guildId: createNewProp(guildIdFinal), guildId: createNewProp(guildIdFinal),
mentionedUserIds: createNewProp(mentions.map((m) => m.id)), mentionedUserIds: createNewProp(mentions.map((m) => m.id)),
mentionedRoleIds: createNewProp(mentionRoles), mentionedRoleIds: createNewProp(mentionRoles),
@@ -177,8 +178,12 @@ export async function createDiscordenoMessage(data: Message) {
} }
export interface DiscordenoMessage export interface DiscordenoMessage
extends Omit<Message, "timestamp" | "editedTimestamp"> { extends Omit<Message, "timestamp" | "editedTimestamp" | "guildId"> {
// For better user experience // 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 */ /** Ids of users specifically mentioned in the message */
mentionedUserIds: string[]; mentionedUserIds: string[];
/** Ids of roles specifically mentioned in this message */ /** Ids of roles specifically mentioned in this message */
@@ -245,10 +250,13 @@ export interface DiscordenoMessage
timeout?: number, timeout?: number,
reason?: string, reason?: string,
): Promise<unknown>; ): Promise<unknown>;
/** Remove all reactions */ /** Removes all reactions for all emojis on this message */
removeAllReactions(): ReturnType<typeof removeAllReactions>; removeAllReactions(): ReturnType<typeof removeAllReactions>;
/** Remove all reactions */ /** Removes all reactions for a single emoji on this message */
removeReactionEmoji(reaction: string): ReturnType<typeof removeReactionEmoji>; removeReactionEmoji(reaction: string): ReturnType<typeof removeReactionEmoji>;
/** Remove all reactions */ /** Removes a reaction from the given user on this message, defaults to bot */
removeReaction(reaction: string): ReturnType<typeof removeReaction>; removeReaction(
reaction: string,
userId?: string,
): ReturnType<typeof removeReaction>;
} }
+1 -4
View File
@@ -1,9 +1,9 @@
import { Integration } from "../integration/integration.ts"; import { Integration } from "../integration/integration.ts";
import { User } from "../users/user.ts"; import { User } from "../users/user.ts";
import { SnakeCasedPropertiesDeep } from "../util.ts";
import { Webhook } from "../webhooks/webhook.ts"; import { Webhook } from "../webhooks/webhook.ts";
import { AuditLogEntry } from "./audit_log_entry.ts"; import { AuditLogEntry } from "./audit_log_entry.ts";
/** https://discord.com/developers/docs/resources/audit-log#audit-log-object */
export interface AuditLog { export interface AuditLog {
/** List of webhooks found in the audit log */ /** List of webhooks found in the audit log */
webhooks: Webhook[]; webhooks: Webhook[];
@@ -14,6 +14,3 @@ export interface AuditLog {
/** List of partial integration objects */ /** List of partial integration objects */
integrations: Partial<Integration>[]; integrations: Partial<Integration>[];
} }
/** https://discord.com/developers/docs/resources/audit-log#audit-log-object */
export type DiscordAuditLog = SnakeCasedPropertiesDeep<AuditLog>;
+1 -4
View File
@@ -1,6 +1,6 @@
import { SnakeCasedPropertiesDeep } from "../util.ts";
import { AuditLogChangeValue } from "./audit_log_change_value.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 { export interface AuditLogChange {
/** New value of the key */ /** New value of the key */
newValue?: AuditLogChangeValue; newValue?: AuditLogChangeValue;
@@ -9,6 +9,3 @@ export interface AuditLogChange {
/** Name of audit log change key */ /** Name of audit log change key */
key: string; key: string;
} }
/** https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-structure */
export type DiscordAuditLogChange = SnakeCasedPropertiesDeep<AuditLogChange>;
@@ -1,7 +1,7 @@
import { Overwrite } from "../channels/overwrite.ts"; import { Overwrite } from "../channels/overwrite.ts";
import { Role } from "../permissions/role.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 = export type AuditLogChangeValue =
| { | {
newValue: string; newValue: string;
@@ -83,8 +83,3 @@ export type AuditLogChangeValue =
oldValue: string | number; oldValue: string | number;
key: "type"; key: "type";
}; };
/** https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-structure */
export type DiscordAuditLogChangeValue = SnakeCasedPropertiesDeep<
AuditLogChangeValue
>;
+1 -4
View File
@@ -1,8 +1,8 @@
import { SnakeCasedPropertiesDeep } from "../util.ts";
import { AuditLogChange } from "./audit_log_change.ts"; import { AuditLogChange } from "./audit_log_change.ts";
import { DiscordAuditLogEvents } from "./audit_log_events.ts"; import { DiscordAuditLogEvents } from "./audit_log_events.ts";
import { OptionalAuditEntryInfo } from "./optional_audit_entry_info.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 { export interface AuditLogEntry {
/** id of the affected entity (webhook, user, role, etc.) */ /** id of the affected entity (webhook, user, role, etc.) */
targetId: string | null; targetId: string | null;
@@ -19,6 +19,3 @@ export interface AuditLogEntry {
/** The reason for the change (0-512 characters) */ /** The reason for the change (0-512 characters) */
reason?: string; reason?: string;
} }
/** https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-entry-structure */
export type DiscordAuditLogEntry = SnakeCasedPropertiesDeep<AuditLogEntry>;
+3
View File
@@ -36,3 +36,6 @@ export enum DiscordAuditLogEvents {
INTEGRATION_UPDATE, INTEGRATION_UPDATE,
INTEGRATION_DELETE, INTEGRATION_DELETE,
} }
export type AuditLogEvents = DiscordAuditLogEvents;
export const AuditLogEvents = DiscordAuditLogEvents;
+1 -6
View File
@@ -1,6 +1,6 @@
import { SnakeCasedPropertiesDeep } from "../util.ts";
import { DiscordAuditLogEvents } from "./audit_log_events.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 { export interface GetGuildAuditLog {
/** Filter the log for actions made by a user */ /** Filter the log for actions made by a user */
userId: string; userId: string;
@@ -11,8 +11,3 @@ export interface GetGuildAuditLog {
/** How many entries are returned (default 50, minimum 1, maximum 100) */ /** How many entries are returned (default 50, minimum 1, maximum 100) */
limit: number; limit: number;
} }
/** https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log-query-string-parameters */
export type DiscordGetGuildAuditLog = SnakeCasedPropertiesDeep<
GetGuildAuditLog
>;
@@ -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 { export interface OptionalAuditEntryInfo {
/** Number of days after which inactive members were kicked */ /** Number of days after which inactive members were kicked */
deleteMemberDays: string; deleteMemberDays: string;
@@ -18,8 +17,3 @@ export interface OptionalAuditEntryInfo {
/** Name of the role if type is "0" (not present if type is "1") */ /** Name of the role if type is "0" (not present if type is "1") */
roleName: string; roleName: string;
} }
/** https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info */
export type DiscordOptionalAuditEntryInfo = SnakeCasedPropertiesDeep<
OptionalAuditEntryInfo
>;
+2 -8
View File
@@ -1,9 +1,9 @@
import { User } from "../users/user.ts"; import { User } from "../users/user.ts";
import { SnakeCasedPropertiesDeep } from "../util.ts";
import { DiscordChannelTypes } from "./channel_types.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"; import { DiscordVideoQualityModes } from "./video_quality_modes.ts";
/** https://discord.com/developers/docs/resources/channel#channel-object */
export interface Channel { export interface Channel {
/** The id of the channel */ /** The id of the channel */
id: string; id: string;
@@ -46,9 +46,3 @@ export interface Channel {
/** The camera video quality mode of the voice channel, 1 when not present */ /** The camera video quality mode of the voice channel, 1 when not present */
videoQualityMode?: DiscordVideoQualityModes; videoQualityMode?: DiscordVideoQualityModes;
} }
/** https://discord.com/developers/docs/resources/channel#channel-object */
export interface DiscordChannel
extends SnakeCasedPropertiesDeep<Omit<Channel, "permissionOverwrites">> {
permission_overwrites?: DiscordOverwrite[];
}
+1 -5
View File
@@ -1,5 +1,4 @@
import { SnakeCasedPropertiesDeep } from "../util.ts"; /** https://discord.com/developers/docs/resources/channel#channel-mention-object */
export interface ChannelMention { export interface ChannelMention {
/** id of the channel */ /** id of the channel */
id: string; id: string;
@@ -10,6 +9,3 @@ export interface ChannelMention {
/** The name of the channel */ /** The name of the channel */
name: string; name: string;
} }
/** https://discord.com/developers/docs/resources/channel#channel-mention-object */
export type DiscordChannelMention = SnakeCasedPropertiesDeep<ChannelMention>;
+1 -7
View File
@@ -1,5 +1,4 @@
import { SnakeCasedPropertiesDeep } from "../util.ts"; /** https://discord.com/developers/docs/topics/gateway#channel-pins-update */
export interface ChannelPinsUpdate { export interface ChannelPinsUpdate {
/** The id of the guild */ /** The id of the guild */
guildId?: string; guildId?: string;
@@ -8,8 +7,3 @@ export interface ChannelPinsUpdate {
/** The time at which the most recent pinned message was pinned */ /** The time at which the most recent pinned message was pinned */
lastPinTimestamp?: string | null; lastPinTimestamp?: string | null;
} }
/** https://discord.com/developers/docs/topics/gateway#channel-pins-update */
export type DiscordChannelPinsUpdate = SnakeCasedPropertiesDeep<
ChannelPinsUpdate
>;
+3
View File
@@ -17,3 +17,6 @@ export enum DiscordChannelTypes {
/** A voice channel for hosting events with an audience */ /** A voice channel for hosting events with an audience */
GUILD_STAGE_VOICE = 13, GUILD_STAGE_VOICE = 13,
} }
export type ChannelTypes = DiscordChannelTypes;
export const ChannelTypes = DiscordChannelTypes;
+1 -5
View File
@@ -1,11 +1,7 @@
import { SnakeCasedPropertiesDeep } from "../util.ts"; /** https://discord.com/developers/docs/resources/channel#followed-channel-object */
export interface FollowedChannel { export interface FollowedChannel {
/** Source message id */ /** Source message id */
channelId: string; channelId: string;
/** Created target webhook id */ /** Created target webhook id */
webhookId: string; webhookId: string;
} }
/** https://discord.com/developers/docs/resources/channel#followed-channel-object */
export type DiscordFollowedChannel = SnakeCasedPropertiesDeep<FollowedChannel>;
+2
View File
@@ -37,3 +37,5 @@ export interface DiscordModifyChannel extends
> { > {
permission_overwrites?: DiscordOverwrite[]; permission_overwrites?: DiscordOverwrite[];
} }
//TODO: check this
+2
View File
@@ -17,3 +17,5 @@ export interface DiscordOverwrite extends Omit<Overwrite, "allow" | "deny"> {
allow: string; allow: string;
deny: string; deny: string;
} }
// TODO: check this
+3
View File
@@ -2,3 +2,6 @@ export enum DiscordOverwriteTypes {
ROLE, ROLE,
MEMBER, MEMBER,
} }
export type OverwriteTypes = DiscordOverwriteTypes;
export const OverwriteTypes = DiscordOverwriteTypes;
@@ -4,3 +4,6 @@ export enum DiscordVideoQualityModes {
/** 720p */ /** 720p */
Full, Full,
} }
export type VideoQualityModes = DiscordVideoQualityModes;
export const VideoQualityModes = DiscordVideoQualityModes;
@@ -15,3 +15,6 @@ export enum DiscordGatewayCloseEventCodes {
InvalidIntents, InvalidIntents,
DisallowedIntents, DisallowedIntents,
} }
export type GatewayCloseEventCodes = DiscordGatewayCloseEventCodes;
export const GatewayCloseEventCodes = DiscordGatewayCloseEventCodes;
+3
View File
@@ -12,3 +12,6 @@ export enum DiscordGatewayOpcodes {
Hello, Hello,
HeartbeatACK, HeartbeatACK,
} }
export type GatewayOpcodes = DiscordGatewayOpcodes;
export const GatewayOpcodes = DiscordGatewayOpcodes;
+3
View File
@@ -12,3 +12,6 @@ export enum DiscordHTTPResponseCodes {
TooManyRequests = 429, TooManyRequests = 429,
GatewayUnavailable = 502, GatewayUnavailable = 502,
} }
export type HTTPPResponseCodes = DiscordHTTPResponseCodes;
export const HTTPPResponseCodes = DiscordHTTPResponseCodes;
+4
View File
@@ -43,6 +43,7 @@ export enum DiscordJsonErrorCodes {
MaximumNumberOfInvitesReached, MaximumNumberOfInvitesReached,
MaximumNumberOfGuildDiscoverySubcategoriesHasBeenReached = 30030, MaximumNumberOfGuildDiscoverySubcategoriesHasBeenReached = 30030,
GuildAlreadyHasTemplate = 30031, GuildAlreadyHasTemplate = 30031,
MaximumNumberOfBansForNonGuildMembersHaveBeenExceeded = 30035,
UnauthorizedProvideAValidTokenAndTryAgain = 40001, UnauthorizedProvideAValidTokenAndTryAgain = 40001,
YouNeedToVerifyYourAccountInOrderToPerformThisAction, YouNeedToVerifyYourAccountInOrderToPerformThisAction,
RequestEntityTooLargeTrySendingSomethingSmallerInSize = 40005, RequestEntityTooLargeTrySendingSomethingSmallerInSize = 40005,
@@ -81,3 +82,6 @@ export enum DiscordJsonErrorCodes {
ReqctionWasBlocked = 90001, ReqctionWasBlocked = 90001,
ApiResourceIsCurrentlyOverloadedTryAgainALittleLater = 130000, ApiResourceIsCurrentlyOverloadedTryAgainALittleLater = 130000,
} }
export type JsonErrrorCodes = DiscordJsonErrorCodes;
export const JsonErrrorCodes = DiscordJsonErrorCodes;
+3
View File
@@ -7,3 +7,6 @@ export enum DiscordRpcCloseEventCodes {
InvalidVersion, InvalidVersion,
InvalidEncoding, InvalidEncoding,
} }
export type RpcCloseEventCodes = DiscordRpcCloseEventCodes;
export const RpcCloseEventCodes = DiscordRpcCloseEventCodes;
+3
View File
@@ -17,3 +17,6 @@ export enum DiscordRpcErrorCodes {
SelectVoiceForceRequired, SelectVoiceForceRequired,
CaptureShortcutAlreadyListening, CaptureShortcutAlreadyListening,
} }
export type RpcErrorCodes = DiscordRpcErrorCodes;
export const RpcErrorCodes = DiscordRpcErrorCodes;
@@ -13,3 +13,6 @@ export enum DiscordVoiceCloseEventCodes {
VoiceServerCrashed, VoiceServerCrashed,
UnknownEncryptionMode, UnknownEncryptionMode,
} }
export type VoiceCloseEventCodes = DiscordVoiceCloseEventCodes;
export const VoiceCloseEventCodes = DiscordVoiceCloseEventCodes;
+3
View File
@@ -12,3 +12,6 @@ export enum DiscordVoiceOpcodes {
Resumed, Resumed,
ClientDisconnect = 13, ClientDisconnect = 13,
} }
export type VoiceOpcodes = DiscordVoiceOpcodes;
export const VoiceOpcodes = DiscordVoiceOpcodes;
-2
View File
@@ -161,8 +161,6 @@ export interface EventHandlers {
) => unknown; ) => unknown;
/** Sent before every event execution. Discordeno will not await its execution. */ /** Sent before every event execution. Discordeno will not await its execution. */
raw?: (data: GatewayPayload) => unknown; raw?: (data: GatewayPayload) => unknown;
// TODO: remove this?
// rawGateway?: (data: unknown) => unknown;
/** Sent when all shards went ready. */ /** Sent when all shards went ready. */
ready?: () => unknown; ready?: () => unknown;
/** Sent when a user adds a reaction to a message. */ /** Sent when a user adds a reaction to a message. */
@@ -1,12 +1,6 @@
import { SnakeCasedPropertiesDeep } from "../util.ts";
export interface AddGuildDiscoverySubcategory { export interface AddGuildDiscoverySubcategory {
/** The guild Id of the subcategory was added to */ /** The guild Id of the subcategory was added to */
guildId: string; guildId: string;
/** The Id of the subcategory added */ /** The Id of the subcategory added */
categoryId: number; categoryId: number;
} }
export type DiscordAddGuildDiscoverySubcategory = SnakeCasedPropertiesDeep<
AddGuildDiscoverySubcategory
>;
+1 -6
View File
@@ -1,6 +1,6 @@
import { SnakeCasedPropertiesDeep } from "../util.ts";
import { DiscoveryName } from "./discovery_name.ts"; import { DiscoveryName } from "./discovery_name.ts";
//TODO: add docs link
export interface DiscoveryCategory { export interface DiscoveryCategory {
/** Numeric id of the category */ /** Numeric id of the category */
id: number; id: number;
@@ -9,8 +9,3 @@ export interface DiscoveryCategory {
/** Whether this category can be set as a guild's primary category */ /** Whether this category can be set as a guild's primary category */
isPrimary: boolean; isPrimary: boolean;
} }
//TODO: add docs link
export type DiscordDiscoveryCategory = SnakeCasedPropertiesDeep<
DiscoveryCategory
>;
+1 -7
View File
@@ -1,5 +1,4 @@
import { SnakeCasedPropertiesDeep } from "../util.ts"; // TODO: add docs link
export interface DiscoveryMetadata { export interface DiscoveryMetadata {
/** The guild Id */ /** The guild Id */
guildId: string; guildId: string;
@@ -16,8 +15,3 @@ export interface DiscoveryMetadata {
/** Ids of up to 5 discovery subcategories set for this guild */ /** Ids of up to 5 discovery subcategories set for this guild */
categoryIds: number[]; categoryIds: number[];
} }
// TODO: add docs link
export type DiscordDiscoveryMetadata = SnakeCasedPropertiesDeep<
DiscoveryMetadata
>;
+1 -2
View File
@@ -1,8 +1,7 @@
//TODO: add docs link
export interface DiscoveryName { export interface DiscoveryName {
/** The name in English */ /** The name in English */
default: string; default: string;
/** The name in other languages */ /** The name in other languages */
localizations?: Record<string, string>; localizations?: Record<string, string>;
} }
export type DiscordDiscoveryName = DiscoveryName;
@@ -1,5 +1,4 @@
import { SnakeCasedPropertiesDeep } from "../util.ts"; // TODO: add docs link
export interface ModifyGuildDiscoveryMetadata { export interface ModifyGuildDiscoveryMetadata {
/** The id of the primary discovery category. Default: 0 */ /** The id of the primary discovery category. Default: 0 */
primaryCategoryId?: number | null; primaryCategoryId?: number | null;
@@ -8,7 +7,3 @@ export interface ModifyGuildDiscoveryMetadata {
/** Whether guild info is shown when custom emojis are clicked. Default: true */ /** Whether guild info is shown when custom emojis are clicked. Default: true */
emojiDiscoverabilityEnabled?: boolean | null; emojiDiscoverabilityEnabled?: boolean | null;
} }
export type DiscordModifyGuildDiscoveryMetadata = SnakeCasedPropertiesDeep<
ModifyGuildDiscoveryMetadata
>;
@@ -1,6 +1,5 @@
// TODO: add docs link
export interface ValidateDiscoverySearchTerm { export interface ValidateDiscoverySearchTerm {
/** Whether the provided term is valid */ /** Whether the provided term is valid */
valid: boolean; valid: boolean;
} }
export type DiscordValidateDiscoverySearchTerm = ValidateDiscoverySearchTerm;
@@ -1,8 +1,5 @@
// TODO: add docs link
export interface ValidateDiscoverySearchTermParams { export interface ValidateDiscoverySearchTermParams {
/** The search term to check */ /** The search term to check */
term: string; term: string;
} }
// TODO: add docs link
export type DiscordValidateDiscoverySearchTermParams =
ValidateDiscoverySearchTermParams;
+1 -3
View File
@@ -7,6 +7,7 @@ import { EmbedThumbnail } from "./embed_thumbnail.ts";
import { DiscordEmbedTypes } from "./embed_types.ts"; import { DiscordEmbedTypes } from "./embed_types.ts";
import { EmbedVideo } from "./embed_video.ts"; import { EmbedVideo } from "./embed_video.ts";
/** https://discord.com/developers/docs/resources/channel#embed-object */
export interface Embed { export interface Embed {
/** Title of embed */ /** Title of embed */
title?: string; title?: string;
@@ -35,6 +36,3 @@ export interface Embed {
/** Fields information */ /** Fields information */
fields?: EmbedField[]; fields?: EmbedField[];
} }
/** https://discord.com/developers/docs/resources/channel#embed-object */
export type DiscordEmbed = Embed;
+1 -5
View File
@@ -1,5 +1,4 @@
import { SnakeCasedPropertiesDeep } from "../util.ts"; /** https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure */
export interface EmbedAuthor { export interface EmbedAuthor {
/** Name of author */ /** Name of author */
name?: string; name?: string;
@@ -10,6 +9,3 @@ export interface EmbedAuthor {
/** A proxied url of author icon */ /** A proxied url of author icon */
proxyIconUrl?: string; proxyIconUrl?: string;
} }
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure */
export type DiscordEmbedAuthor = SnakeCasedPropertiesDeep<EmbedAuthor>;
+1 -3
View File
@@ -1,3 +1,4 @@
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure */
export interface EmbedField { export interface EmbedField {
/** Name of the field */ /** Name of the field */
name: string; name: string;
@@ -6,6 +7,3 @@ export interface EmbedField {
/** Whether or not this field should display inline */ /** Whether or not this field should display inline */
inline?: boolean; inline?: boolean;
} }
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure */
export type DiscordEmbedField = EmbedField;
+1 -5
View File
@@ -1,5 +1,4 @@
import { SnakeCasedPropertiesDeep } from "../util.ts"; /** https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure */
export interface EmbedFooter { export interface EmbedFooter {
/** Footer text */ /** Footer text */
text: string; text: string;
@@ -8,6 +7,3 @@ export interface EmbedFooter {
/** A proxied url of footer icon */ /** A proxied url of footer icon */
proxyIconUrl?: string; proxyIconUrl?: string;
} }
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure */
export type DiscordEmbedFooter = SnakeCasedPropertiesDeep<EmbedFooter>;
+1 -5
View File
@@ -1,5 +1,4 @@
import { SnakeCasedPropertiesDeep } from "../util.ts"; /** https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure */
export interface EmbedImage { export interface EmbedImage {
/** Source url of image (only supports http(s) and attachments) */ /** Source url of image (only supports http(s) and attachments) */
url?: string; url?: string;
@@ -10,6 +9,3 @@ export interface EmbedImage {
/** Width of image */ /** Width of image */
width?: number; width?: number;
} }
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure */
export type DiscordEmbedImage = SnakeCasedPropertiesDeep<EmbedImage>;
+1 -3
View File
@@ -1,9 +1,7 @@
export type DiscordEmbedProvider = EmbedProvider;
export interface EmbedProvider { export interface EmbedProvider {
/** Name of provider */ /** Name of provider */
name?: string; name?: string;
/** Url of provider */ /** Url of provider */
url?: string; url?: string;
} }
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-provider-structure */
export type DiscordEmbedProvider = EmbedProvider;
+1 -5
View File
@@ -1,5 +1,4 @@
import { SnakeCasedPropertiesDeep } from "../util.ts"; /** https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure */
export interface EmbedThumbnail { export interface EmbedThumbnail {
/** Source url of thumbnail (only supports http(s) and attachments) */ /** Source url of thumbnail (only supports http(s) and attachments) */
url?: string; url?: string;
@@ -10,6 +9,3 @@ export interface EmbedThumbnail {
/** Width of thumbnail */ /** Width of thumbnail */
width?: number; width?: number;
} }
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure */
export type DiscordEmbedThumbnail = SnakeCasedPropertiesDeep<EmbedThumbnail>;
+1 -5
View File
@@ -1,5 +1,4 @@
import { SnakeCasedPropertiesDeep } from "../util.ts"; /** https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure */
export interface EmbedVideo { export interface EmbedVideo {
/** Source url of video */ /** Source url of video */
url?: string; url?: string;
@@ -10,6 +9,3 @@ export interface EmbedVideo {
/** Width of video */ /** Width of video */
width?: number; width?: number;
} }
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure */
export type DiscordEmbedVideo = SnakeCasedPropertiesDeep<EmbedVideo>;
+1 -3
View File
@@ -1,3 +1,4 @@
/** https://discord.com/developers/docs/resources/emoji#create-guild-emoji */
export interface CreateGuildEmoji { export interface CreateGuildEmoji {
/** Name of the emoji */ /** Name of the emoji */
name: string; name: string;
@@ -6,6 +7,3 @@ export interface CreateGuildEmoji {
/** Roles allowed to use this emoji */ /** Roles allowed to use this emoji */
roles: string[]; roles: string[];
} }
/** https://discord.com/developers/docs/resources/emoji#create-guild-emoji */
export type DiscordCreateGuildEmojis = CreateGuildEmoji;
+1 -4
View File
@@ -1,6 +1,6 @@
import { User } from "../users/user.ts"; 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 { export interface Emoji {
/** Emoji id */ /** Emoji id */
id: string | null; 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 */ /** Whether this emoji can be used, may be false due to loss of Server Boosts */
available?: boolean; available?: boolean;
} }
/** https://discord.com/developers/docs/resources/emoji#emoji-object-emoji-structure */
export type DiscordEmoji = SnakeCasedPropertiesDeep<Emoji>;
+1 -6
View File
@@ -1,14 +1,9 @@
import { Emoji } from "../emojis/emoji.ts"; import { Emoji } from "../emojis/emoji.ts";
import { SnakeCasedPropertiesDeep } from "../util.ts";
/** https://discord.com/developers/docs/topics/gateway#guild-emojis-update */
export interface GuildEmojisUpdate { export interface GuildEmojisUpdate {
/** id of the guild */ /** id of the guild */
guildId: string; guildId: string;
/** Array of emojis */ /** Array of emojis */
emojis: Emoji[]; emojis: Emoji[];
} }
/** https://discord.com/developers/docs/topics/gateway#guild-emojis-update */
export type DiscordGuildEmojisUpdate = SnakeCasedPropertiesDeep<
GuildEmojisUpdate
>;
+1 -3
View File
@@ -1,9 +1,7 @@
/** https://discord.com/developers/docs/resources/emoji#modify-guild-emoji */
export interface ModifyGuildEmoji { export interface ModifyGuildEmoji {
/** Name of the emoji */ /** Name of the emoji */
name?: string; name?: string;
/** Roles allowed to use this emoji */ /** Roles allowed to use this emoji */
roles?: string[] | null; roles?: string[] | null;
} }
/** https://discord.com/developers/docs/resources/emoji#modify-guild-emoji */
export type DiscordModifyGuildEmoji = ModifyGuildEmoji;
+3
View File
@@ -88,3 +88,6 @@ export enum DiscordGatewayIntents {
*/ */
DIRECT_MESSAGE_TYPING = 1 << 14, DIRECT_MESSAGE_TYPING = 1 << 14,
} }
export type Intents = DiscordGatewayIntents;
export const Intents = DiscordGatewayIntents;
+1 -3
View File
@@ -1,3 +1,4 @@
/** https://discord.com/developers/docs/topics/gateway#connecting-gateway-url-params */
export interface GatewayURLParams { export interface GatewayURLParams {
/** Gateway version to use */ /** Gateway version to use */
v: string; v: string;
@@ -6,6 +7,3 @@ export interface GatewayURLParams {
/** The (optional) compression of gateway packets */ /** The (optional) compression of gateway packets */
compress?: string; compress?: string;
} }
/** https://discord.com/developers/docs/topics/gateway#connecting-gateway-url-params */
export type DiscordGatewayURLParams = GatewayURLParams;
+1 -4
View File
@@ -1,6 +1,6 @@
import { SnakeCasedPropertiesDeep } from "../util.ts";
import { SessionStartLimit } from "./session_start_limit.ts"; import { SessionStartLimit } from "./session_start_limit.ts";
/** https://discord.com/developers/docs/topics/gateway#get-gateway-bot */
export interface GetGatewayBot { export interface GetGatewayBot {
/** The WSS URL that can be used for connecting to the gateway */ /** The WSS URL that can be used for connecting to the gateway */
url: string; url: string;
@@ -9,6 +9,3 @@ export interface GetGatewayBot {
/** Information on the current session start limit */ /** Information on the current session start limit */
sessionStartLimit: SessionStartLimit; sessionStartLimit: SessionStartLimit;
} }
/** https://discord.com/developers/docs/topics/gateway#get-gateway-bot */
export type DiscordGetGatewayBot = SnakeCasedPropertiesDeep<GetGatewayBot>;
+1 -4
View File
@@ -1,7 +1,7 @@
import { SnakeCasedPropertiesDeep } from "../util.ts";
import { IdentifyConnectionProperties } from "./identify_connection_properties.ts"; import { IdentifyConnectionProperties } from "./identify_connection_properties.ts";
import { StatusUpdate } from "./status_update.ts"; import { StatusUpdate } from "./status_update.ts";
/** https://discord.com/developers/docs/topics/gateway#identify */
export interface Identify { export interface Identify {
/** Authentication token */ /** Authentication token */
token: string; token: string;
@@ -18,6 +18,3 @@ export interface Identify {
/** The Gateway Intents you wish to receive */ /** The Gateway Intents you wish to receive */
intents: number; intents: number;
} }
/** https://discord.com/developers/docs/topics/gateway#identify */
export type DiscordIdentify = SnakeCasedPropertiesDeep<Identify>;
+1 -1
View File
@@ -3,6 +3,7 @@ import { Application } from "../oauth2/application.ts";
import { User } from "../users/user.ts"; import { User } from "../users/user.ts";
import { SnakeCasedPropertiesDeep } from "../util.ts"; import { SnakeCasedPropertiesDeep } from "../util.ts";
/** https://discord.com/developers/docs/topics/gateway#ready */
export interface Ready { export interface Ready {
/** Gateway version */ /** Gateway version */
v: number; v: number;
@@ -20,5 +21,4 @@ export interface Ready {
application: Partial<Application> & Pick<Application, "id" | "flags">; application: Partial<Application> & Pick<Application, "id" | "flags">;
} }
/** https://discord.com/developers/docs/topics/gateway#ready */
export type DiscordReady = SnakeCasedPropertiesDeep<Ready>; export type DiscordReady = SnakeCasedPropertiesDeep<Ready>;
+1 -3
View File
@@ -1,3 +1,4 @@
/** https://discord.com/developers/docs/topics/gateway#resume */
export interface Resume { export interface Resume {
/** Session token */ /** Session token */
token: string; token: string;
@@ -6,6 +7,3 @@ export interface Resume {
/** Last sequence number received */ /** Last sequence number received */
seq: number; seq: number;
} }
/** https://discord.com/developers/docs/topics/gateway#resume */
export type DiscordResume = Resume;
+1 -7
View File
@@ -1,5 +1,4 @@
import { SnakeCasedPropertiesDeep } from "../util.ts"; /** https://discord.com/developers/docs/topics/gateway#session-start-limit-object */
export interface SessionStartLimit { export interface SessionStartLimit {
/** The total number of session starts the current user is allowed */ /** The total number of session starts the current user is allowed */
total: number; total: number;
@@ -10,8 +9,3 @@ export interface SessionStartLimit {
/** The number of identify requests allowed per 5 seconds */ /** The number of identify requests allowed per 5 seconds */
maxConcurrency: number; maxConcurrency: number;
} }
/** https://discord.com/developers/docs/topics/gateway#session-start-limit-object */
export type DiscordSessionStartLimit = SnakeCasedPropertiesDeep<
SessionStartLimit
>;
+1 -4
View File
@@ -1,7 +1,7 @@
import { Activity } from "../misc/activity.ts"; import { Activity } from "../misc/activity.ts";
import { SnakeCasedPropertiesDeep } from "../util.ts";
import { DiscordStatusTypes } from "./status_types.ts"; import { DiscordStatusTypes } from "./status_types.ts";
/** https://discord.com/developers/docs/topics/gateway#update-status */
export interface StatusUpdate { export interface StatusUpdate {
/** Unix time (in milliseconds) of when the client went idle, or null if the client is not idle */ /** Unix time (in milliseconds) of when the client went idle, or null if the client is not idle */
since: number | null; since: number | null;
@@ -12,6 +12,3 @@ export interface StatusUpdate {
/** Whether or not the client is afk */ /** Whether or not the client is afk */
afk: boolean; afk: boolean;
} }
/** https://discord.com/developers/docs/topics/gateway#update-status */
export type DiscordStatusUpdate = SnakeCasedPropertiesDeep<StatusUpdate>;
+1 -4
View File
@@ -1,12 +1,9 @@
import { User } from "../users/user.ts"; import { User } from "../users/user.ts";
import { SnakeCasedPropertiesDeep } from "../util.ts";
/** https://discord.com/developers/docs/resources/guild#ban-object */
export interface Ban { export interface Ban {
/** The reason for the ban */ /** The reason for the ban */
reason: string | null; reason: string | null;
/** The banned user */ /** The banned user */
user: User; user: User;
} }
/** https://discord.com/developers/docs/resources/guild#ban-object */
export type DiscordBan = SnakeCasedPropertiesDeep<Ban>;
+1 -5
View File
@@ -1,5 +1,4 @@
import { SnakeCasedPropertiesDeep } from "../util.ts"; /** https://discord.com/developers/docs/resources/guild#begin-guild-prune */
export interface BeginGuildPrune { export interface BeginGuildPrune {
/** Number of days to prune (1 or more), default: 7 */ /** Number of days to prune (1 or more), default: 7 */
days?: number; days?: number;
@@ -8,6 +7,3 @@ export interface BeginGuildPrune {
/** Role(s) ro include, default: none */ /** Role(s) ro include, default: none */
includeRoles?: string[]; includeRoles?: string[];
} }
/** https://discord.com/developers/docs/resources/guild#begin-guild-prune */
export type DiscordBeginGuildPrune = SnakeCasedPropertiesDeep<BeginGuildPrune>;
+1 -4
View File
@@ -1,11 +1,11 @@
import { Channel } from "../channels/channel.ts"; import { Channel } from "../channels/channel.ts";
import { Role } from "../permissions/role.ts"; import { Role } from "../permissions/role.ts";
import { SnakeCasedPropertiesDeep } from "../util.ts";
import { DiscordDefaultMessageNotificationLevels } from "./default_message_notification_levels.ts"; import { DiscordDefaultMessageNotificationLevels } from "./default_message_notification_levels.ts";
import { DiscordExplicitContentFilterLevels } from "./explicit_content_filter_levels.ts"; import { DiscordExplicitContentFilterLevels } from "./explicit_content_filter_levels.ts";
import { DiscordSystemChannelFlags } from "./system_channel_flags.ts"; import { DiscordSystemChannelFlags } from "./system_channel_flags.ts";
import { DiscordVerificationLevels } from "./verification_levels.ts"; import { DiscordVerificationLevels } from "./verification_levels.ts";
/** https://discord.com/developers/docs/resources/guild#create-guild */
export interface CreateGuild { export interface CreateGuild {
/** Name of the guild (2-100 characters) */ /** Name of the guild (2-100 characters) */
name: string; name: string;
@@ -32,6 +32,3 @@ export interface CreateGuild {
/** System channel flags */ /** System channel flags */
systemChannelFlags?: DiscordSystemChannelFlags; systemChannelFlags?: DiscordSystemChannelFlags;
} }
/** https://discord.com/developers/docs/resources/guild#create-guild */
export type DiscordCreateGuild = SnakeCasedPropertiesDeep<CreateGuild>;
+1 -5
View File
@@ -1,11 +1,7 @@
import { SnakeCasedPropertiesDeep } from "../util.ts"; /** https://discord.com/developers/docs/resources/guild#create-guild-ban */
export interface CreateGuildBan { export interface CreateGuildBan {
/** Number of days to delete messages for (0-7) */ /** Number of days to delete messages for (0-7) */
deleteMessageDays?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7; deleteMessageDays?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
/** Reason for the ban */ /** Reason for the ban */
reason?: string; reason?: string;
} }
/** https://discord.com/developers/docs/resources/guild#create-guild-ban */
export type DiscordCreateGuildBan = SnakeCasedPropertiesDeep<CreateGuildBan>;
+1
View File
@@ -32,3 +32,4 @@ export interface DiscordCreateGuildChannel extends
> { > {
permission_overwrites: DiscordOverwrite[]; permission_overwrites: DiscordOverwrite[];
} }
// TODO: check this
+1
View File
@@ -18,3 +18,4 @@ export interface DiscordCreateGuildRole
extends Omit<CreateGuildRole, "permissions"> { extends Omit<CreateGuildRole, "permissions"> {
permissions?: string; permissions?: string;
} }
// TODO: check this
@@ -5,3 +5,8 @@ export enum DiscordDefaultMessageNotificationLevels {
/** Members will receive notifications only for messages that @mention them by default */ /** Members will receive notifications only for messages that @mention them by default */
ONLY_MENTIONS, ONLY_MENTIONS,
} }
export type DefaultMessageNotificationLevels =
DiscordDefaultMessageNotificationLevels;
export const DefaultMessageNotificationLevels =
DiscordDefaultMessageNotificationLevels;
@@ -7,3 +7,6 @@ export enum DiscordExplicitContentFilterLevels {
/** Media content sent by all members will be scanned */ /** Media content sent by all members will be scanned */
ALL_MEMBERS, ALL_MEMBERS,
} }
export type ExplicitContentFilterLevels = DiscordExplicitContentFilterLevels;
export const ExplicitContentFilterLevels = DiscordExplicitContentFilterLevels;
+1 -5
View File
@@ -1,9 +1,5 @@
import { SnakeCasedPropertiesDeep } from "../util.ts"; /** https://discord.com/developers/docs/resources/guild#get-guild */
export interface GetGuildQuery { export interface GetGuildQuery {
/** When true, will return approximate member and presence counts for the guild */ /** When true, will return approximate member and presence counts for the guild */
withCounts?: boolean; withCounts?: boolean;
} }
/** https://discord.com/developers/docs/resources/guild#get-guild */
export type DiscordGetGuildQuery = SnakeCasedPropertiesDeep<GetGuildQuery>;
+1 -7
View File
@@ -1,13 +1,7 @@
import { SnakeCasedPropertiesDeep } from "../util.ts"; /** https://discord.com/developers/docs/resources/guild#get-guild-prune-count */
export interface GetGuildPruneCountQuery { export interface GetGuildPruneCountQuery {
/** Number of days to count prune for (1 or more), default: 7 */ /** Number of days to count prune for (1 or more), default: 7 */
days?: number; days?: number;
/** Role(s) to include, default: none */ /** Role(s) to include, default: none */
includeRoles: string | string[]; includeRoles: string | string[];
} }
/** https://discord.com/developers/docs/resources/guild#get-guild-prune-count */
export type DiscordGetGuildPruneCountQuery = SnakeCasedPropertiesDeep<
GetGuildPruneCountQuery
>;
+1 -3
View File
@@ -1,9 +1,7 @@
import { DiscordGetGuildWidgetImageStyleOptions } from "./get_guild_widget_image_style_options.ts"; 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 { export interface GetGuildWidgetImageQuery {
/** Style of the widget returned, default: shield */ /** Style of the widget returned, default: shield */
style?: DiscordGetGuildWidgetImageStyleOptions; style?: DiscordGetGuildWidgetImageStyleOptions;
} }
/** https://discord.com/developers/docs/resources/guild#get-guild-widget-image-query-string-params */
export type DiscordGetGuildWidgetImage = GetGuildWidgetImageQuery;
@@ -11,3 +11,8 @@ export enum DiscordGetGuildWidgetImageStyleOptions {
/** Large Discord logo at the top of the widget. Guild icon, name and online count in the middle portion of the widget and a "JOIN MY SERVER" button at the bottom */ /** Large Discord logo at the top of the widget. Guild icon, name and online count in the middle portion of the widget and a "JOIN MY SERVER" button at the bottom */
BANNER_4 = "banner4", BANNER_4 = "banner4",
} }
export type GetGuildWidgetImageStyleOptions =
DiscordGetGuildWidgetImageStyleOptions;
export const GetGuildWidgetImageStyleOptions =
DiscordGetGuildWidgetImageStyleOptions;
+3 -4
View File
@@ -2,7 +2,6 @@ import { Channel } from "../channels/channel.ts";
import { Emoji } from "../emojis/emoji.ts"; import { Emoji } from "../emojis/emoji.ts";
import { PresenceUpdate } from "../misc/presence_update.ts"; import { PresenceUpdate } from "../misc/presence_update.ts";
import { Role } from "../permissions/role.ts"; import { Role } from "../permissions/role.ts";
import { SnakeCasedPropertiesDeep } from "../util.ts";
import { VoiceState } from "../voice/voice_state.ts"; import { VoiceState } from "../voice/voice_state.ts";
import { DiscordDefaultMessageNotificationLevels } from "./default_message_notification_levels.ts"; import { DiscordDefaultMessageNotificationLevels } from "./default_message_notification_levels.ts";
import { DiscordExplicitContentFilterLevels } from "./explicit_content_filter_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 { DiscordVerificationLevels } from "./verification_levels.ts";
import { WelcomeScreen } from "./welcome_screen.ts"; import { WelcomeScreen } from "./welcome_screen.ts";
/** https://discord.com/developers/docs/resources/guild#guild-object */
export interface Guild { export interface Guild {
/** Guild id */ /** Guild id */
id: string; id: string;
@@ -107,7 +107,6 @@ export interface Guild {
approximatePresenceCount?: number; approximatePresenceCount?: number;
/** The welcome screen of a Community guild, shown to new members, returned when in the invite object */ /** The welcome screen of a Community guild, shown to new members, returned when in the invite object */
welcomeScreen?: WelcomeScreen; welcomeScreen?: WelcomeScreen;
/** `true` if this guild is designated as NSFW */
nsfw: boolean;
} }
/** https://discord.com/developers/docs/resources/guild#guild-object */
export type DiscordGuild = SnakeCasedPropertiesDeep<Guild>;
+1 -6
View File
@@ -1,14 +1,9 @@
import { User } from "../users/user.ts"; import { User } from "../users/user.ts";
import { SnakeCasedPropertiesDeep } from "../util.ts";
/** https://discord.com/developers/docs/topics/gateway#guild-ban-add */
export interface GuildBanAddRemove { export interface GuildBanAddRemove {
/** id of the guild */ /** id of the guild */
guildId: string; guildId: string;
/** The banned user */ /** The banned user */
user: User; user: User;
} }
/** https://discord.com/developers/docs/topics/gateway#guild-ban-add */
export type DiscordGuildBanAddRemove = SnakeCasedPropertiesDeep<
GuildBanAddRemove
>;
+1 -4
View File
@@ -1,12 +1,9 @@
import { User } from "../users/user.ts"; import { User } from "../users/user.ts";
import { SnakeCasedPropertiesDeep } from "../util.ts";
/** https://discord.com/developers/docs/topics/gateway#guild-ban-remove */
export interface GuildBanRemove { export interface GuildBanRemove {
/** id of the guild */ /** id of the guild */
guildId: string; guildId: string;
/** The unbanned user */ /** The unbanned user */
user: User; user: User;
} }
/** https://discord.com/developers/docs/topics/gateway#guild-ban-remove */
export type DiscordGuildBanRemove = SnakeCasedPropertiesDeep<GuildBanRemove>;
+5 -1
View File
@@ -17,7 +17,8 @@ export enum DiscordGuildFeatures {
/** Guild has access to create news channels */ /** Guild has access to create news channels */
NEWS = "NEWS", NEWS = "NEWS",
/** Guild is able to be discovered in the directory */ /** 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", DISCOVERABLE_DISABLED = "DISCOVERABLE_DISABLED",
/** Guild is able to be featured in the directory */ /** Guild is able to be featured in the directory */
FEATURABLE = "FEATURABLE", FEATURABLE = "FEATURABLE",
@@ -32,3 +33,6 @@ export enum DiscordGuildFeatures {
/** Guild can be previewed before joining via Membership Screening or the directory */ /** Guild can be previewed before joining via Membership Screening or the directory */
PREVIEW_ENABLED = "PREVIEW_ENABLED", PREVIEW_ENABLED = "PREVIEW_ENABLED",
} }
export type GuildFeatures = DiscordGuildFeatures;
export const GuildFeatures = DiscordGuildFeatures;
+2 -8
View File
@@ -1,6 +1,6 @@
import { User } from "../users/user.ts"; import { User } from "../users/user.ts";
import { SnakeCasedPropertiesDeep } from "../util.ts";
/** https://discord.com/developers/docs/resources/guild#guild-member-object */
export interface GuildMember { export interface GuildMember {
/** The user this guild member represents */ /** The user this guild member represents */
user?: User; user?: User;
@@ -20,13 +20,7 @@ export interface GuildMember {
pending?: boolean; pending?: boolean;
} }
/** https://discord.com/developers/docs/resources/guild#guild-member-object */
export type DiscordGuildMember = SnakeCasedPropertiesDeep<GuildMember>;
// We use these types much since user always exists unless its a `CREATE_MESSAGE` or `MESSAGE_UPDATE` event // We use these types much since user always exists unless its a `CREATE_MESSAGE` or `MESSAGE_UPDATE` event
export type GuildMemberWithUser = Omit<GuildMember, "user"> & { user: User };
/** https://discord.com/developers/docs/resources/guild#guild-member-object */ /** https://discord.com/developers/docs/resources/guild#guild-member-object */
export type DiscordGuildMemberWithUser = SnakeCasedPropertiesDeep< export type GuildMemberWithUser = Omit<GuildMember, "user"> & { user: User };
GuildMemberWithUser
>;
+1 -4
View File
@@ -1,7 +1,7 @@
import { Emoji } from "../emojis/emoji.ts"; import { Emoji } from "../emojis/emoji.ts";
import { SnakeCasedPropertiesDeep } from "../util.ts";
import { DiscordGuildFeatures } from "./guild_features.ts"; import { DiscordGuildFeatures } from "./guild_features.ts";
/** https://discord.com/developers/docs/resources/guild#guild-preview-object */
export interface GuildPreview { export interface GuildPreview {
/** Guild id */ /** Guild id */
id: string; id: string;
@@ -24,6 +24,3 @@ export interface GuildPreview {
/** The description for the guild, if the guild is discoverable */ /** The description for the guild, if the guild is discoverable */
description: string | null; description: string | null;
} }
/** https://discord.com/developers/docs/resources/guild#guild-preview-object */
export type DiscordGuildPreview = SnakeCasedPropertiesDeep<GuildPreview>;
+1 -4
View File
@@ -1,12 +1,9 @@
import { Role } from "../permissions/role.ts"; import { Role } from "../permissions/role.ts";
import { SnakeCasedPropertiesDeep } from "../util.ts";
/** https://discord.com/developers/docs/topics/gateway#guild-role-create */
export interface GuildRoleCreate { export interface GuildRoleCreate {
/** The id of the guild */ /** The id of the guild */
guildId: string; guildId: string;
/** The role created */ /** The role created */
role: Role; role: Role;
} }
/** https://discord.com/developers/docs/topics/gateway#guild-role-create */
export type DiscordGuildRoleCreate = SnakeCasedPropertiesDeep<GuildRoleCreate>;
+1 -5
View File
@@ -1,11 +1,7 @@
import { SnakeCasedPropertiesDeep } from "../util.ts"; /** https://discord.com/developers/docs/topics/gateway#guild-role-delete */
export interface GuildRoleDelete { export interface GuildRoleDelete {
/** id of the guild */ /** id of the guild */
guildId: string; guildId: string;
/** id of the role */ /** id of the role */
roleId: string; roleId: string;
} }
/** https://discord.com/developers/docs/topics/gateway#guild-role-delete */
export type DiscordGuildRoleDelete = SnakeCasedPropertiesDeep<GuildRoleDelete>;
+1 -4
View File
@@ -1,12 +1,9 @@
import { Role } from "../permissions/role.ts"; import { Role } from "../permissions/role.ts";
import { SnakeCasedPropertiesDeep } from "../util.ts";
/** https://discord.com/developers/docs/topics/gateway#guild-role-update */
export interface GuildRoleUpdate { export interface GuildRoleUpdate {
/** The id of the guild */ /** The id of the guild */
guildId: string; guildId: string;
/** The role updated */ /** The role updated */
role: Role; role: Role;
} }
/** https://discord.com/developers/docs/topics/gateway#guild-role-update */
export type DiscordGuildRoleUpdate = SnakeCasedPropertiesDeep<GuildRoleUpdate>;
+1 -5
View File
@@ -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 { export interface GuildWidget {
/** Whether the widget is enabled */ /** Whether the widget is enabled */
enabled: boolean; enabled: boolean;
/** The widget channel id */ /** The widget channel id */
channelId: string | null; channelId: string | null;
} }
/** https://discord.com/developers/docs/resources/guild#guild-widget-object-guild-widget-structure */
export type DiscordGuildWidget = SnakeCasedPropertiesDeep<GuildWidget>;
+1 -3
View File
@@ -1,9 +1,7 @@
/** https://discord.com/developers/docs/resources/guild#list-guild-members */
export interface ListGuildMembers { export interface ListGuildMembers {
/** Max number of members to return (1-1000). Default: 1 */ /** Max number of members to return (1-1000). Default: 1 */
limit?: number; limit?: number;
/** The highest user id in the previous page. Default: 0 */ /** The highest user id in the previous page. Default: 0 */
after?: string; after?: string;
} }
/** https://discord.com/developers/docs/resources/guild#list-guild-members */
export type DiscordListGuildMembers = ListGuildMembers;
+3
View File
@@ -5,3 +5,6 @@ export enum DiscordMfaLevels {
/** Guild has a 2FA requirement for moderation actions */ /** Guild has a 2FA requirement for moderation actions */
ELEVATED, ELEVATED,
} }
export type MfaLevels = DiscordMfaLevels;
export const MfaLevels = DiscordMfaLevels;

Some files were not shown because too many files have changed in this diff Show More