Merge branch 'change-cache-members' of https://github.com/discordeno/discordeno into change-cache-members

This commit is contained in:
ITOH
2021-05-05 18:09:58 +02:00
43 changed files with 200 additions and 163 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ export async function handleChannelDelete(data: DiscordGatewayPayload) {
if (
[
DiscordChannelTypes.GuildText,
DiscordChannelTypes.Dm,
DiscordChannelTypes.DM,
DiscordChannelTypes.GroupDm,
DiscordChannelTypes.GuildNews,
].includes(payload.type)
+1 -1
View File
@@ -14,7 +14,7 @@ export async function cloneChannel(channelId: bigint, reason?: string) {
//Check for DM channel
if (
channelToClone.type === DiscordChannelTypes.Dm ||
channelToClone.type === DiscordChannelTypes.DM ||
channelToClone.type === DiscordChannelTypes.GroupDm
) {
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 (
![
DiscordChannelTypes.Dm,
DiscordChannelTypes.DM,
DiscordChannelTypes.GuildNews,
DiscordChannelTypes.GuildText,
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 { GetInvite } from "../../types/invites/get_invite.ts";
import type { Invite } from "../../types/invites/invite.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. */
export async function getInvite(inviteCode: string) {
export async function getInvite(inviteCode: string, options?: GetInvite) {
return await rest.runMethod<Invite>(
"get",
endpoints.INVITE(inviteCode),
camelKeysToSnakeCase(options ?? {}),
);
}
+1 -1
View File
@@ -24,7 +24,7 @@ export function fetchMembers(
// You can request 1 member without the intent
if (
(!options?.limit || options.limit > 1) &&
!(ws.identifyPayload.intents & DiscordGatewayIntents.GUILD_MEMBERS)
!(ws.identifyPayload.intents & DiscordGatewayIntents.GuildMembers)
) {
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
}
+1 -1
View File
@@ -24,7 +24,7 @@ export async function getMembers(
guildId: bigint,
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);
}
+1 -8
View File
@@ -26,7 +26,7 @@ export async function sendMessage(
if (channel) {
if (
![
DiscordChannelTypes.Dm,
DiscordChannelTypes.DM,
DiscordChannelTypes.GuildNews,
DiscordChannelTypes.GuildText,
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>(
"post",
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 { editSlashCommandPermissions } from "./commands/edit_slash_command_permissions.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 { getSlashCommands } from "./commands/get_slash_commands.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 { getTemplate } from "./templates/get_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 { deleteWebhook } from "./webhooks/delete_webhook.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 { editWebhookMessage } from "./webhooks/edit_webhook_message.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 { getWebhooks } from "./webhooks/get_webhooks.ts";
import { getWebhookMessage } from "./webhooks/get_webhook_message.ts";
import { getWebhookWithToken } from "./webhooks/get_webhook_with_token.ts";
// Type Guards
import { isActionRow } from "./type_guards/is_action_row.ts";
import { isButton } from "./type_guards/is_button.ts";
import { sendWebhook } from "./webhooks/send_webhook.ts";
export {
addDiscoverySubcategory,
@@ -205,6 +207,7 @@ export {
getMembers,
getMessage,
getMessages,
getOriginalInteractionResponse,
getPins,
getPruneCount,
getReactions,
@@ -218,6 +221,7 @@ export {
getVanityURL,
getVoiceRegions,
getWebhook,
getWebhookMessage,
getWebhooks,
getWebhookWithToken,
getWelcomeScreen,
@@ -289,6 +293,7 @@ export let helpers = {
getSlashCommands,
upsertSlashCommand,
upsertSlashCommands,
getOriginalInteractionResponse,
// emojis
createEmoji,
deleteEmoji,
@@ -396,6 +401,7 @@ export let helpers = {
getWebhookWithToken,
getWebhook,
getWebhooks,
getWebhookMessage,
};
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>(
"post",
`${endpoints.WEBHOOK(webhookId, webhookToken)}${
options.wait ? "?wait=true" : ""
`${endpoints.WEBHOOK(webhookId, webhookToken)}?wait=${options.wait}${
options.threadId ? `&thread_id=${options.threadId}` : ""
}`,
{
...options,
+2 -2
View File
@@ -92,10 +92,10 @@ const baseGuild: Partial<DiscordenoGuild> = {
return cache.members.get(this.ownerId!);
},
get partnered() {
return Boolean(this.features?.includes(DiscordGuildFeatures.PARTNERED));
return Boolean(this.features?.includes(DiscordGuildFeatures.Partnered));
},
get verified() {
return Boolean(this.features?.includes(DiscordGuildFeatures.VERIFIED));
return Boolean(this.features?.includes(DiscordGuildFeatures.Verified));
},
bannerURL(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 */
export enum DiscordAuditLogEvents {
GUILD_UPDATE = 1,
CHANNEL_CREATE = 10,
CHANNEL_UPDATE,
CHANNEL_DELETE,
CHANNEL_OVERWRITE_CREATE,
CHANNEL_OVERWRITE_UPDATE,
CHANNEL_OVERWRITE_DELETE,
MEMBER_KICK = 20,
MEMBER_PRUNE,
MEMBER_BAN_ADD,
MEMBER_BAN_REMOVE,
MEMBER_UPDATE,
MEMBER_ROLE_UPDATE,
MEMBER_MOVE,
MEMBER_DISCONNECT,
BOT_ADD,
ROLE_CREATE = 30,
ROLE_UPDATE,
ROLE_DELETE,
INVITE_CREATE = 40,
INVITE_UPDATE,
INVITE_DELETE,
WEBHOOK_CREATE = 50,
WEBHOOK_UPDATE,
WEBHOOK_DELETE,
EMOJI_CREATE = 60,
EMOJI_UPDATE,
EMOJI_DELETE,
MESSAGE_DELETE = 72,
MESSAGE_BULK_DELETE,
MESSAGE_PIN,
MESSAGE_UNPIN,
INTEGRATION_CREATE = 80,
INTEGRATION_UPDATE,
INTEGRATION_DELETE,
GuildUpdate = 1,
ChannelCreate = 10,
ChannelUpdate,
ChannelDelete,
ChannelOverwriteCreate,
ChannelOverwriteUpdate,
ChannelOverwriteDelete,
MemberKick = 20,
MemberPrune,
MemberBanAdd,
MemberBanRemove,
MemberUpdate,
MemberRoleUpdate,
MemberMove,
MemberDisconnect,
BotAdd,
RoleCreate = 30,
RoleUpdate,
RoleDelete,
InviteCreate = 40,
InviteUpdate,
InviteDelete,
WebhookCreate = 50,
WebhookUpdate,
WebhookDelete,
EmojiCreate = 60,
EmojiUpdate,
EmojiDelete,
MessageDelete = 72,
MessageBulkDelete,
MessagePin,
MessageUnpin,
IntegrationCreate = 80,
IntegrationUpdate,
IntegrationDelete,
}
export type AuditLogEvents = DiscordAuditLogEvents;
+1 -1
View File
@@ -3,7 +3,7 @@ export enum DiscordChannelTypes {
/** A text channel within a server */
GuildText,
/** A direct message between users */
Dm,
DM,
/** A voice channel within a server */
GuildVoice,
/** A direct message between multiple users */
+2 -2
View File
@@ -1,6 +1,6 @@
export enum DiscordOverwriteTypes {
ROLE,
MEMBER,
Role,
Member,
}
export type OverwriteTypes = DiscordOverwriteTypes;
+15 -15
View File
@@ -11,63 +11,63 @@ export enum DiscordGatewayIntents {
* - CHANNEL_DELETE
* - CHANNEL_PINS_UPDATE
*/
GUILDS = 1 << 0,
Guilds = 1 << 0,
/**
* - GUILD_MEMBER_ADD
* - GUILD_MEMBER_UPDATE
* - GUILD_MEMBER_REMOVE
*/
GUILD_MEMBERS = 1 << 1,
GuildMembers = 1 << 1,
/**
* - GUILD_BAN_ADD
* - GUILD_BAN_REMOVE
*/
GUILD_BANS = 1 << 2,
GuildBans = 1 << 2,
/**
* - GUILD_EMOJIS_UPDATE
*/
GUILD_EMOJIS = 1 << 3,
GuildEmojis = 1 << 3,
/**
* - GUILD_INTEGRATIONS_UPDATE
* - INTEGRATION_CREATE
* - INTEGRATION_UPDATE
* - INTEGRATION_DELETE
*/
GUILD_INTEGRATIONS = 1 << 4,
GuildIntegrations = 1 << 4,
/** Enables the following events:
* - WEBHOOKS_UPDATE
*/
GUILD_WEBHOOKS = 1 << 5,
GuildWebhooks = 1 << 5,
/**
* - INVITE_CREATE
* - INVITE_DELETE
*/
GUILD_INVITES = 1 << 6,
GuildInvites = 1 << 6,
/**
* - VOICE_STATE_UPDATE
*/
GUILD_VOICE_STATES = 1 << 7,
GuildVoiceStates = 1 << 7,
/**
* - PRESENCE_UPDATE
*/
GUILD_PRESENCES = 1 << 8,
GuildPresences = 1 << 8,
/**
* - MESSAGE_CREATE
* - MESSAGE_UPDATE
* - MESSAGE_DELETE
*/
GUILD_MESSAGES = 1 << 9,
GuildMessages = 1 << 9,
/**
* - MESSAGE_REACTION_ADD
* - MESSAGE_REACTION_REMOVE
* - MESSAGE_REACTION_REMOVE_ALL
* - MESSAGE_REACTION_REMOVE_EMOJI
*/
GUILD_MESSAGE_REACTIONS = 1 << 10,
GuildMessageReactions = 1 << 10,
/**
* - TYPING_START
*/
GUILD_MESSAGE_TYPING = 1 << 11,
GuildMessageTyping = 1 << 11,
/**
* - CHANNEL_CREATE
* - MESSAGE_CREATE
@@ -75,18 +75,18 @@ export enum DiscordGatewayIntents {
* - MESSAGE_DELETE
* - CHANNEL_PINS_UPDATE
*/
DIRECT_MESSAGES = 1 << 12,
DirectMessages = 1 << 12,
/**
* - MESSAGE_REACTION_ADD
* - MESSAGE_REACTION_REMOVE
* - MESSAGE_REACTION_REMOVE_ALL
* - MESSAGE_REACTION_REMOVE_EMOJI
*/
DIRECT_MESSAGE_REACTIONS = 1 << 13,
DirectMessageReactions = 1 << 13,
/**
* - TYPING_START
*/
DIRECT_MESSAGE_TYPING = 1 << 14,
DirectMessageTyping = 1 << 14,
}
export type Intents = DiscordGatewayIntents;
@@ -1,9 +1,9 @@
/** https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level */
export enum DiscordDefaultMessageNotificationLevels {
/** Members will receive notifications for all messages by default */
ALL_MESSAGES,
AllMessages,
/** Members will receive notifications only for messages that @mention them by default */
ONLY_MENTIONS,
OnlyMentions,
}
export type DefaultMessageNotificationLevels =
@@ -1,11 +1,11 @@
/** https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level */
export enum DiscordExplicitContentFilterLevels {
/** Media content will not be scanned */
DISABLED,
Disabled,
/** Media content sent by members without roles will be scanned */
MEMBERS_WITHOUT_ROLES,
MembersWithoutRoles,
/** Media content sent by all members will be scanned */
ALL_MEMBERS,
AllMembers,
}
export type ExplicitContentFilterLevels = DiscordExplicitContentFilterLevels;
@@ -1,15 +1,15 @@
/** https://discord.com/developers/docs/resources/guild#get-guild-widget-image-widget-style-options */
export enum DiscordGetGuildWidgetImageStyleOptions {
/** 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 */
BANNER_1 = "banner1",
Banner1 = "banner1",
/** 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 */
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 */
BANNER_4 = "banner4",
Banner4 = "banner4",
}
export type GetGuildWidgetImageStyleOptions =
+16 -16
View File
@@ -1,37 +1,37 @@
/** https://discord.com/developers/docs/resources/guild#guild-object-guild-features */
export enum DiscordGuildFeatures {
/** 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) */
VIP_REGIONS = "VIP_REGIONS",
VipRegions = "VIP_REGIONS",
/** Guild has access to set a vanity URL */
VANITY_URL = "VANITY_URL",
VanityUrl = "VANITY_URL",
/** Guild is verified */
VERIFIED = "VERIFIED",
Verified = "VERIFIED",
/** Guild is partnered */
PARTNERED = "PARTNERED",
Partnered = "PARTNERED",
/** 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) */
COMMERCE = "COMMERCE",
Commerce = "COMMERCE",
/** Guild has access to create news channels */
NEWS = "NEWS",
News = "NEWS",
/** Guild is able to be discovered in the directory */
DISCOVERABLE = "DISCOVERABLE",
Discoverable = "DISCOVERABLE",
/** guild cannot be discoverable */
DISCOVERABLE_DISABLED = "DISCOVERABLE_DISABLED",
DiscoverableDisabled = "DISCOVERABLE_DISABLED",
/** Guild is able to be featured in the directory */
FEATURABLE = "FEATURABLE",
Feature = "FEATURABLE",
/** 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 */
BANNER = "BANNER",
Banner = "BANNER",
/** 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) */
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 */
PREVIEW_ENABLED = "PREVIEW_ENABLED",
PreviewEnabled = "PREVIEW_ENABLED",
}
export type GuildFeatures = DiscordGuildFeatures;
+2 -2
View File
@@ -1,9 +1,9 @@
/** https://discord.com/developers/docs/resources/guild#guild-object-mfa-level */
export enum DiscordMfaLevels {
/** Guild has no MFA/2FA requirement for moderation actions */
NONE,
None,
/** Guild has a 2FA requirement for moderation actions */
ELEVATED,
Elevated,
}
export type MfaLevels = DiscordMfaLevels;
+4 -4
View File
@@ -1,13 +1,13 @@
/** https://discord.com/developers/docs/resources/guild#guild-object-premium-tier */
export enum DiscordPremiumTiers {
/** Guild has not unlocked any Server Boost perks */
NONE,
None,
/** Guild has unlocked Server Boost level 1 perks */
TIER_1,
Tier1,
/** Guild has unlocked Server Boost level 2 perks */
TIER_2,
Tier2,
/** Guild has unlocked Server Boost level 3 perks */
TIER_3,
Tier3,
}
export type PremiumTiers = DiscordPremiumTiers;
+3 -3
View File
@@ -1,11 +1,11 @@
/** https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags */
export enum DiscordSystemChannelFlags {
/** Suppress member join notifications */
SUPPRESS_JOIN_NOTIFICATIONS = 1 << 0,
SuppressJoinNotifications = 1 << 0,
/** Suppress server boost notifications */
SUPPRESS_PREMIUM_SUBSCRIPTIONS = 1 << 1,
SuppressPremiumSubscriptions = 1 << 1,
/** Suppress server setup tips */
SUPPRESS_GUILD_REMINDER_NOTIFICATIONS = 1 << 2,
SuppressGuildReminderNotifications = 1 << 2,
}
export type SystemChannelFlags = DiscordSystemChannelFlags;
+5 -5
View File
@@ -1,15 +1,15 @@
/** https://discord.com/developers/docs/resources/guild#guild-object-verification-level */
export enum DiscordVerificationLevels {
/** Unrestricted */
NONE,
None,
/** Must have verified email on account */
LOW,
Low,
/** Must be registered on Discord for longer than 5 minutes */
MEDIUM,
Medium,
/** Must be a member of the server for longer than 10 minutes */
HIGH,
High,
/** Must have a verified phone number */
VERY_HIGH,
VeryHigh,
}
export type VerificationLevels = DiscordVerificationLevels;
@@ -1,14 +1,14 @@
/** https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype */
export enum DiscordApplicationCommandOptionTypes {
SUB_COMMAND = 1,
SUB_COMMAND_GROUP,
STRING,
INTEGER,
BOOLEAN,
USER,
CHANNEL,
ROLE,
MENTIONABLE,
SubCommand = 1,
SubCommandGroup,
String,
Integer,
Boolean,
User,
Channel,
Role,
Mentionable,
}
export type ApplicationCommandOptionTypes =
+2 -2
View File
@@ -1,7 +1,7 @@
/** https://discord.com/developers/docs/resources/invite#invite-object-target-user-types */
export enum DiscordTargetTypes {
STREAM = 1,
EMBEDDED_APPLICATION,
Stream = 1,
EmbeddedApplication,
}
export type TargetTypes = DiscordTargetTypes;
+1 -3
View File
@@ -8,13 +8,11 @@ import { MessageComponents } from "./components/message_components.ts";
export interface CreateMessage {
/** The message contents (up to 2000 characters) */
content?: string;
/** A nonce that can be used for optimistic message sending */
nonce?: number | string;
/** true if this is a TTS message */
tts?: boolean;
/** Embedded `rich` content */
embed?: Embed;
/** Allowed mentions for a message */
/** Allowed mentions for the message */
allowedMentions?: AllowedMentions;
/** Include to make your message a reply */
messageReference?: MessageReference;
+3
View File
@@ -1,4 +1,5 @@
import { Embed } from "../embeds/embed.ts";
import { FileContent } from "../misc/file_content.ts";
import { AllowedMentions } from "./allowed_mentions.ts";
import { Attachment } from "./attachment.ts";
@@ -10,6 +11,8 @@ export interface EditMessage {
embed?: Embed | null;
/** Edit the flags of the message (only `SUPRESS_EMBEDS` can currently be set/unset) */
flags?: 4 | null;
/** The contents of the file being sent/edited */
file?: FileContent | FileContent[] | null;
/** Allowed mentions for the message */
allowedMentions?: AllowedMentions | null;
/** Attached files to keep */
+4 -4
View File
@@ -1,9 +1,9 @@
/** https://discord.com/developers/docs/resources/channel#message-object-message-activity-types */
export enum DiscordMessageActivityTypes {
JOIN = 1,
SPECTATE,
LISTEN,
JOIN_REQUEST,
Join = 1,
Spectate,
Listen,
JoinRequest,
}
export type MessageActivityTypes = DiscordMessageActivityTypes;
@@ -1,8 +1,8 @@
/** https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types */
export enum DiscordMessageStickerFormatTypes {
PNG = 1,
APNG,
LOTTIE,
Png = 1,
Apng,
Lottie,
}
export type MessageStickerFormatTypes = DiscordMessageStickerFormatTypes;
+6 -6
View File
@@ -1,11 +1,11 @@
/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-flags */
export enum DiscordActivityFlags {
INSTANCE = 1 << 0,
JOIN = 1 << 1,
SPECTATE = 1 << 2,
JOIN_REQUEST = 1 << 3,
SYNC = 1 << 4,
PLAY = 1 << 5,
Instance = 1 << 0,
Join = 1 << 1,
Spectate = 1 << 2,
JoinRequest = 1 << 3,
Sync = 1 << 4,
Play = 1 << 5,
}
export type ActivityFlags = DiscordActivityFlags;
+2 -2
View File
@@ -1,7 +1,7 @@
/** https://discord.com/developers/docs/topics/teams#data-models-membership-state-enum */
export enum DiscordTeamMembershipStates {
INVITED = 1,
ACCEPTED,
Invited = 1,
Accepted,
}
export type TeamMembershipStates = DiscordTeamMembershipStates;
+2 -2
View File
@@ -1,7 +1,7 @@
import { Embed } from "../embeds/embed.ts";
import { AllowedMentions } from "../messages/allowed_mentions.ts";
import { FileContent } from "../misc/file_content.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 */
export interface EditWebhookMessage {
@@ -10,7 +10,7 @@ export interface EditWebhookMessage {
/** Embedded `rich` content */
embeds?: Embed[] | null;
/** The contents of the file being sent/edited */
file?: FileContent | FileContent[];
file?: FileContent | FileContent[] | null;
/** Allowed mentions for the message */
allowedMentions?: AllowedMentions | null;
/** Attached files to keep */
+2
View File
@@ -7,6 +7,8 @@ import { SnakeCasedPropertiesDeep } from "../util.ts";
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) */
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) */
content?: string;
/** Override the default username of the webhook */
+4 -4
View File
@@ -130,11 +130,11 @@ function validateSlashOptionChoices(
}
if (
(optionType === DiscordApplicationCommandOptionTypes.STRING &&
(optionType === DiscordApplicationCommandOptionTypes.String &&
(typeof choice.value !== "string" ||
choice.value.length < 1 ||
choice.value.length > 100)) ||
(optionType === DiscordApplicationCommandOptionTypes.INTEGER &&
(optionType === DiscordApplicationCommandOptionTypes.Integer &&
typeof choice.value !== "number")
) {
throw new Error(Errors.INVALID_SLASH_OPTIONS_CHOICES);
@@ -152,8 +152,8 @@ function validateSlashOptions(options: ApplicationCommandOption[]) {
if (
option.choices?.length &&
(option.choices.length > 25 ||
(option.type !== DiscordApplicationCommandOptionTypes.STRING &&
option.type !== DiscordApplicationCommandOptionTypes.INTEGER))
(option.type !== DiscordApplicationCommandOptionTypes.String &&
option.type !== DiscordApplicationCommandOptionTypes.Integer))
) {
throw new Error(Errors.INVALID_SLASH_OPTIONS_CHOICES);
}
@@ -53,7 +53,7 @@ Deno.test({
permissionOverwrites: [
{
id: bigintToSnowflake(botId),
type: DiscordOverwriteTypes.MEMBER,
type: DiscordOverwriteTypes.Member,
allow: ["VIEW_CHANNEL"],
deny: [],
},
+1 -1
View File
@@ -141,7 +141,7 @@ Deno.test({
permissionOverwrites: [
{
id: bigintToSnowflake(botId),
type: DiscordOverwriteTypes.MEMBER,
type: DiscordOverwriteTypes.Member,
allow: ["VIEW_CHANNEL"],
deny: [],
},
+1 -1
View File
@@ -160,7 +160,7 @@ Deno.test({
permissionOverwrites: [
{
id: bigintToSnowflake(botId),
type: DiscordOverwriteTypes.MEMBER,
type: DiscordOverwriteTypes.Member,
allow: ["VIEW_CHANNEL"],
deny: [],
},
+1 -1
View File
@@ -56,7 +56,7 @@ Deno.test({
permissionOverwrites: [
{
id: bigintToSnowflake(botId),
type: DiscordOverwriteTypes.MEMBER,
type: DiscordOverwriteTypes.Member,
allow: ["VIEW_CHANNEL"],
deny: [],
},
+2 -2
View File
@@ -35,7 +35,7 @@ async function ifItFailsBlameWolf(options: CreateGuildChannel) {
}
await editChannelOverwrite(channel.guildId, channel.id, botId, {
type: DiscordOverwriteTypes.MEMBER,
type: DiscordOverwriteTypes.Member,
allow: ["VIEW_CHANNEL", "ADD_REACTIONS"],
deny: [],
});
@@ -71,7 +71,7 @@ Deno.test({
permissionOverwrites: [
{
id: bigintToSnowflake(botId),
type: DiscordOverwriteTypes.MEMBER,
type: DiscordOverwriteTypes.Member,
allow: ["VIEW_CHANNEL"],
deny: [],
},
+1 -1
View File
@@ -18,7 +18,7 @@ Deno.test({
permissionOverwrites: [
{
id: bigintToSnowflake(botId),
type: DiscordOverwriteTypes.MEMBER,
type: DiscordOverwriteTypes.Member,
allow: ["VIEW_CHANNEL"],
deny: [],
},
+1 -1
View File
@@ -114,7 +114,7 @@ Deno.test({
const option = {
name: "option1",
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.
const options: ApplicationCommandOption[] = Array(26).fill(option);
+4 -5
View File
@@ -36,11 +36,10 @@ Deno.test({
await startBot({
token,
intents: [
"GUILD_MESSAGES",
"GUILDS",
"GUILD_EMOJIS",
"GUILD_MESSAGE_REACTIONS",
"GUILD_EMOJIS",
"GuildMessages",
"Guilds",
"GuildEmojis",
"GuildMessageReactions",
],
});