lilybird
Version:
A bun-first discord api wrapper written in TS
408 lines • 24.4 kB
TypeScript
import type { AuditLogEvent, MFALevel, OnboardingMode, PrivacyLevel } from "#enums";
import type { ListArchivedThreadsReturnStructure, GetGatewayBotResponse, ApplicationCommand, LilybirdAttachment, AutoModeration, DebugFunction, StageInstance, Application, Interaction, AuditLog, Channel, Message, Sticker, Webhook, Invite, Emoji, Guild, Voice, Role, User, Poll } from "../typings/index.js";
export interface DiscordErrorMessage {
code: number;
message: string;
errors?: Record<string, unknown>;
}
export declare class RestError extends Error {
readonly code: number;
readonly errors: DiscordErrorMessage["errors"];
constructor(error: DiscordErrorMessage);
}
export type TokenType = "Bearer" | "Bot";
export declare class REST {
#private;
static readonly BaseURL = "https://discord.com/api/v10/";
constructor(token?: string, tokenType?: TokenType);
makeAPIRequest<T>(method: "GET" | "POST" | "PATCH" | "DELETE" | "PUT", path: string, data: FormData, reason?: string): Promise<T>;
makeAPIRequest<T>(method: "GET" | "POST" | "PATCH" | "DELETE" | "PUT", path: string, data?: Record<string, any>, files?: Array<LilybirdAttachment>): Promise<T>;
setToken(token: string | undefined, tokenType?: TokenType): void;
getGateway(): Promise<{
url: string;
}>;
getGatewayBot(): Promise<GetGatewayBotResponse>;
getGlobalApplicationCommands(clientId: string): Promise<Array<ApplicationCommand.GlobalStructure>>;
getGlobalApplicationCommands(clientId: string, withLocalizations: true): Promise<Array<ApplicationCommand.Localized.GlobalStructure>>;
createGlobalApplicationCommand(clientId: string, body: ApplicationCommand.Create.ApplicationCommandJSONParams): Promise<ApplicationCommand.Localizations.GlobalStructure>;
getGlobalApplicationCommand(clientId: string, commandId: string): Promise<ApplicationCommand.Localizations.GlobalStructure>;
editGlobalApplicationCommand(clientId: string, commandId: string, body: Partial<ApplicationCommand.Create.ApplicationCommandJSONParams>): Promise<ApplicationCommand.Localizations.GlobalStructure>;
deleteGlobalApplicationCommand(clientId: string, commandId: string): Promise<null>;
bulkOverwriteGlobalApplicationCommand(clientId: string, body: Array<ApplicationCommand.Create.ApplicationCommandJSONParams>): Promise<Array<ApplicationCommand.Localizations.GlobalStructure>>;
getGuildApplicationCommands(clientId: string): Promise<Array<ApplicationCommand.GuildStructure>>;
getGuildApplicationCommands(clientId: string, withLocalizations: true): Promise<Array<ApplicationCommand.Localized.GuildStructure>>;
createGuildApplicationCommand(clientId: string, guildId: string, body: ApplicationCommand.Create.ApplicationCommandJSONParams): Promise<ApplicationCommand.Localizations.GuildStructure>;
getGuildApplicationCommand(clientId: string, guildId: string, commandId: string): Promise<ApplicationCommand.Localizations.GuildStructure>;
editGuildApplicationCommand(clientId: string, guildId: string, commandId: string, body: Partial<ApplicationCommand.Create.ApplicationCommandJSONParams>): Promise<ApplicationCommand.Localizations.GuildStructure>;
deleteGuildApplicationCommand(clientId: string, guildId: string, commandId: string): Promise<null>;
bulkOverwriteGuildApplicationCommand(clientId: string, guildId: string, body: Array<ApplicationCommand.Create.ApplicationCommandJSONParams>): Promise<Array<ApplicationCommand.Localizations.GuildStructure>>;
getGuildApplicationCommandPermissions(clientId: string, guildId: string): Promise<Array<ApplicationCommand.GuildPermissionsStructure>>;
getApplicationCommandPermissions(clientId: string, guildId: string, commandId: string): Promise<ApplicationCommand.GuildPermissionsStructure>;
editApplicationCommandPermissions(clientId: string, guildId: string, commandId: string, body: {
permissions: Array<ApplicationCommand.PermissionsStructure>;
}): Promise<ApplicationCommand.GuildPermissionsStructure>;
createInteractionResponse(interactionId: string, interactionToken: string, body: Interaction.ResponseJSONParams, files?: Array<LilybirdAttachment>): Promise<null>;
getOriginalInteractionResponse(clientId: string, interactionToken: string): Promise<Message.Structure>;
editOriginalInteractionResponse(clientId: string, interactionToken: string, body: Webhook.EditWebhookJSONParams, files?: Array<LilybirdAttachment>): Promise<Message.Structure>;
deleteOriginalInteractionResponse(clientId: string, interactionToken: string): Promise<null>;
createFollowupMessage(clientId: string, interactionToken: string, body: Webhook.ExecuteWebhookJSONParams, files?: Array<LilybirdAttachment>): Promise<Message.Structure>;
getFollowupMessage(clientId: string, interactionToken: string, messageId: string): Promise<Message.Structure>;
editFollowupMessage(clientId: string, interactionToken: string, messageId: string, body: Webhook.EditWebhookJSONParams, files?: Array<LilybirdAttachment>): Promise<Message.Structure>;
deleteFollowupMessage(clientId: string, interactionToken: string, messageId: string): Promise<null>;
getCurrentApplication(): Promise<Application.Structure>;
editCurrentApplication(app: Application.EditApplicationJSONParams): Promise<Application.Structure>;
getApplicationRoleConnectionMetadataRecords(applicationId: string): Promise<Array<Application.RoleConnectionMetadataStructure>>;
updateApplicationRoleConnectionMetadataRecords(applicationId: string): Promise<Array<Application.RoleConnectionMetadataStructure>>;
getGuildAuditLog(guildId: string, params: {
user_id?: string;
action_type?: AuditLogEvent;
before?: string;
after?: string;
limit?: number;
}): Promise<AuditLog.Structure>;
listAutoModerationRulesForGuild(guildId: string): Promise<Array<AutoModeration.RuleStructure>>;
getAutoModerationRule(guildId: string, ruleId: string): Promise<AutoModeration.RuleStructure>;
createAutoModerationRule(guildId: string, rule: AutoModeration.CreateJSONParams): Promise<AutoModeration.RuleStructure>;
modifyAutoModerationRule(guildId: string, ruleId: string, rule: Partial<Omit<AutoModeration.CreateJSONParams, "trigger_type">>): Promise<AutoModeration.RuleStructure>;
deleteAutoModerationRule(guildId: string, ruleId: string, reason: string): Promise<null>;
getChannel(channelId: string): Promise<Channel.Structure>;
modifyChannel(channelId: string, body: Channel.Modify.GuildChannelStructure | Channel.Modify.DMChannelStructure | Channel.Modify.ThreadChannelStructure): Promise<Channel.Structure>;
deleteChannel(channelId: string, reason?: string): Promise<Channel.Structure>;
editChannelPermissions(channelId: string, overwriteId: string, params: {
reason?: string;
allow?: string | null;
deny?: string | null;
type: 0 | 1;
}): Promise<null>;
getChannelInvites(channelId: string): Promise<Array<Invite.Structure>>;
createChannelInvite(channelId: string, body: Invite.CreateJSONParams): Promise<Invite.Structure>;
deleteChannelPermission(channelId: string, overwriteId: string, reason?: string): Promise<null>;
followAnnouncementChannel(channelId: string, body: {
webhook_channel_id?: string;
}): Promise<Channel.FollowedChannelStructure>;
triggerTypingIndicator(channelId: string): Promise<null>;
getPinnedMessages(channelId: string): Promise<null>;
pinMessage(channelId: string, messageId: string, reason?: string): Promise<null>;
unpinMessage(channelId: string, messageId: string, reason?: string): Promise<null>;
groupDMAddRecipient(channelId: string, userId: string, body: {
access_token: string;
nick: string;
}): Promise<null>;
groupDMRemoveRecipient(channelId: string, userId: string): Promise<null>;
startThreadFromMessage(channelId: string, messageId: string, body: Channel.Create.ThreadFromMessageJSONParams): Promise<Channel.Structure>;
startThreadWithoutMessage(channelId: string, body: Channel.Create.ThreadJSONParams): Promise<Channel.Structure>;
startThreadInForumOrMediaChannel(channelId: string, body: Channel.Create.ForumMediaThreadJSONParams, files?: Array<LilybirdAttachment>): Promise<Channel.Structure>;
joinThread(channelId: string): Promise<null>;
addThreadMember(channelId: string, userId: string): Promise<null>;
leaveThread(channelId: string): Promise<null>;
removeThreadMember(channelId: string, userId: string): Promise<null>;
getThreadMember(channelId: string, userId: string, withMember?: boolean): Promise<Channel.ThreadMemberStructure>;
listThreadMembers(channelId: string, params?: {
after?: number;
limit?: string;
}): Promise<Array<Channel.ThreadMemberStructure>>;
listPublicArchivedThreads(channelId: string, params?: {
before?: string;
limit?: string;
}): Promise<ListArchivedThreadsReturnStructure>;
listPrivateArchivedThreads(channelId: string, params?: {
before?: string;
limit?: string;
}): Promise<ListArchivedThreadsReturnStructure>;
listJoinedPrivateArchivedThreads(channelId: string, params?: {
before?: string;
limit?: string;
}): Promise<ListArchivedThreadsReturnStructure>;
listGuildEmojis(guildId: string): Promise<Array<Emoji.Structure>>;
getGuildEmoji(guildId: string, emojiId: string): Promise<Emoji.Structure>;
createGuildEmoji(guildId: string, params: {
name: string;
image: ImageData;
roles: Array<string>;
reason?: string;
}): Promise<Emoji.Structure>;
modifyGuildEmoji(guildId: string, emojiId: string, params: {
name?: string;
roles?: Array<string> | null;
reason: string;
}): Promise<Emoji.Structure>;
deleteGuildEmoji(guildId: string, emojiId: string, reason?: string): Promise<null>;
listApplicationEmojis(applicationId: string): Promise<Array<Emoji.Structure>>;
getApplicationEmoji(applicationId: string, emojiId: string): Promise<Emoji.Structure>;
createApplicationEmoji(applicationId: string, params: {
name: string;
image: ImageData;
}): Promise<Emoji.Structure>;
modifyApplicationEmoji(applicationId: string, emojiId: string, params: {
name: string;
}): Promise<Emoji.Structure>;
deleteApplicationEmoji(applicationId: string, emojiId: string): Promise<null>;
getGuild(guildId: string, withCounts?: boolean): Promise<Guild.Structure>;
getGuildPreview(guildId: string): Promise<Guild.PreviewStructure>;
modifyGuild(guildId: string, body: Guild.Modify.GuildJSONParams): Promise<Guild.Structure>;
deleteGuild(guildId: string): Promise<null>;
getGuildChannels(guildId: string): Promise<Array<Channel.Structure>>;
createGuildChannel(guildId: string, body: Guild.Create.GuildChannelJSONParams): Promise<Channel.Structure>;
modifyGuildChannelPositions(guildId: string, body: Array<Guild.Modify.ChannelPositionJSONParams>): Promise<Channel.Structure>;
listActiveGuildThreads(guildId: string): Promise<{
threads: Array<Channel.ThreadChannelStructure>;
members: Array<Channel.ThreadMemberStructure>;
}>;
getGuildMember(guildId: string, userId: string): Promise<Guild.MemberStructure>;
listGuildMembers(guildId: string, params: {
limit: number;
after: string;
}): Promise<Array<Guild.MemberStructure>>;
searchGuildMembers(guildId: string, params: {
query: string;
limit: number;
}): Promise<Array<Guild.MemberStructure>>;
addGuildMember(guildId: string, userId: string, body: {
access_token: string;
nick?: string;
roles?: Array<string>;
mute?: boolean;
deaf?: boolean;
}): Promise<Guild.MemberStructure | null>;
modifyGuildMember(guildId: string, userId: string, body: {
reason?: string | null;
nick?: string | null;
roles?: Array<string> | null;
mute?: boolean | null;
deaf?: boolean | null;
channel_id?: string | null;
communication_disabled_until?: string | null;
flags?: number | null;
}): Promise<Guild.MemberStructure>;
modifyCurrentMember(guildId: string, body: {
reason?: string | null;
nick?: string | null;
}): Promise<Guild.MemberStructure>;
addGuildMemberRole(guildId: string, userId: string, roleId: string, reason: string): Promise<null>;
removeGuildMemberRole(guildId: string, userId: string, roleId: string, reason: string): Promise<null>;
removeGuildMember(guildId: string, userId: string, reason: string): Promise<null>;
getGuildBans(guildId: string, params: {
before: string;
after: string;
limit: string;
}): Promise<Array<Guild.BanStructure>>;
getGuildBan(guildId: string, userId: string): Promise<Guild.BanStructure>;
createGuildBan(guildId: string, userId: string, body: {
reason?: string;
delete_message_seconds?: number;
}): Promise<null>;
removeGuildBan(guildId: string, userId: string, reason?: string): Promise<null>;
getGuildRoles(guildId: string): Promise<Array<Role.Structure>>;
getGuildRole(guildId: string, roleId: string): Promise<Role.Structure>;
createGuildRole(guildId: string, body: Role.JSONParams): Promise<Role.Structure>;
modifyGuildRolePosition(guildId: string, body: {
reason?: string;
id: string;
position?: number | null;
}): Promise<Array<Role.Structure>>;
modifyGuildRole(guildId: string, roleId: string, body: Partial<Role.JSONParams>): Promise<Role.Structure>;
modifyGuildMFALevel(guildId: string, level: MFALevel): Promise<MFALevel>;
deleteGuildRole(guildId: string, roleId: string, reason?: string): Promise<null>;
getGuildPruneCount(guildId: string, params: {
days: number;
include_roles?: string;
}): Promise<{
pruned: number;
}>;
beginGuildPrune(guildId: string, body: {
days?: number;
compute_prune_count?: boolean;
include_roles?: Array<string>;
reason?: string;
}): Promise<{
pruned: number | null;
}>;
getGuildVoiceRegions(guildId: string): Promise<Array<Voice.RegionStructure>>;
getGuildInvites(guildId: string): Promise<Array<Invite.Structure>>;
getGuildIntegrations(guildId: string): Promise<Array<Guild.IntegrationStructure>>;
deleteGuildIntegration(guildId: string, integrationId: string, reason?: string): Promise<null>;
getGuildWidgetSettings(guildId: string): Promise<Guild.WidgetSettingsStructure>;
modifyGuildWidget(guildId: string, body: Guild.WidgetSettingsStructure & {
reason?: string;
}): Promise<Guild.WidgetSettingsStructure>;
getGuildWidget(guildId: string): Promise<Guild.WidgetStructure>;
getGuildVanityUrl(guildId: string): Promise<Partial<Invite.Structure>>;
getGuildWidgetImage(guildId: string, style?: string): Promise<string>;
getGuildWelcomeScreen(guildId: string): Promise<Guild.WelcomeScreenStructure>;
modifyGuildWelcomeScreen(guildId: string, body: {
reason?: string;
enabled?: boolean | null;
welcome_channels?: Array<Guild.WelcomeScreenChannelStructure> | null;
description?: string | null;
}): Promise<Guild.WelcomeScreenStructure>;
getGuildOnboarding(guildId: string): Promise<Guild.OnboardingStructure>;
modifyGuildOnboarding(guildId: string, body: {
reason?: string;
prompts: Array<Guild.OnboardingPromptStructure>;
default_channel_ids: Array<string>;
enabled: boolean;
mode: OnboardingMode;
}): Promise<Guild.OnboardingStructure>;
modifyCurrentUserVoiceState(guildId: string, body: {
channel_id?: string;
suppress?: boolean;
request_to_speak_timestamp?: string | null;
}): Promise<null>;
modifyUserVoiceState(guildId: string, userId: string, body: {
channel_id: string;
suppress?: boolean;
}): Promise<null>;
listScheduledEventsForGuild(guildId: string, params: {
with_user_count?: boolean;
}): Promise<Array<Guild.ScheduledEventStructure>>;
createGuildScheduledEvent(guildId: string, event: Guild.Create.ScheduledEventJSONParams): Promise<Guild.ScheduledEventStructure>;
getGuildScheduledEvent(guildId: string, eventId: string, params: {
with_user_count?: boolean;
}): Promise<Array<Guild.ScheduledEventStructure>>;
modifyGuildScheduledEvent(guildId: string, eventId: string, event: Partial<Guild.Create.ScheduledEventJSONParams>): Promise<Guild.ScheduledEventStructure>;
deleteGuildScheduledEvent(guildId: string, eventId: string): Promise<null>;
getGuildScheduledEventUsers(guildId: string, eventId: string, params: {
limit?: number;
with_member?: boolean;
before?: string;
after?: string;
}): Promise<{
guild_scheduled_event_id: string;
user: User.Structure;
member?: Guild.MemberStructure;
}>;
getGuildTemplate(templateCode: string): Promise<Guild.TemplateStructure>;
createGuildFromGuildTemplate(templateCode: string, guild: {
name: string;
image?: ImageData;
}): Promise<Guild.Structure>;
getGuildTemplates(guildId: string): Promise<Array<Guild.TemplateStructure>>;
createGuildTemplate(guildId: string, template: {
name: string;
description?: string | null;
}): Promise<Guild.TemplateStructure>;
syncGuildTemplate(guildId: string, templateCode: string): Promise<Array<Guild.TemplateStructure>>;
modifyGuildTemplate(guildId: string, templateCode: string, template: {
name?: string;
description?: string | null;
}): Promise<Guild.TemplateStructure>;
deleteGuildTemplate(guildId: string, templateCode: string): Promise<Guild.TemplateStructure>;
getInvite(inviteCode: string): Promise<Invite.Structure>;
deleteInvite(inviteCode: string, reason?: string): Promise<Invite.Structure>;
getChannelMessages(channelId: string, params: {
around?: string;
before?: string;
after?: string;
limit?: number;
}): Promise<Array<Message.Structure>>;
getChannelMessage(channelId: string, messageId: string): Promise<Message.Structure>;
createMessage(channelId: string, body: Message.CreateJSONParams, files?: Array<LilybirdAttachment>): Promise<Message.Structure>;
crosspostMessage(channelId: string, messageId: string): Promise<Message.Structure>;
createReaction(channelId: string, messageId: string, emoji: string, isCustom?: boolean): Promise<null>;
deleteOwnReaction(channelId: string, messageId: string, emoji: string, isCustom?: boolean): Promise<null>;
deleteUserReaction(channelId: string, messageId: string, userId: string, emoji: string, isCustom?: boolean): Promise<null>;
getReactions(channelId: string, messageId: string, emoji: string, isCustom?: boolean, params?: {
after?: number;
limit?: string;
}): Promise<Array<User.Structure>>;
deleteAllReactions(channelId: string, messageId: string): Promise<null>;
deleteAllReactionsForEmoji(channelId: string, messageId: string, emoji: string, isCustom?: boolean): Promise<null>;
editMessage(channelId: string, messageId: string, body: Message.EditJSONParams, files?: Array<LilybirdAttachment>): Promise<Message.Structure>;
deleteMessage(channelId: string, messageId: string, reason?: string): Promise<null>;
bulkDeleteMessages(channelId: string, messageIds: Array<string>, reason?: string): Promise<null>;
getAnswerVoters(channelId: string, messageId: string, answerId: number, params: {
after?: string;
limit?: number;
}): Promise<Poll.AnswerVotersStructure>;
endPoll(channelId: string, messageId: string): Promise<Message.Structure>;
createStageInstance(instance: StageInstance.CreateJSONParams): Promise<StageInstance.Structure>;
getStageInstance(channelId: string): Promise<StageInstance.Structure>;
modifyStageInstance(channelId: string, data: {
topic?: string;
privacy_level?: PrivacyLevel;
reason?: string;
}): Promise<StageInstance.Structure>;
deleteStageInstance(channelId: string, reason?: string): Promise<null>;
getSticker(stickerId: string): Promise<Sticker.Structure>;
listStickerPacks(): Promise<{
sticker_packs: Array<Sticker.PackStructure>;
}>;
getStickerPack(packId: string): Promise<Sticker.PackStructure>;
listGuildStickers(guildId: string): Promise<Array<Sticker.Structure>>;
getGuildSticker(guildId: string, stickerId: string): Promise<Sticker.Structure>;
createGuildSticker(guildId: string, stickerId: string, params: {
name: string;
description: string;
tags: string;
file: Blob;
reason?: string;
}): Promise<Sticker.Structure>;
modifyGuildSticker(guildId: string, stickerId: string, params: {
name?: string;
description?: string;
tags?: string;
reason?: string;
}): Promise<Sticker.Structure>;
deleteGuildSticker(guildId: string, stickerId: string, reason?: string): Promise<null>;
getCurrentUser(): Promise<User.Structure>;
getUser(userId: string): Promise<User.Structure>;
modifyCurrentUser(body?: {
username?: string;
avatar?: string;
}): Promise<User.Structure>;
getCurrentUserGuilds(params: {
before: string;
after: string;
limit: string;
withCounts: boolean;
}): Promise<Array<Partial<Guild.Structure>>>;
getCurrentUserGuildMember(guildId: string): Promise<Guild.MemberStructure>;
leaveGuild(guildId: string): Promise<null>;
createDM(userId: string): Promise<Channel.DMChannelStructure>;
createGroupDM(tokens: Array<string>, nicks: Record<string, string>): Promise<Channel.DMChannelStructure>;
listVoiceRegions(): Promise<Array<Voice.RegionStructure>>;
getCurrentUserVoiceState(guildId: string): Promise<Voice.StateStructure>;
getUserVoiceState(guildId: string, userId: string): Promise<Voice.StateStructure>;
createWebhook(channelId: string, webhook: {
name: string;
avatar?: ImageData | null;
}): Promise<Webhook.Structure>;
getChannelWebhooks(channelId: string): Promise<Array<Webhook.Structure>>;
getGuildWebhooks(guildId: string): Promise<Array<Webhook.Structure>>;
getWebhook(webhookId: string): Promise<Webhook.Structure>;
getWebhookWithToken(webhookId: string, token: string): Promise<Webhook.Structure>;
modifyWebhook(webhookId: string, webhook: {
name?: string;
avatar?: ImageData | null;
channel_id?: string;
reason?: string;
}): Promise<Webhook.Structure>;
modifyWebhookWithToken(webhookId: string, token: string, webhook: {
name?: string;
avatar?: ImageData | null;
channel_id?: string;
reason?: string;
}): Promise<Webhook.Structure>;
deleteWebhook(webhookId: string, reason?: string): Promise<Webhook.Structure>;
deleteWebhookWithToken(webhookId: string, token: string, reason?: string): Promise<Webhook.Structure>;
executeWebhook(webhookId: string, token: string, params: {
wait?: boolean;
thread_id?: string;
}, body: Webhook.ExecuteWebhookJSONParams, files?: Array<LilybirdAttachment>): Promise<Message.Structure | null>;
getWebhookMessage(webhookId: string, token: string, messageId: string, params: {
thread_id?: string;
}): Promise<Message.Structure>;
editWebhookMessage(webhookId: string, token: string, messageId: string, params: {
thread_id?: string;
}, body: Webhook.EditWebhookJSONParams, files?: Array<LilybirdAttachment>): Promise<Message.Structure>;
deleteWebhookMessage(webhookId: string, token: string, messageId: string, params: {
thread_id?: string;
}): Promise<null>;
}
export declare class DebugREST extends REST {
#private;
constructor(debug?: DebugFunction, token?: string);
makeAPIRequest<T>(method: "GET" | "POST" | "PATCH" | "DELETE" | "PUT", path: string, data: FormData, reason?: string | undefined): Promise<T>;
makeAPIRequest<T>(method: "GET" | "POST" | "PATCH" | "DELETE" | "PUT", path: string, data?: Record<string, any> | undefined, files?: Array<LilybirdAttachment> | undefined): Promise<T>;
}
//# sourceMappingURL=rest.d.ts.map