Merge branch 'main' into change-cache-members

This commit is contained in:
Skillz4Killz
2021-05-05 12:08:45 -04:00
committed by GitHub
43 changed files with 200 additions and 163 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ export async function handleChannelDelete(data: DiscordGatewayPayload) {
if ( if (
[ [
DiscordChannelTypes.GuildText, DiscordChannelTypes.GuildText,
DiscordChannelTypes.Dm, DiscordChannelTypes.DM,
DiscordChannelTypes.GroupDm, DiscordChannelTypes.GroupDm,
DiscordChannelTypes.GuildNews, DiscordChannelTypes.GuildNews,
].includes(payload.type) ].includes(payload.type)
+1 -1
View File
@@ -14,7 +14,7 @@ export async function cloneChannel(channelId: bigint, reason?: string) {
//Check for DM channel //Check for DM channel
if ( if (
channelToClone.type === DiscordChannelTypes.Dm || channelToClone.type === DiscordChannelTypes.DM ||
channelToClone.type === DiscordChannelTypes.GroupDm channelToClone.type === DiscordChannelTypes.GroupDm
) { ) {
throw new Error(Errors.CHANNEL_NOT_IN_GUILD); throw new Error(Errors.CHANNEL_NOT_IN_GUILD);
+1 -1
View File
@@ -16,7 +16,7 @@ export async function startTyping(channelId: bigint) {
if (channel) { if (channel) {
if ( if (
![ ![
DiscordChannelTypes.Dm, DiscordChannelTypes.DM,
DiscordChannelTypes.GuildNews, DiscordChannelTypes.GuildNews,
DiscordChannelTypes.GuildText, DiscordChannelTypes.GuildText,
DiscordChannelTypes.GuildNewsThread, DiscordChannelTypes.GuildNewsThread,
@@ -0,0 +1,15 @@
import { applicationId } from "../../bot.ts";
import { rest } from "../../rest/rest.ts";
import { structures } from "../../structures/mod.ts";
import type { Message } from "../../types/messages/message.ts";
import { endpoints } from "../../util/constants.ts";
/** Returns the initial Interactio response. Functions the same as Get Webhook Message */
export async function getOriginalInteractionResponse(token: string) {
const result = await rest.runMethod<Message>(
"get",
endpoints.INTERACTION_ORIGINAL_ID_TOKEN(applicationId, token),
);
return await structures.createDiscordenoMessage(result);
}
+4 -1
View File
@@ -1,11 +1,14 @@
import { rest } from "../../rest/rest.ts"; import { rest } from "../../rest/rest.ts";
import { GetInvite } from "../../types/invites/get_invite.ts";
import type { Invite } from "../../types/invites/invite.ts"; import type { Invite } from "../../types/invites/invite.ts";
import { endpoints } from "../../util/constants.ts"; import { endpoints } from "../../util/constants.ts";
import { camelKeysToSnakeCase } from "../../util/utils.ts";
/** Returns an invite for the given code or throws an error if the invite doesn't exists. */ /** Returns an invite for the given code or throws an error if the invite doesn't exists. */
export async function getInvite(inviteCode: string) { export async function getInvite(inviteCode: string, options?: GetInvite) {
return await rest.runMethod<Invite>( return await rest.runMethod<Invite>(
"get", "get",
endpoints.INVITE(inviteCode), endpoints.INVITE(inviteCode),
camelKeysToSnakeCase(options ?? {}),
); );
} }
+1 -1
View File
@@ -24,7 +24,7 @@ export function fetchMembers(
// 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.GuildMembers)
) { ) {
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS); throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
} }
+1 -1
View File
@@ -24,7 +24,7 @@ export async function getMembers(
guildId: bigint, guildId: bigint,
options?: ListGuildMembers & { addToCache?: boolean }, options?: ListGuildMembers & { addToCache?: boolean },
) { ) {
if (!(ws.identifyPayload.intents && DiscordGatewayIntents.GUILD_MEMBERS)) { if (!(ws.identifyPayload.intents && DiscordGatewayIntents.GuildMembers)) {
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS); throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
} }
+1 -8
View File
@@ -26,7 +26,7 @@ export async function sendMessage(
if (channel) { if (channel) {
if ( if (
![ ![
DiscordChannelTypes.Dm, DiscordChannelTypes.DM,
DiscordChannelTypes.GuildNews, DiscordChannelTypes.GuildNews,
DiscordChannelTypes.GuildText, DiscordChannelTypes.GuildText,
DiscordChannelTypes.GuildPublicThread, DiscordChannelTypes.GuildPublicThread,
@@ -145,13 +145,6 @@ export async function sendMessage(
} }
} }
if (
content.nonce &&
!validateLength(content.nonce.toString(), { max: 25 })
) {
throw new Error(Errors.NONCE_TOO_LONG);
}
const result = await rest.runMethod<Message>( const result = await rest.runMethod<Message>(
"post", "post",
endpoints.CHANNEL_MESSAGES(channelId), endpoints.CHANNEL_MESSAGES(channelId),
+10 -4
View File
@@ -19,6 +19,7 @@ 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 { 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 { getOriginalInteractionResponse } from "./commands/get_original_interaction_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 { getSlashCommandPermission } from "./commands/get_slash_command_permission.ts";
@@ -111,6 +112,9 @@ import { editGuildTemplate } from "./templates/edit_guild_template.ts";
import { getGuildTemplates } from "./templates/get_guild_templates.ts"; import { getGuildTemplates } from "./templates/get_guild_templates.ts";
import { getTemplate } from "./templates/get_template.ts"; import { getTemplate } from "./templates/get_template.ts";
import { syncGuildTemplate } from "./templates/sync_guild_template.ts"; import { syncGuildTemplate } from "./templates/sync_guild_template.ts";
// Type Guards
import { isActionRow } from "./type_guards/is_action_row.ts";
import { isButton } from "./type_guards/is_button.ts";
import { createWebhook } from "./webhooks/create_webhook.ts"; import { createWebhook } from "./webhooks/create_webhook.ts";
import { deleteWebhook } from "./webhooks/delete_webhook.ts"; import { deleteWebhook } from "./webhooks/delete_webhook.ts";
import { deleteWebhookMessage } from "./webhooks/delete_webhook_message.ts"; import { deleteWebhookMessage } from "./webhooks/delete_webhook_message.ts";
@@ -118,13 +122,11 @@ import { deleteWebhookWithToken } from "./webhooks/delete_webhook_with_token.ts"
import { editWebhook } from "./webhooks/edit_webhook.ts"; import { editWebhook } from "./webhooks/edit_webhook.ts";
import { editWebhookMessage } from "./webhooks/edit_webhook_message.ts"; import { editWebhookMessage } from "./webhooks/edit_webhook_message.ts";
import { editWebhookWithToken } from "./webhooks/edit_webhook_with_token.ts"; import { editWebhookWithToken } from "./webhooks/edit_webhook_with_token.ts";
import { sendWebhook } from "./webhooks/send_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 { getWebhookMessage } from "./webhooks/get_webhook_message.ts";
import { getWebhookWithToken } from "./webhooks/get_webhook_with_token.ts"; import { getWebhookWithToken } from "./webhooks/get_webhook_with_token.ts";
// Type Guards import { sendWebhook } from "./webhooks/send_webhook.ts";
import { isActionRow } from "./type_guards/is_action_row.ts";
import { isButton } from "./type_guards/is_button.ts";
export { export {
addDiscoverySubcategory, addDiscoverySubcategory,
@@ -205,6 +207,7 @@ export {
getMembers, getMembers,
getMessage, getMessage,
getMessages, getMessages,
getOriginalInteractionResponse,
getPins, getPins,
getPruneCount, getPruneCount,
getReactions, getReactions,
@@ -218,6 +221,7 @@ export {
getVanityURL, getVanityURL,
getVoiceRegions, getVoiceRegions,
getWebhook, getWebhook,
getWebhookMessage,
getWebhooks, getWebhooks,
getWebhookWithToken, getWebhookWithToken,
getWelcomeScreen, getWelcomeScreen,
@@ -289,6 +293,7 @@ export let helpers = {
getSlashCommands, getSlashCommands,
upsertSlashCommand, upsertSlashCommand,
upsertSlashCommands, upsertSlashCommands,
getOriginalInteractionResponse,
// emojis // emojis
createEmoji, createEmoji,
deleteEmoji, deleteEmoji,
@@ -396,6 +401,7 @@ export let helpers = {
getWebhookWithToken, getWebhookWithToken,
getWebhook, getWebhook,
getWebhooks, getWebhooks,
getWebhookMessage,
}; };
export type Helpers = typeof helpers; export type Helpers = typeof helpers;
@@ -0,0 +1,18 @@
import { rest } from "../../rest/rest.ts";
import { structures } from "../../structures/mod.ts";
import type { Message } from "../../types/messages/message.ts";
import { endpoints } from "../../util/constants.ts";
/** Returns a previousy-sent webhook message from the same token. Returns a message object on success. */
export async function getWebhookMessage(
webhookId: bigint,
webhookToken: string,
messageId: bigint,
) {
const result = await rest.runMethod<Message>(
"get",
endpoints.WEBHOOK_MESSAGE(webhookId, webhookToken, messageId),
);
return await structures.createDiscordenoMessage(result);
}
+2 -2
View File
@@ -66,8 +66,8 @@ export async function sendWebhook(
const result = await rest.runMethod<Message>( const result = await rest.runMethod<Message>(
"post", "post",
`${endpoints.WEBHOOK(webhookId, webhookToken)}${ `${endpoints.WEBHOOK(webhookId, webhookToken)}?wait=${options.wait}${
options.wait ? "?wait=true" : "" options.threadId ? `&thread_id=${options.threadId}` : ""
}`, }`,
{ {
...options, ...options,
+2 -2
View File
@@ -92,10 +92,10 @@ const baseGuild: Partial<DiscordenoGuild> = {
return cache.members.get(this.ownerId!); return cache.members.get(this.ownerId!);
}, },
get partnered() { get partnered() {
return Boolean(this.features?.includes(DiscordGuildFeatures.PARTNERED)); return Boolean(this.features?.includes(DiscordGuildFeatures.Partnered));
}, },
get verified() { get verified() {
return Boolean(this.features?.includes(DiscordGuildFeatures.VERIFIED)); return Boolean(this.features?.includes(DiscordGuildFeatures.Verified));
}, },
bannerURL(size, format) { bannerURL(size, format) {
return guildBannerURL(this.id!, this.banner!, size, format); return guildBannerURL(this.id!, this.banner!, size, format);
+35 -35
View File
@@ -1,40 +1,40 @@
/** https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events */ /** https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events */
export enum DiscordAuditLogEvents { export enum DiscordAuditLogEvents {
GUILD_UPDATE = 1, GuildUpdate = 1,
CHANNEL_CREATE = 10, ChannelCreate = 10,
CHANNEL_UPDATE, ChannelUpdate,
CHANNEL_DELETE, ChannelDelete,
CHANNEL_OVERWRITE_CREATE, ChannelOverwriteCreate,
CHANNEL_OVERWRITE_UPDATE, ChannelOverwriteUpdate,
CHANNEL_OVERWRITE_DELETE, ChannelOverwriteDelete,
MEMBER_KICK = 20, MemberKick = 20,
MEMBER_PRUNE, MemberPrune,
MEMBER_BAN_ADD, MemberBanAdd,
MEMBER_BAN_REMOVE, MemberBanRemove,
MEMBER_UPDATE, MemberUpdate,
MEMBER_ROLE_UPDATE, MemberRoleUpdate,
MEMBER_MOVE, MemberMove,
MEMBER_DISCONNECT, MemberDisconnect,
BOT_ADD, BotAdd,
ROLE_CREATE = 30, RoleCreate = 30,
ROLE_UPDATE, RoleUpdate,
ROLE_DELETE, RoleDelete,
INVITE_CREATE = 40, InviteCreate = 40,
INVITE_UPDATE, InviteUpdate,
INVITE_DELETE, InviteDelete,
WEBHOOK_CREATE = 50, WebhookCreate = 50,
WEBHOOK_UPDATE, WebhookUpdate,
WEBHOOK_DELETE, WebhookDelete,
EMOJI_CREATE = 60, EmojiCreate = 60,
EMOJI_UPDATE, EmojiUpdate,
EMOJI_DELETE, EmojiDelete,
MESSAGE_DELETE = 72, MessageDelete = 72,
MESSAGE_BULK_DELETE, MessageBulkDelete,
MESSAGE_PIN, MessagePin,
MESSAGE_UNPIN, MessageUnpin,
INTEGRATION_CREATE = 80, IntegrationCreate = 80,
INTEGRATION_UPDATE, IntegrationUpdate,
INTEGRATION_DELETE, IntegrationDelete,
} }
export type AuditLogEvents = DiscordAuditLogEvents; export type AuditLogEvents = DiscordAuditLogEvents;
+1 -1
View File
@@ -3,7 +3,7 @@ export enum DiscordChannelTypes {
/** A text channel within a server */ /** A text channel within a server */
GuildText, GuildText,
/** A direct message between users */ /** A direct message between users */
Dm, DM,
/** A voice channel within a server */ /** A voice channel within a server */
GuildVoice, GuildVoice,
/** A direct message between multiple users */ /** A direct message between multiple users */
+2 -2
View File
@@ -1,6 +1,6 @@
export enum DiscordOverwriteTypes { export enum DiscordOverwriteTypes {
ROLE, Role,
MEMBER, Member,
} }
export type OverwriteTypes = DiscordOverwriteTypes; export type OverwriteTypes = DiscordOverwriteTypes;
+15 -15
View File
@@ -11,63 +11,63 @@ export enum DiscordGatewayIntents {
* - CHANNEL_DELETE * - CHANNEL_DELETE
* - CHANNEL_PINS_UPDATE * - CHANNEL_PINS_UPDATE
*/ */
GUILDS = 1 << 0, Guilds = 1 << 0,
/** /**
* - GUILD_MEMBER_ADD * - GUILD_MEMBER_ADD
* - GUILD_MEMBER_UPDATE * - GUILD_MEMBER_UPDATE
* - GUILD_MEMBER_REMOVE * - GUILD_MEMBER_REMOVE
*/ */
GUILD_MEMBERS = 1 << 1, GuildMembers = 1 << 1,
/** /**
* - GUILD_BAN_ADD * - GUILD_BAN_ADD
* - GUILD_BAN_REMOVE * - GUILD_BAN_REMOVE
*/ */
GUILD_BANS = 1 << 2, GuildBans = 1 << 2,
/** /**
* - GUILD_EMOJIS_UPDATE * - GUILD_EMOJIS_UPDATE
*/ */
GUILD_EMOJIS = 1 << 3, GuildEmojis = 1 << 3,
/** /**
* - GUILD_INTEGRATIONS_UPDATE * - GUILD_INTEGRATIONS_UPDATE
* - INTEGRATION_CREATE * - INTEGRATION_CREATE
* - INTEGRATION_UPDATE * - INTEGRATION_UPDATE
* - INTEGRATION_DELETE * - INTEGRATION_DELETE
*/ */
GUILD_INTEGRATIONS = 1 << 4, GuildIntegrations = 1 << 4,
/** Enables the following events: /** Enables the following events:
* - WEBHOOKS_UPDATE * - WEBHOOKS_UPDATE
*/ */
GUILD_WEBHOOKS = 1 << 5, GuildWebhooks = 1 << 5,
/** /**
* - INVITE_CREATE * - INVITE_CREATE
* - INVITE_DELETE * - INVITE_DELETE
*/ */
GUILD_INVITES = 1 << 6, GuildInvites = 1 << 6,
/** /**
* - VOICE_STATE_UPDATE * - VOICE_STATE_UPDATE
*/ */
GUILD_VOICE_STATES = 1 << 7, GuildVoiceStates = 1 << 7,
/** /**
* - PRESENCE_UPDATE * - PRESENCE_UPDATE
*/ */
GUILD_PRESENCES = 1 << 8, GuildPresences = 1 << 8,
/** /**
* - MESSAGE_CREATE * - MESSAGE_CREATE
* - MESSAGE_UPDATE * - MESSAGE_UPDATE
* - MESSAGE_DELETE * - MESSAGE_DELETE
*/ */
GUILD_MESSAGES = 1 << 9, GuildMessages = 1 << 9,
/** /**
* - MESSAGE_REACTION_ADD * - MESSAGE_REACTION_ADD
* - MESSAGE_REACTION_REMOVE * - MESSAGE_REACTION_REMOVE
* - MESSAGE_REACTION_REMOVE_ALL * - MESSAGE_REACTION_REMOVE_ALL
* - MESSAGE_REACTION_REMOVE_EMOJI * - MESSAGE_REACTION_REMOVE_EMOJI
*/ */
GUILD_MESSAGE_REACTIONS = 1 << 10, GuildMessageReactions = 1 << 10,
/** /**
* - TYPING_START * - TYPING_START
*/ */
GUILD_MESSAGE_TYPING = 1 << 11, GuildMessageTyping = 1 << 11,
/** /**
* - CHANNEL_CREATE * - CHANNEL_CREATE
* - MESSAGE_CREATE * - MESSAGE_CREATE
@@ -75,18 +75,18 @@ export enum DiscordGatewayIntents {
* - MESSAGE_DELETE * - MESSAGE_DELETE
* - CHANNEL_PINS_UPDATE * - CHANNEL_PINS_UPDATE
*/ */
DIRECT_MESSAGES = 1 << 12, DirectMessages = 1 << 12,
/** /**
* - MESSAGE_REACTION_ADD * - MESSAGE_REACTION_ADD
* - MESSAGE_REACTION_REMOVE * - MESSAGE_REACTION_REMOVE
* - MESSAGE_REACTION_REMOVE_ALL * - MESSAGE_REACTION_REMOVE_ALL
* - MESSAGE_REACTION_REMOVE_EMOJI * - MESSAGE_REACTION_REMOVE_EMOJI
*/ */
DIRECT_MESSAGE_REACTIONS = 1 << 13, DirectMessageReactions = 1 << 13,
/** /**
* - TYPING_START * - TYPING_START
*/ */
DIRECT_MESSAGE_TYPING = 1 << 14, DirectMessageTyping = 1 << 14,
} }
export type Intents = DiscordGatewayIntents; export type Intents = DiscordGatewayIntents;
@@ -1,9 +1,9 @@
/** https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level */ /** https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level */
export enum DiscordDefaultMessageNotificationLevels { export enum DiscordDefaultMessageNotificationLevels {
/** Members will receive notifications for all messages by default */ /** Members will receive notifications for all messages by default */
ALL_MESSAGES, AllMessages,
/** 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, OnlyMentions,
} }
export type DefaultMessageNotificationLevels = export type DefaultMessageNotificationLevels =
@@ -1,11 +1,11 @@
/** https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level */ /** https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level */
export enum DiscordExplicitContentFilterLevels { export enum DiscordExplicitContentFilterLevels {
/** Media content will not be scanned */ /** Media content will not be scanned */
DISABLED, Disabled,
/** Media content sent by members without roles will be scanned */ /** Media content sent by members without roles will be scanned */
MEMBERS_WITHOUT_ROLES, MembersWithoutRoles,
/** Media content sent by all members will be scanned */ /** Media content sent by all members will be scanned */
ALL_MEMBERS, AllMembers,
} }
export type ExplicitContentFilterLevels = DiscordExplicitContentFilterLevels; export type ExplicitContentFilterLevels = DiscordExplicitContentFilterLevels;
@@ -1,15 +1,15 @@
/** https://discord.com/developers/docs/resources/guild#get-guild-widget-image-widget-style-options */ /** https://discord.com/developers/docs/resources/guild#get-guild-widget-image-widget-style-options */
export enum DiscordGetGuildWidgetImageStyleOptions { export enum DiscordGetGuildWidgetImageStyleOptions {
/** Shield style widget with Discord icon and guild members online count */ /** Shield style widget with Discord icon and guild members online count */
SHIELD = "shield", Shield = "shield",
/** Large image with guild icon, name and online count. "POWERED BY DISCORD" as the footer of the widget */ /** Large image with guild icon, name and online count. "POWERED BY DISCORD" as the footer of the widget */
BANNER_1 = "banner1", Banner1 = "banner1",
/** Smaller widget style with guild icon, name and online count. Split on the right with Discord logo */ /** Smaller widget style with guild icon, name and online count. Split on the right with Discord logo */
BANNER_2 = "banner2", Banner2 = "banner2",
/** Large image with guild icon, name and online count. In the footer, Discord logo on the left and "Chat Now" on the right */ /** Large image with guild icon, name and online count. In the footer, Discord logo on the left and "Chat Now" on the right */
BANNER_3 = "banner3", Banner3 = "banner3",
/** 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", Banner4 = "banner4",
} }
export type GetGuildWidgetImageStyleOptions = export type GetGuildWidgetImageStyleOptions =
+16 -16
View File
@@ -1,37 +1,37 @@
/** https://discord.com/developers/docs/resources/guild#guild-object-guild-features */ /** https://discord.com/developers/docs/resources/guild#guild-object-guild-features */
export enum DiscordGuildFeatures { export enum DiscordGuildFeatures {
/** Guild has access to set an invite splash background */ /** Guild has access to set an invite splash background */
INVITE_SPLASH = "INVITE_SPLASH", InviteSplash = "INVITE_SPLASH",
/** Guild has access to set 384kbps bitrate in voice (previously VIP voice servers) */ /** Guild has access to set 384kbps bitrate in voice (previously VIP voice servers) */
VIP_REGIONS = "VIP_REGIONS", VipRegions = "VIP_REGIONS",
/** Guild has access to set a vanity URL */ /** Guild has access to set a vanity URL */
VANITY_URL = "VANITY_URL", VanityUrl = "VANITY_URL",
/** Guild is verified */ /** Guild is verified */
VERIFIED = "VERIFIED", Verified = "VERIFIED",
/** Guild is partnered */ /** Guild is partnered */
PARTNERED = "PARTNERED", Partnered = "PARTNERED",
/** Guild can enable welcome screen, Membership Screening, stage channels and discovery, and recives community updates */ /** Guild can enable welcome screen, Membership Screening, stage channels and discovery, and recives community updates */
COMMUNITY = "COMMUNITY", Community = "COMMUNITY",
/** Guild has access to use commerce features (i.e. create store channels) */ /** Guild has access to use commerce features (i.e. create store channels) */
COMMERCE = "COMMERCE", Commerce = "COMMERCE",
/** 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", Discoverable = "DISCOVERABLE",
/** guild cannot be discoverable */ /** guild cannot be discoverable */
DISCOVERABLE_DISABLED = "DISCOVERABLE_DISABLED", DiscoverableDisabled = "DISCOVERABLE_DISABLED",
/** Guild is able to be featured in the directory */ /** Guild is able to be featured in the directory */
FEATURABLE = "FEATURABLE", Feature = "FEATURABLE",
/** Guild has access to set an animated guild icon */ /** Guild has access to set an animated guild icon */
ANIMATED_ICON = "ANIMATED_ICON", AnimatedIcon = "ANIMATED_ICON",
/** Guild has access to set a guild banner image */ /** Guild has access to set a guild banner image */
BANNER = "BANNER", Banner = "BANNER",
/** Guild has enabled the welcome screen */ /** Guild has enabled the welcome screen */
WELCOME_SCREEN_ENABLED = "WELCOME_SCREEN_ENABLED", WelcomeScreenEnabled = "WELCOME_SCREEN_ENABLED",
/** Guild has enabled [Membership Screening](https://discord.com/developers/docs/resources/guild#membership-screening-object) */ /** Guild has enabled [Membership Screening](https://discord.com/developers/docs/resources/guild#membership-screening-object) */
MEMBER_VERIFICATION_GATE_ENABLED = "MEMBER_VERIFICATION_GATE_ENABLED", MemberVerificationGateEnabled = "MEMBER_VERIFICATION_GATE_ENABLED",
/** 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", PreviewEnabled = "PREVIEW_ENABLED",
} }
export type GuildFeatures = DiscordGuildFeatures; export type GuildFeatures = DiscordGuildFeatures;
+2 -2
View File
@@ -1,9 +1,9 @@
/** https://discord.com/developers/docs/resources/guild#guild-object-mfa-level */ /** https://discord.com/developers/docs/resources/guild#guild-object-mfa-level */
export enum DiscordMfaLevels { export enum DiscordMfaLevels {
/** Guild has no MFA/2FA requirement for moderation actions */ /** Guild has no MFA/2FA requirement for moderation actions */
NONE, None,
/** Guild has a 2FA requirement for moderation actions */ /** Guild has a 2FA requirement for moderation actions */
ELEVATED, Elevated,
} }
export type MfaLevels = DiscordMfaLevels; export type MfaLevels = DiscordMfaLevels;
+4 -4
View File
@@ -1,13 +1,13 @@
/** https://discord.com/developers/docs/resources/guild#guild-object-premium-tier */ /** https://discord.com/developers/docs/resources/guild#guild-object-premium-tier */
export enum DiscordPremiumTiers { export enum DiscordPremiumTiers {
/** Guild has not unlocked any Server Boost perks */ /** Guild has not unlocked any Server Boost perks */
NONE, None,
/** Guild has unlocked Server Boost level 1 perks */ /** Guild has unlocked Server Boost level 1 perks */
TIER_1, Tier1,
/** Guild has unlocked Server Boost level 2 perks */ /** Guild has unlocked Server Boost level 2 perks */
TIER_2, Tier2,
/** Guild has unlocked Server Boost level 3 perks */ /** Guild has unlocked Server Boost level 3 perks */
TIER_3, Tier3,
} }
export type PremiumTiers = DiscordPremiumTiers; export type PremiumTiers = DiscordPremiumTiers;
+3 -3
View File
@@ -1,11 +1,11 @@
/** https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags */ /** https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags */
export enum DiscordSystemChannelFlags { export enum DiscordSystemChannelFlags {
/** Suppress member join notifications */ /** Suppress member join notifications */
SUPPRESS_JOIN_NOTIFICATIONS = 1 << 0, SuppressJoinNotifications = 1 << 0,
/** Suppress server boost notifications */ /** Suppress server boost notifications */
SUPPRESS_PREMIUM_SUBSCRIPTIONS = 1 << 1, SuppressPremiumSubscriptions = 1 << 1,
/** Suppress server setup tips */ /** Suppress server setup tips */
SUPPRESS_GUILD_REMINDER_NOTIFICATIONS = 1 << 2, SuppressGuildReminderNotifications = 1 << 2,
} }
export type SystemChannelFlags = DiscordSystemChannelFlags; export type SystemChannelFlags = DiscordSystemChannelFlags;
+5 -5
View File
@@ -1,15 +1,15 @@
/** https://discord.com/developers/docs/resources/guild#guild-object-verification-level */ /** https://discord.com/developers/docs/resources/guild#guild-object-verification-level */
export enum DiscordVerificationLevels { export enum DiscordVerificationLevels {
/** Unrestricted */ /** Unrestricted */
NONE, None,
/** Must have verified email on account */ /** Must have verified email on account */
LOW, Low,
/** Must be registered on Discord for longer than 5 minutes */ /** Must be registered on Discord for longer than 5 minutes */
MEDIUM, Medium,
/** Must be a member of the server for longer than 10 minutes */ /** Must be a member of the server for longer than 10 minutes */
HIGH, High,
/** Must have a verified phone number */ /** Must have a verified phone number */
VERY_HIGH, VeryHigh,
} }
export type VerificationLevels = DiscordVerificationLevels; export type VerificationLevels = DiscordVerificationLevels;
@@ -1,14 +1,14 @@
/** https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype */ /** https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype */
export enum DiscordApplicationCommandOptionTypes { export enum DiscordApplicationCommandOptionTypes {
SUB_COMMAND = 1, SubCommand = 1,
SUB_COMMAND_GROUP, SubCommandGroup,
STRING, String,
INTEGER, Integer,
BOOLEAN, Boolean,
USER, User,
CHANNEL, Channel,
ROLE, Role,
MENTIONABLE, Mentionable,
} }
export type ApplicationCommandOptionTypes = export type ApplicationCommandOptionTypes =
+2 -2
View File
@@ -1,7 +1,7 @@
/** https://discord.com/developers/docs/resources/invite#invite-object-target-user-types */ /** https://discord.com/developers/docs/resources/invite#invite-object-target-user-types */
export enum DiscordTargetTypes { export enum DiscordTargetTypes {
STREAM = 1, Stream = 1,
EMBEDDED_APPLICATION, EmbeddedApplication,
} }
export type TargetTypes = DiscordTargetTypes; export type TargetTypes = DiscordTargetTypes;
+1 -3
View File
@@ -8,13 +8,11 @@ import { MessageComponents } from "./components/message_components.ts";
export interface CreateMessage { export interface CreateMessage {
/** The message contents (up to 2000 characters) */ /** The message contents (up to 2000 characters) */
content?: string; content?: string;
/** A nonce that can be used for optimistic message sending */
nonce?: number | string;
/** true if this is a TTS message */ /** true if this is a TTS message */
tts?: boolean; tts?: boolean;
/** Embedded `rich` content */ /** Embedded `rich` content */
embed?: Embed; embed?: Embed;
/** Allowed mentions for a message */ /** Allowed mentions for the message */
allowedMentions?: AllowedMentions; allowedMentions?: AllowedMentions;
/** Include to make your message a reply */ /** Include to make your message a reply */
messageReference?: MessageReference; messageReference?: MessageReference;
+3
View File
@@ -1,4 +1,5 @@
import { Embed } from "../embeds/embed.ts"; import { Embed } from "../embeds/embed.ts";
import { FileContent } from "../misc/file_content.ts";
import { AllowedMentions } from "./allowed_mentions.ts"; import { AllowedMentions } from "./allowed_mentions.ts";
import { Attachment } from "./attachment.ts"; import { Attachment } from "./attachment.ts";
@@ -10,6 +11,8 @@ export interface EditMessage {
embed?: Embed | null; embed?: Embed | null;
/** Edit the flags of the message (only `SUPRESS_EMBEDS` can currently be set/unset) */ /** Edit the flags of the message (only `SUPRESS_EMBEDS` can currently be set/unset) */
flags?: 4 | null; flags?: 4 | null;
/** The contents of the file being sent/edited */
file?: FileContent | FileContent[] | null;
/** Allowed mentions for the message */ /** Allowed mentions for the message */
allowedMentions?: AllowedMentions | null; allowedMentions?: AllowedMentions | null;
/** Attached files to keep */ /** Attached files to keep */
+4 -4
View File
@@ -1,9 +1,9 @@
/** https://discord.com/developers/docs/resources/channel#message-object-message-activity-types */ /** https://discord.com/developers/docs/resources/channel#message-object-message-activity-types */
export enum DiscordMessageActivityTypes { export enum DiscordMessageActivityTypes {
JOIN = 1, Join = 1,
SPECTATE, Spectate,
LISTEN, Listen,
JOIN_REQUEST, JoinRequest,
} }
export type MessageActivityTypes = DiscordMessageActivityTypes; export type MessageActivityTypes = DiscordMessageActivityTypes;
@@ -1,8 +1,8 @@
/** https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types */ /** https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types */
export enum DiscordMessageStickerFormatTypes { export enum DiscordMessageStickerFormatTypes {
PNG = 1, Png = 1,
APNG, Apng,
LOTTIE, Lottie,
} }
export type MessageStickerFormatTypes = DiscordMessageStickerFormatTypes; export type MessageStickerFormatTypes = DiscordMessageStickerFormatTypes;
+6 -6
View File
@@ -1,11 +1,11 @@
/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-flags */ /** https://discord.com/developers/docs/topics/gateway#activity-object-activity-flags */
export enum DiscordActivityFlags { export enum DiscordActivityFlags {
INSTANCE = 1 << 0, Instance = 1 << 0,
JOIN = 1 << 1, Join = 1 << 1,
SPECTATE = 1 << 2, Spectate = 1 << 2,
JOIN_REQUEST = 1 << 3, JoinRequest = 1 << 3,
SYNC = 1 << 4, Sync = 1 << 4,
PLAY = 1 << 5, Play = 1 << 5,
} }
export type ActivityFlags = DiscordActivityFlags; export type ActivityFlags = DiscordActivityFlags;
+2 -2
View File
@@ -1,7 +1,7 @@
/** https://discord.com/developers/docs/topics/teams#data-models-membership-state-enum */ /** https://discord.com/developers/docs/topics/teams#data-models-membership-state-enum */
export enum DiscordTeamMembershipStates { export enum DiscordTeamMembershipStates {
INVITED = 1, Invited = 1,
ACCEPTED, Accepted,
} }
export type TeamMembershipStates = DiscordTeamMembershipStates; export type TeamMembershipStates = DiscordTeamMembershipStates;
+2 -2
View File
@@ -1,7 +1,7 @@
import { Embed } from "../embeds/embed.ts"; import { Embed } from "../embeds/embed.ts";
import { AllowedMentions } from "../messages/allowed_mentions.ts"; import { AllowedMentions } from "../messages/allowed_mentions.ts";
import { FileContent } from "../misc/file_content.ts";
import { Attachment } from "../messages/attachment.ts"; import { Attachment } from "../messages/attachment.ts";
import { FileContent } from "../misc/file_content.ts";
/** https://discord.com/developers/docs/resources/webhook#edit-webhook-message-jsonform-params */ /** https://discord.com/developers/docs/resources/webhook#edit-webhook-message-jsonform-params */
export interface EditWebhookMessage { export interface EditWebhookMessage {
@@ -10,7 +10,7 @@ export interface EditWebhookMessage {
/** Embedded `rich` content */ /** Embedded `rich` content */
embeds?: Embed[] | null; embeds?: Embed[] | null;
/** The contents of the file being sent/edited */ /** The contents of the file being sent/edited */
file?: FileContent | FileContent[]; file?: FileContent | FileContent[] | null;
/** Allowed mentions for the message */ /** Allowed mentions for the message */
allowedMentions?: AllowedMentions | null; allowedMentions?: AllowedMentions | null;
/** Attached files to keep */ /** Attached files to keep */
+2
View File
@@ -7,6 +7,8 @@ import { SnakeCasedPropertiesDeep } from "../util.ts";
export interface ExecuteWebhook { export interface ExecuteWebhook {
/** Waits for server confirmation of message send before response, and returns the created message body (defaults to `false`; when `false` a message that is not saved does not return an error) */ /** Waits for server confirmation of message send before response, and returns the created message body (defaults to `false`; when `false` a message that is not saved does not return an error) */
wait?: boolean; wait?: boolean;
/** Send a message to the specified thread within a webhook's channel. The thread will automatically be unarchived. */
threadId?: bigint;
/** The message contents (up to 2000 characters) */ /** The message contents (up to 2000 characters) */
content?: string; content?: string;
/** Override the default username of the webhook */ /** Override the default username of the webhook */
+4 -4
View File
@@ -130,11 +130,11 @@ function validateSlashOptionChoices(
} }
if ( if (
(optionType === DiscordApplicationCommandOptionTypes.STRING && (optionType === DiscordApplicationCommandOptionTypes.String &&
(typeof choice.value !== "string" || (typeof choice.value !== "string" ||
choice.value.length < 1 || choice.value.length < 1 ||
choice.value.length > 100)) || choice.value.length > 100)) ||
(optionType === DiscordApplicationCommandOptionTypes.INTEGER && (optionType === DiscordApplicationCommandOptionTypes.Integer &&
typeof choice.value !== "number") typeof choice.value !== "number")
) { ) {
throw new Error(Errors.INVALID_SLASH_OPTIONS_CHOICES); throw new Error(Errors.INVALID_SLASH_OPTIONS_CHOICES);
@@ -152,8 +152,8 @@ function validateSlashOptions(options: ApplicationCommandOption[]) {
if ( if (
option.choices?.length && option.choices?.length &&
(option.choices.length > 25 || (option.choices.length > 25 ||
(option.type !== DiscordApplicationCommandOptionTypes.STRING && (option.type !== DiscordApplicationCommandOptionTypes.String &&
option.type !== DiscordApplicationCommandOptionTypes.INTEGER)) option.type !== DiscordApplicationCommandOptionTypes.Integer))
) { ) {
throw new Error(Errors.INVALID_SLASH_OPTIONS_CHOICES); throw new Error(Errors.INVALID_SLASH_OPTIONS_CHOICES);
} }
@@ -53,7 +53,7 @@ Deno.test({
permissionOverwrites: [ permissionOverwrites: [
{ {
id: bigintToSnowflake(botId), id: bigintToSnowflake(botId),
type: DiscordOverwriteTypes.MEMBER, type: DiscordOverwriteTypes.Member,
allow: ["VIEW_CHANNEL"], allow: ["VIEW_CHANNEL"],
deny: [], deny: [],
}, },
+1 -1
View File
@@ -141,7 +141,7 @@ Deno.test({
permissionOverwrites: [ permissionOverwrites: [
{ {
id: bigintToSnowflake(botId), id: bigintToSnowflake(botId),
type: DiscordOverwriteTypes.MEMBER, type: DiscordOverwriteTypes.Member,
allow: ["VIEW_CHANNEL"], allow: ["VIEW_CHANNEL"],
deny: [], deny: [],
}, },
+1 -1
View File
@@ -160,7 +160,7 @@ Deno.test({
permissionOverwrites: [ permissionOverwrites: [
{ {
id: bigintToSnowflake(botId), id: bigintToSnowflake(botId),
type: DiscordOverwriteTypes.MEMBER, type: DiscordOverwriteTypes.Member,
allow: ["VIEW_CHANNEL"], allow: ["VIEW_CHANNEL"],
deny: [], deny: [],
}, },
+1 -1
View File
@@ -56,7 +56,7 @@ Deno.test({
permissionOverwrites: [ permissionOverwrites: [
{ {
id: bigintToSnowflake(botId), id: bigintToSnowflake(botId),
type: DiscordOverwriteTypes.MEMBER, type: DiscordOverwriteTypes.Member,
allow: ["VIEW_CHANNEL"], allow: ["VIEW_CHANNEL"],
deny: [], deny: [],
}, },
+2 -2
View File
@@ -35,7 +35,7 @@ async function ifItFailsBlameWolf(options: CreateGuildChannel) {
} }
await editChannelOverwrite(channel.guildId, channel.id, botId, { await editChannelOverwrite(channel.guildId, channel.id, botId, {
type: DiscordOverwriteTypes.MEMBER, type: DiscordOverwriteTypes.Member,
allow: ["VIEW_CHANNEL", "ADD_REACTIONS"], allow: ["VIEW_CHANNEL", "ADD_REACTIONS"],
deny: [], deny: [],
}); });
@@ -71,7 +71,7 @@ Deno.test({
permissionOverwrites: [ permissionOverwrites: [
{ {
id: bigintToSnowflake(botId), id: bigintToSnowflake(botId),
type: DiscordOverwriteTypes.MEMBER, type: DiscordOverwriteTypes.Member,
allow: ["VIEW_CHANNEL"], allow: ["VIEW_CHANNEL"],
deny: [], deny: [],
}, },
+1 -1
View File
@@ -18,7 +18,7 @@ Deno.test({
permissionOverwrites: [ permissionOverwrites: [
{ {
id: bigintToSnowflake(botId), id: bigintToSnowflake(botId),
type: DiscordOverwriteTypes.MEMBER, type: DiscordOverwriteTypes.Member,
allow: ["VIEW_CHANNEL"], allow: ["VIEW_CHANNEL"],
deny: [], deny: [],
}, },
+1 -1
View File
@@ -114,7 +114,7 @@ Deno.test({
const option = { const option = {
name: "option1", name: "option1",
description: "The description of the application command's option.", description: "The description of the application command's option.",
type: DiscordApplicationCommandOptionTypes.STRING, type: DiscordApplicationCommandOptionTypes.String,
}; };
// The maximum number of options an application command can "accomodate" is 25. // The maximum number of options an application command can "accomodate" is 25.
const options: ApplicationCommandOption[] = Array(26).fill(option); const options: ApplicationCommandOption[] = Array(26).fill(option);
+4 -5
View File
@@ -36,11 +36,10 @@ Deno.test({
await startBot({ await startBot({
token, token,
intents: [ intents: [
"GUILD_MESSAGES", "GuildMessages",
"GUILDS", "Guilds",
"GUILD_EMOJIS", "GuildEmojis",
"GUILD_MESSAGE_REACTIONS", "GuildMessageReactions",
"GUILD_EMOJIS",
], ],
}); });