Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: missing types #310

Merged
merged 2 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/api/Routes/applications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
RESTGetAPIApplicationGuildCommandsQuery,
RESTGetAPIApplicationGuildCommandsResult,
RESTGetAPIApplicationRoleConnectionMetadataResult,
RESTGetAPIEntitlementResult,
RESTGetAPIEntitlementsQuery,
RESTGetAPIEntitlementsResult,
RESTGetAPIGuildApplicationCommandsPermissionsResult,
Expand Down Expand Up @@ -112,6 +113,7 @@ export interface ApplicationRoutes {
(
id: string,
): {
get(args?: RestArgumentsNoBody<never>): Promise<RESTGetAPIEntitlementResult>;
delete(args?: RestArgumentsNoBody): Promise<never>;
consume: {
post(args?: RestArgumentsNoBody): Promise<never>;
Expand Down
7 changes: 6 additions & 1 deletion src/api/Routes/stickers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RESTGetAPIStickerResult, RESTGetStickerPacksResult } from '../../types';
import type { RESTGetAPIStickerPack, RESTGetAPIStickerResult, RESTGetStickerPacksResult } from '../../types';
import type { RestArgumentsNoBody } from '../api';

export interface StickerRoutes {
Expand All @@ -7,5 +7,10 @@ export interface StickerRoutes {
};
'sticker-packs': {
get(args?: RestArgumentsNoBody): Promise<RESTGetStickerPacksResult>;
(
id: string,
): {
get(args?: RestArgumentsNoBody): Promise<RESTGetAPIStickerPack>;
};
};
}
6 changes: 5 additions & 1 deletion src/types/payloads/_interactions/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
APIThreadChannel,
ThreadChannelType,
} from '../channel';
import type { APIGuildMember } from '../guild';
import type { APIGuildMember, APIPartialInteractionGuild } from '../guild';
import type { APIEntitlement } from '../monetization';
import type { APIRole } from '../permissions';
import type { APIUser } from '../user';
Expand Down Expand Up @@ -119,6 +119,10 @@ export interface APIBaseInteraction<Type extends InteractionType, Data> {
* The command data payload
*/
data?: Data;
/**
* The guild it was sent from
*/
guild?: APIPartialInteractionGuild;
/**
* The guild it was sent from
*/
Expand Down
4 changes: 2 additions & 2 deletions src/types/payloads/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ export interface APIApplication {
/**
* The interactions endpoint URL for the application
*/
interactions_endpoint_url?: string;
interactions_endpoint_url?: string | null;
/**
* The application's role connection verification entry point,
* which when configured will render the app as a verification method in the guild role verification configuration
*/
role_connections_verification_url?: string;
role_connections_verification_url?: string | null;
/**
* Up to 5 tags of max 20 characters each describing the content and functionality of the application
*/
Expand Down
45 changes: 45 additions & 0 deletions src/types/payloads/auditLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type {
} from './guild';
import type {
APIGuildScheduledEvent,
APIGuildScheduledEventRecurrenceRule,
GuildScheduledEventEntityType,
GuildScheduledEventStatus,
} from './guildScheduledEvent';
Expand Down Expand Up @@ -196,6 +197,10 @@ export enum AuditLogEvent {

ApplicationCommandPermissionUpdate = 121,

SoundboardSoundCreate = 130,
SoundboardSoundUpdate,
SoundboardSoundDelete,

AutoModerationRuleCreate = 140,
AutoModerationRuleUpdate,
AutoModerationRuleDelete,
Expand Down Expand Up @@ -372,6 +377,8 @@ export type APIAuditLogChange =
| APIAuditLogChangeKeyDeny
| APIAuditLogChangeKeyDescription
| APIAuditLogChangeKeyDiscoverySplashHash
| APIAuditLogChangeKeyEmojiId
| APIAuditLogChangeKeyEmojiName
| APIAuditLogChangeKeyEnabled
| APIAuditLogChangeKeyEnableEmoticons
| APIAuditLogChangeKeyEntityType
Expand Down Expand Up @@ -404,12 +411,14 @@ export type APIAuditLogChange =
| APIAuditLogChangeKeyPermissions
| APIAuditLogChangeKeyPosition
| APIAuditLogChangeKeyPreferredLocale
| APIAuditLogChangeKeyPremiumProgressBarEnabled
| APIAuditLogChangeKeyPrivacyLevel
| APIAuditLogChangeKeyPruneDeleteDays
| APIAuditLogChangeKeyPublicUpdatesChannelId
| APIAuditLogChangeKeyRateLimitPerUser
| APIAuditLogChangeKeyRegion
| APIAuditLogChangeKeyRulesChannelId
| APIAuditLogChangeKeySoundId
| APIAuditLogChangeKeySplashHash
| APIAuditLogChangeKeyStatus
| APIAuditLogChangeKeySystemChannelFlags
Expand All @@ -420,10 +429,12 @@ export type APIAuditLogChange =
| APIAuditLogChangeKeyTriggerMetadata
| APIAuditLogChangeKeyTriggerType
| APIAuditLogChangeKeyType
| APIAuditLogChangeKeyUserId
| APIAuditLogChangeKeyUserLimit
| APIAuditLogChangeKeyUses
| APIAuditLogChangeKeyVanityURLCode
| APIAuditLogChangeKeyVerificationLevel
| APIAuditLogChangeKeyVolume
| APIAuditLogChangeKeyWidgetChannelId
| APIAuditLogChangeKeyWidgetEnabled;

Expand Down Expand Up @@ -533,6 +544,11 @@ export type APIAuditLogChangeKeyDefaultMessageNotifications = AuditLogChangeData
*/
export type APIAuditLogChangeKeyVanityURLCode = AuditLogChangeData<'vanity_url_code', string>;

/**
* Returned when a guild's boost progress bar is enabled
*/
export type APIAuditLogChangeKeyPremiumProgressBarEnabled = AuditLogChangeData<'premium_progress_bar_enabled', boolean>;

/**
* Returned when new role(s) are added
*/
Expand Down Expand Up @@ -607,6 +623,14 @@ export type APIAuditLogChangeKeyApplicationId = AuditLogChangeData<'application_
*/
export type APIAuditLogChangeKeyRateLimitPerUser = AuditLogChangeData<'rate_limit_per_user', number>;

/**
* Returned when a guild scheduled event's recurrence_rule is changed
*/
export type APIAuditLogChangeKeyRecurrenceRule = AuditLogChangeData<
'recurrence_rule',
APIGuildScheduledEventRecurrenceRule
>;

/**
* Returned when a permission bitfield is changed
*/
Expand Down Expand Up @@ -866,6 +890,27 @@ export type APIAuditLogChangeKeyDefaultThreadRateLimitPerUser = AuditLogChangeDa
number
>;

/**
* Returned when a soundboard is create or deleted
*/
export type APIAuditLogChangeKeySoundId = AuditLogChangeData<'sound_id', Snowflake>;
/**
* Returned when a soundboard's volume is changed
*/
export type APIAuditLogChangeKeyVolume = AuditLogChangeData<'volume', number>;
/**
* Returned when a soundboard's custom emoji is changed
*/
export type APIAuditLogChangeKeyEmojiId = AuditLogChangeData<'emoji_id', Snowflake>;
/**
* Returned when a soundboard's unicode emoji is changed
*/
export type APIAuditLogChangeKeyEmojiName = AuditLogChangeData<'emoji_name', string>;
/**
* Returned when a sounboard is created
*/
export type APIAuditLogChangeKeyUserId = AuditLogChangeData<'user_id', Snowflake>;

interface AuditLogChangeData<K extends string, D> {
key: K;
/**
Expand Down
6 changes: 1 addition & 5 deletions src/types/payloads/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -748,10 +748,6 @@ export interface APIMessageSnapshot {
* Subset of the message object fields
*/
message: APIMessageSnapshotFields;
/**
* Id of the origin message's guild
*/
guild_id?: Snowflake;
}

export type APIMessageSnapshotFields = Pick<
Expand Down Expand Up @@ -981,7 +977,7 @@ export interface APIThreadMetadata {
/**
* Whether the thread is locked; when a thread is locked, only users with `MANAGE_THREADS` can unarchive it
*/
locked?: boolean;
locked: boolean;
/**
* Whether non-moderators can add other non-moderators to the thread; only available on private threads
*/
Expand Down
4 changes: 2 additions & 2 deletions src/types/payloads/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import type { Snowflake } from '../index';
import type { APIChannel, APIThreadMember } from './channel';
import type { APIThreadChannel, APIThreadMember } from './channel';
import type { APIEmoji } from './emoji';
import type { APIUser } from './user';

Expand Down Expand Up @@ -361,7 +361,7 @@ export interface GatewayThreadListSync {
/**
* Array of the synced threads
*/
threads: APIChannel[];
threads: APIThreadChannel[];
/**
* The member objects for the client user in each joined thread that was synced
*/
Expand Down
17 changes: 15 additions & 2 deletions src/types/payloads/guild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Types extracted from https://discord.com/developers/docs/resources/guild
*/

import type { GuildMemberFlags, Permissions, Snowflake } from '../index';
import type { GuildMemberFlags, Locale, LocaleString, Permissions, Snowflake } from '../index';
import type { APIEmoji, APIPartialEmoji } from './emoji';
import type { PresenceUpdateReceiveStatus } from './gateway';
import type { OAuth2Scopes } from './oauth2';
Expand Down Expand Up @@ -227,7 +227,7 @@ export interface APIGuild extends APIPartialGuild {
*
* @default "en-US"
*/
preferred_locale: string;
preferred_locale: LocaleString;
/**
* The id of the channel where admins and moderators of Community guilds receive notices from Discord
*/
Expand Down Expand Up @@ -282,6 +282,19 @@ export interface APIGuild extends APIPartialGuild {
safety_alerts_channel_id: Snowflake | null;
}

/**
* https://discord.com/developers/docs/resources/guild#guild-object-guild-structure
*/
export interface APIPartialInteractionGuild extends Pick<APIGuild, 'features' | 'id'> {
/**
* The preferred locale of a Community guild; used in guild discovery and notices from Discord; defaults to "en-US"
*
* @unstable https://github.com/discord/discord-api-docs/issues/6938
* @default "en-US"
*/
locale: Locale;
}

/**
* https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level
*/
Expand Down
105 changes: 103 additions & 2 deletions src/types/payloads/guildScheduledEvent.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Snowflake } from '../index';
import type { Snowflake } from '..';
import type { APIGuildMember } from './guild';
import type { APIUser } from './user';

interface APIGuildScheduledEventBase<Type extends GuildScheduledEventEntityType> {
/**
* The id of the guild event
Expand Down Expand Up @@ -67,6 +66,108 @@ interface APIGuildScheduledEventBase<Type extends GuildScheduledEventEntityType>
* The cover image of the scheduled event
*/
image?: string | null;
/**
* The definition for how often this event should recur
*/
recurrence_rule: APIGuildScheduledEventRecurrenceRule | null;
}
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-recurrence-rule-object-guild-scheduled-event-recurrence-rule-structure
*/
export interface APIGuildScheduledEventRecurrenceRule {
/**
* Starting time of the recurrence interval
*/
start: string;
/**
* Ending time of the recurrence interval
*/
end: string | null;
/**
* How often the event occurs
*/
frequency: GuildScheduledEventRecurrenceRuleFrequency;
/**
* The spacing between the events, defined by `frequency`.
* For example, `frequency` of {@apilink GuildScheduledEventRecurrenceRuleFrequency#Weekly} and an `interval` of `2`
* would be "every-other week"
*/
interval: number;
/**
* Set of specific days within a week for the event to recur on
*/
by_weekday: GuildScheduledEventRecurrenceRuleWeekday[] | null;
/**
* List of specific days within a specific week (1-5) to recur on
*/
by_n_weekday: GuildScheduledEventRecurrenceRuleNWeekday[] | null;
/**
* Set of specific months to recur on
*/
by_month: GuildScheduledEventRecurrenceRuleMonth[] | null;
/**
* Set of specific dates within a month to recur on
*/
by_month_day: number[] | null;
/**
* Set of days within a year to recur on (1-364)
*/
by_year_day: number[] | null;
/**
* The total amount of times that the event is allowed to recur before stopping
*/
count: number | null;
}
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-recurrence-rule-object-guild-scheduled-event-recurrence-rule-frequency
*/
export declare enum GuildScheduledEventRecurrenceRuleFrequency {
Yearly = 0,
Monthly = 1,
Weekly = 2,
Daily = 3,
}
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-recurrence-rule-object-guild-scheduled-event-recurrence-rule-weekday
*/
export declare enum GuildScheduledEventRecurrenceRuleWeekday {
Monday = 0,
Tuesday = 1,
Wednesday = 2,
Thursday = 3,
Friday = 4,
Saturday = 5,
Sunday = 6,
}
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-recurrence-rule-object-guild-scheduled-event-recurrence-rule-month
*/
export declare enum GuildScheduledEventRecurrenceRuleMonth {
January = 1,
February = 2,
March = 3,
April = 4,
May = 5,
June = 6,
July = 7,
August = 8,
September = 9,
October = 10,
November = 11,
December = 12,
}
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-recurrence-rule-object-guild-scheduled-event-recurrence-rule-nweekday-structure
*/
export interface GuildScheduledEventRecurrenceRuleNWeekday {
/**
* The week to reoccur on.
*/
n: 1 | 2 | 3 | 4 | 5;
/**
* The day within the week to reoccur on
*/
day: GuildScheduledEventRecurrenceRuleWeekday;
}

export interface APIStageInstanceGuildScheduledEvent
Expand Down
10 changes: 6 additions & 4 deletions src/types/payloads/monetization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ export interface APIEntitlement {
*/
deleted: boolean;
/**
* Start date at which the entitlement is valid. Not present when using test entitlements.
* Start date at which the entitlement is valid.
*/
starts_at?: string;
starts_at: string | null;
/**
* Date at which the entitlement is no longer valid. Not present when using test entitlements.
* Date at which the entitlement is no longer valid.
*/
ends_at?: string | null;
ends_at: string | null;
/**
* For consumable items, whether or not the entitlement has been consumed
*/
Expand Down Expand Up @@ -163,6 +163,8 @@ export interface APISubscription {
sku_ids: string[];
/** List of entitlements granted for this subscription */
entitlements_ids: string[];
/** List of SKUs that this user will be subscribed to at renewal */
renewal_sku_ids: Snowflake[] | null;
/** Start of the current subscription period */
current_period_start: string;
/** End of the current subscription period */
Expand Down
Loading
Loading