discord-slim
Advanced tools
Comparing version 2.1.9 to 2.2.0
/// <reference types="node" /> | ||
import { RequestOptions } from './request'; | ||
import { RequestOptions } from './request.js'; | ||
import type * as helpers from './helpers'; | ||
import type * as types from './types'; | ||
export declare const setDefaultRequestOptions: (requestOptions?: RequestOptions | undefined) => RequestOptions | undefined; | ||
export { SetDefOptions as setDefaultRequestOptions } from './request.js'; | ||
export declare const Channel: { | ||
@@ -7,0 +7,0 @@ Create: (guild_id: string, params: { |
@@ -1,199 +0,194 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.StageInstance = exports.Thread = exports.OAuth2 = exports.Application = exports.Webhook = exports.Voice = exports.User = exports.Template = exports.Invite = exports.WelcomeScreen = exports.Widget = exports.Role = exports.Ban = exports.Member = exports.Emoji = exports.Guild = exports.GroupDM = exports.Reaction = exports.Message = exports.Channel = exports.setDefaultRequestOptions = void 0; | ||
const request_1 = require("./request"); | ||
const url_1 = require("url"); | ||
const ParamString = (params) => String(new url_1.URLSearchParams(params)), QueryString = (params) => params ? '?' + ParamString(params) : ''; | ||
let defaultRequestOptions; | ||
const setDefaultRequestOptions = (requestOptions) => defaultRequestOptions = requestOptions; | ||
exports.setDefaultRequestOptions = setDefaultRequestOptions; | ||
exports.Channel = { | ||
Create: (guild_id, params, requestOptions) => request_1.Request("POST", "/guilds/" + guild_id + "/channels", requestOptions ?? defaultRequestOptions, params), | ||
Get: (channel_id, requestOptions) => request_1.Request("GET", "/channels/" + channel_id, requestOptions ?? defaultRequestOptions), | ||
Modify: (id, params, requestOptions) => request_1.Request("PATCH", "/channels/" + id, requestOptions ?? defaultRequestOptions, params), | ||
Delete: (channel_id, requestOptions) => request_1.Request("DELETE", "/channels/" + channel_id, requestOptions ?? defaultRequestOptions), | ||
GetMessages: (channel_id, params, requestOptions) => request_1.Request("GET", "/channels/" + channel_id + "/messages", requestOptions ?? defaultRequestOptions, params), | ||
BulkDeleteMessages: (channel_id, params, requestOptions) => request_1.Request("POST", "/channels/" + channel_id + "/messages" + "/bulk-delete", requestOptions ?? defaultRequestOptions, params), | ||
EditPermissions: (channel_id, overwrite_id, params, requestOptions) => request_1.Request("PUT", "/channels/" + channel_id + "/permissions/" + overwrite_id, requestOptions ?? defaultRequestOptions, params), | ||
GetInvites: (channel_id, requestOptions) => request_1.Request("GET", "/channels/" + channel_id + "/invites", requestOptions ?? defaultRequestOptions), | ||
DeletePermission: (channel_id, overwrite_id, requestOptions) => request_1.Request("DELETE", "/channels/" + channel_id + "/permissions/" + overwrite_id, requestOptions ?? defaultRequestOptions), | ||
FollowNews: (channel_id, params, requestOptions) => request_1.Request("POST", "/channels/" + channel_id + "/followers", requestOptions ?? defaultRequestOptions, params), | ||
TriggerTypingIndicator: (channel_id, requestOptions) => request_1.Request("POST", "/channels/" + channel_id + "/typing", requestOptions ?? defaultRequestOptions), | ||
GetPinnedMessages: (channel_id, requestOptions) => request_1.Request("GET", "/channels/" + channel_id + "/pins", requestOptions ?? defaultRequestOptions), | ||
GetWebhooks: (channel_id, requestOptions) => request_1.Request("GET", "/channels/" + channel_id + "/webhooks", requestOptions ?? defaultRequestOptions), | ||
ListActiveThreads: (channel_id, requestOptions) => request_1.Request("GET", "/channels/" + channel_id + "/threads" + "/active", requestOptions ?? defaultRequestOptions), | ||
ListPublicArchivedThreads: (channel_id, params, requestOptions) => request_1.Request("GET", "/channels/" + channel_id + "/threads" + "/archived" + "/public" + QueryString(params), requestOptions ?? defaultRequestOptions), | ||
ListPrivateArchivedThreads: (channel_id, params, requestOptions) => request_1.Request("GET", "/channels/" + channel_id + "/threads" + "/archived" + "/private" + QueryString(params), requestOptions ?? defaultRequestOptions), | ||
ListJoinedPrivateArchivedThreads: (channel_id, params, requestOptions) => request_1.Request("GET", "/channels/" + channel_id + "/users" + "/@me" + "/threads" + "/archived" + "/private" + QueryString(params), requestOptions ?? defaultRequestOptions), | ||
import { Request } from './request.js'; | ||
import { URLSearchParams } from 'url'; | ||
export { SetDefOptions as setDefaultRequestOptions } from './request.js'; | ||
const Path = (...paths) => paths.join('/'), Param = (params) => String(new URLSearchParams(params)), Query = (params) => params ? '?' + Param(params) : ''; | ||
export const Channel = { | ||
Create: (guild_id, params, requestOptions) => Request("POST", Path("guilds", guild_id, "channels"), requestOptions, params), | ||
Get: (channel_id, requestOptions) => Request("GET", Path("channels", channel_id), requestOptions), | ||
Modify: (id, params, requestOptions) => Request("PATCH", Path("channels", id), requestOptions, params), | ||
Delete: (channel_id, requestOptions) => Request("DELETE", Path("channels", channel_id), requestOptions), | ||
GetMessages: (channel_id, params, requestOptions) => Request("GET", Path("channels", channel_id, "messages"), requestOptions, params), | ||
BulkDeleteMessages: (channel_id, params, requestOptions) => Request("POST", Path("channels", channel_id, "messages", "bulk-delete"), requestOptions, params), | ||
EditPermissions: (channel_id, overwrite_id, params, requestOptions) => Request("PUT", Path("channels", channel_id, "permissions", overwrite_id), requestOptions, params), | ||
GetInvites: (channel_id, requestOptions) => Request("GET", Path("channels", channel_id, "invites"), requestOptions), | ||
DeletePermission: (channel_id, overwrite_id, requestOptions) => Request("DELETE", Path("channels", channel_id, "permissions", overwrite_id), requestOptions), | ||
FollowNews: (channel_id, params, requestOptions) => Request("POST", Path("channels", channel_id, "followers"), requestOptions, params), | ||
TriggerTypingIndicator: (channel_id, requestOptions) => Request("POST", Path("channels", channel_id, "typing"), requestOptions), | ||
GetPinnedMessages: (channel_id, requestOptions) => Request("GET", Path("channels", channel_id, "pins"), requestOptions), | ||
GetWebhooks: (channel_id, requestOptions) => Request("GET", Path("channels", channel_id, "webhooks"), requestOptions), | ||
ListActiveThreads: (channel_id, requestOptions) => Request("GET", Path("channels", channel_id, "threads", "active"), requestOptions), | ||
ListPublicArchivedThreads: (channel_id, params, requestOptions) => Request("GET", Path("channels", channel_id, "threads", "archived", "public") + Query(params), requestOptions), | ||
ListPrivateArchivedThreads: (channel_id, params, requestOptions) => Request("GET", Path("channels", channel_id, "threads", "archived", "private") + Query(params), requestOptions), | ||
ListJoinedPrivateArchivedThreads: (channel_id, params, requestOptions) => Request("GET", Path("channels", channel_id, "users", "@me", "threads", "archived", "private") + Query(params), requestOptions), | ||
}; | ||
exports.Message = { | ||
Get: (channel_id, message_id, requestOptions) => request_1.Request("GET", "/channels/" + channel_id + "/messages/" + message_id, requestOptions ?? defaultRequestOptions), | ||
Create: (channel_id, params, requestOptions) => request_1.Request("POST", "/channels/" + channel_id + "/messages", requestOptions ?? defaultRequestOptions, params), | ||
Crosspost: (channel_id, message_id, requestOptions) => request_1.Request("POST", "/channels/" + channel_id + "/messages/" + message_id + "/crosspost", requestOptions ?? defaultRequestOptions), | ||
Delete: (channel_id, message_id, requestOptions) => request_1.Request("DELETE", "/channels/" + channel_id + "/messages/" + message_id, requestOptions ?? defaultRequestOptions), | ||
Edit: (channel_id, message_id, params, requestOptions) => request_1.Request("PATCH", "/channels/" + channel_id + "/messages/" + message_id, requestOptions ?? defaultRequestOptions, params), | ||
Pin: (channel_id, message_id, requestOptions) => request_1.Request("PUT", "/channels/" + channel_id + "/pins/" + message_id, requestOptions ?? defaultRequestOptions), | ||
Unpin: (channel_id, message_id, requestOptions) => request_1.Request("DELETE", "/channels/" + channel_id + "/pins/" + message_id, requestOptions ?? defaultRequestOptions), | ||
GetReactions: (channel_id, message_id, emoji, params, requestOptions) => request_1.Request("GET", "/channels/" + channel_id + "/messages/" + message_id + "/reactions/" + encodeURIComponent(emoji) + QueryString(params), requestOptions ?? defaultRequestOptions), | ||
DeleteAllReactions: (channel_id, message_id, requestOptions) => request_1.Request("DELETE", "/channels/" + channel_id + "/messages/" + message_id + "/reactions", requestOptions ?? defaultRequestOptions), | ||
DeleteAllReactionsForEmoji: (channel_id, message_id, emoji, requestOptions) => request_1.Request("DELETE", "/channels/" + channel_id + "/messages/" + message_id + "/reactions/" + encodeURIComponent(emoji), requestOptions ?? defaultRequestOptions), | ||
export const Message = { | ||
Get: (channel_id, message_id, requestOptions) => Request("GET", Path("channels", channel_id, "messages", message_id), requestOptions), | ||
Create: (channel_id, params, requestOptions) => Request("POST", Path("channels", channel_id, "messages"), requestOptions, params), | ||
Crosspost: (channel_id, message_id, requestOptions) => Request("POST", Path("channels", channel_id, "messages", message_id, "crosspost"), requestOptions), | ||
Delete: (channel_id, message_id, requestOptions) => Request("DELETE", Path("channels", channel_id, "messages", message_id), requestOptions), | ||
Edit: (channel_id, message_id, params, requestOptions) => Request("PATCH", Path("channels", channel_id, "messages", message_id), requestOptions, params), | ||
Pin: (channel_id, message_id, requestOptions) => Request("PUT", Path("channels", channel_id, "pins", message_id), requestOptions), | ||
Unpin: (channel_id, message_id, requestOptions) => Request("DELETE", Path("channels", channel_id, "pins", message_id), requestOptions), | ||
GetReactions: (channel_id, message_id, emoji, params, requestOptions) => Request("GET", Path("channels", channel_id, "messages", message_id, "reactions", encodeURIComponent(emoji)) + Query(params), requestOptions), | ||
DeleteAllReactions: (channel_id, message_id, requestOptions) => Request("DELETE", Path("channels", channel_id, "messages", message_id, "reactions"), requestOptions), | ||
DeleteAllReactionsForEmoji: (channel_id, message_id, emoji, requestOptions) => Request("DELETE", Path("channels", channel_id, "messages", message_id, "reactions", encodeURIComponent(emoji)), requestOptions), | ||
}; | ||
exports.Reaction = { | ||
Add: (channel_id, message_id, emoji, requestOptions) => request_1.Request("PUT", "/channels/" + channel_id + "/messages/" + message_id + "/reactions/" + encodeURIComponent(emoji) + "/@me", requestOptions ?? defaultRequestOptions), | ||
DeleteOwn: (channel_id, message_id, emoji, requestOptions) => request_1.Request("DELETE", "/channels/" + channel_id + "/messages/" + message_id + "/reactions/" + encodeURIComponent(emoji) + "/@me", requestOptions ?? defaultRequestOptions), | ||
Delete: (channel_id, message_id, user_id, emoji, requestOptions) => request_1.Request("DELETE", "/channels/" + channel_id + "/messages/" + message_id + "/reactions/" + encodeURIComponent(emoji) + '/' + user_id, requestOptions ?? defaultRequestOptions), | ||
export const Reaction = { | ||
Add: (channel_id, message_id, emoji, requestOptions) => Request("PUT", Path("channels", channel_id, "messages", message_id, "reactions", encodeURIComponent(emoji), "@me"), requestOptions), | ||
DeleteOwn: (channel_id, message_id, emoji, requestOptions) => Request("DELETE", Path("channels", channel_id, "messages", message_id, "reactions", encodeURIComponent(emoji), "@me"), requestOptions), | ||
Delete: (channel_id, message_id, user_id, emoji, requestOptions) => Request("DELETE", Path("channels", channel_id, "messages", message_id, "reactions", encodeURIComponent(emoji), user_id), requestOptions), | ||
}; | ||
exports.GroupDM = { | ||
AddRecipient: (channel_id, user_id, params, requestOptions) => request_1.Request("PUT", "/channels/" + channel_id + "/recipients/" + user_id, requestOptions ?? defaultRequestOptions, params), | ||
RemoveRecipient: (channel_id, user_id, requestOptions) => request_1.Request("DELETE", "/channels/" + channel_id + "/recipients/" + user_id, requestOptions ?? defaultRequestOptions), | ||
Modify: (id, params, requestOptions) => request_1.Request("PATCH", "/channels/" + id, requestOptions ?? defaultRequestOptions, params), | ||
export const GroupDM = { | ||
AddRecipient: (channel_id, user_id, params, requestOptions) => Request("PUT", Path("channels", channel_id, "recipients", user_id), requestOptions, params), | ||
RemoveRecipient: (channel_id, user_id, requestOptions) => Request("DELETE", Path("channels", channel_id, "recipients", user_id), requestOptions), | ||
Modify: (id, params, requestOptions) => Request("PATCH", Path("channels", id), requestOptions, params), | ||
}; | ||
exports.Guild = { | ||
GetAuditLog: (guild_id, params, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/audit-logs" + QueryString(params), requestOptions ?? defaultRequestOptions), | ||
ListEmojis: (guild_id, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/emojis", requestOptions ?? defaultRequestOptions), | ||
Create: (params, requestOptions) => request_1.Request("POST", "/guilds", requestOptions ?? defaultRequestOptions, params), | ||
Get: (guild_id, params, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + QueryString(params), requestOptions ?? defaultRequestOptions), | ||
GetPreview: (guild_id, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/preview", requestOptions ?? defaultRequestOptions), | ||
Modify: (guild_id, params, requestOptions) => request_1.Request("PATCH", "/guilds/" + guild_id, requestOptions ?? defaultRequestOptions, params), | ||
Delete: (guild_id, requestOptions) => request_1.Request("DELETE", "/guilds/" + guild_id, requestOptions ?? defaultRequestOptions), | ||
GetChannels: (guild_id, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/channels", requestOptions ?? defaultRequestOptions), | ||
ModifyChannelPositions: (guild_id, params, requestOptions) => request_1.Request("PATCH", "/guilds/" + guild_id + "/channels", requestOptions ?? defaultRequestOptions, params), | ||
ListActiveThreads: (guild_id, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/threads" + "/active", requestOptions ?? defaultRequestOptions), | ||
ListMembers: (guild_id, params, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/members" + QueryString(params), requestOptions ?? defaultRequestOptions), | ||
SearchMembers: (guild_id, params, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/members" + "/search" + QueryString(params), requestOptions ?? defaultRequestOptions), | ||
GetBans: (guild_id, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/bans", requestOptions ?? defaultRequestOptions), | ||
GetRoles: (guild_id, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/roles", requestOptions ?? defaultRequestOptions), | ||
ModifyRolePositions: (guild_id, params, requestOptions) => request_1.Request("PATCH", "/guilds/" + guild_id + "/roles", requestOptions ?? defaultRequestOptions, params), | ||
GetPruneCount: (guild_id, params, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/prune" + QueryString(params), requestOptions ?? defaultRequestOptions), | ||
Prune: (guild_id, params, requestOptions) => request_1.Request("POST", "/guilds/" + guild_id + "/prune", requestOptions ?? defaultRequestOptions, params), | ||
GetVoiceRegions: (guild_id, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/regions", requestOptions ?? defaultRequestOptions), | ||
GetInvites: (guild_id, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/invites", requestOptions ?? defaultRequestOptions), | ||
GetIntegrations: (guild_id, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/integrations", requestOptions ?? defaultRequestOptions), | ||
DeleteIntegration: (guild_id, integration_id, requestOptions) => request_1.Request("DELETE", "/guilds/" + guild_id + "/integrations/" + integration_id, requestOptions ?? defaultRequestOptions), | ||
GetVanityURL: (guild_id, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/vanity-url", requestOptions ?? defaultRequestOptions), | ||
CreateFromTemplate: (template_code, params, requestOptions) => request_1.Request("POST", "/guilds" + "/templates/" + template_code, requestOptions ?? defaultRequestOptions, params), | ||
GetTemplates: (guild_id, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/templates", requestOptions ?? defaultRequestOptions), | ||
GetWebhooks: (guild_id, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/webhooks", requestOptions ?? defaultRequestOptions), | ||
export const Guild = { | ||
GetAuditLog: (guild_id, params, requestOptions) => Request("GET", Path("guilds", guild_id, "audit-logs") + Query(params), requestOptions), | ||
ListEmojis: (guild_id, requestOptions) => Request("GET", Path("guilds", guild_id, "emojis"), requestOptions), | ||
Create: (params, requestOptions) => Request("POST", "guilds", requestOptions, params), | ||
Get: (guild_id, params, requestOptions) => Request("GET", Path("guilds", guild_id) + Query(params), requestOptions), | ||
GetPreview: (guild_id, requestOptions) => Request("GET", Path("guilds", guild_id, "preview"), requestOptions), | ||
Modify: (guild_id, params, requestOptions) => Request("PATCH", Path("guilds", guild_id), requestOptions, params), | ||
Delete: (guild_id, requestOptions) => Request("DELETE", Path("guilds", guild_id), requestOptions), | ||
GetChannels: (guild_id, requestOptions) => Request("GET", Path("guilds", guild_id, "channels"), requestOptions), | ||
ModifyChannelPositions: (guild_id, params, requestOptions) => Request("PATCH", Path("guilds", guild_id, "channels"), requestOptions, params), | ||
ListActiveThreads: (guild_id, requestOptions) => Request("GET", Path("guilds", guild_id, "threads", "active"), requestOptions), | ||
ListMembers: (guild_id, params, requestOptions) => Request("GET", Path("guilds", guild_id, "members") + Query(params), requestOptions), | ||
SearchMembers: (guild_id, params, requestOptions) => Request("GET", Path("guilds", guild_id, "members", "search") + Query(params), requestOptions), | ||
GetBans: (guild_id, requestOptions) => Request("GET", Path("guilds", guild_id, "bans"), requestOptions), | ||
GetRoles: (guild_id, requestOptions) => Request("GET", Path("guilds", guild_id, "roles"), requestOptions), | ||
ModifyRolePositions: (guild_id, params, requestOptions) => Request("PATCH", Path("guilds", guild_id, "roles"), requestOptions, params), | ||
GetPruneCount: (guild_id, params, requestOptions) => Request("GET", Path("guilds", guild_id, "prune") + Query(params), requestOptions), | ||
Prune: (guild_id, params, requestOptions) => Request("POST", Path("guilds", guild_id, "prune"), requestOptions, params), | ||
GetVoiceRegions: (guild_id, requestOptions) => Request("GET", Path("guilds", guild_id, "regions"), requestOptions), | ||
GetInvites: (guild_id, requestOptions) => Request("GET", Path("guilds", guild_id, "invites"), requestOptions), | ||
GetIntegrations: (guild_id, requestOptions) => Request("GET", Path("guilds", guild_id, "integrations"), requestOptions), | ||
DeleteIntegration: (guild_id, integration_id, requestOptions) => Request("DELETE", Path("guilds", guild_id, "integrations", integration_id), requestOptions), | ||
GetVanityURL: (guild_id, requestOptions) => Request("GET", Path("guilds", guild_id, "vanity-url"), requestOptions), | ||
CreateFromTemplate: (template_code, params, requestOptions) => Request("POST", Path("guilds", "templates", template_code), requestOptions, params), | ||
GetTemplates: (guild_id, requestOptions) => Request("GET", Path("guilds", guild_id, "templates"), requestOptions), | ||
GetWebhooks: (guild_id, requestOptions) => Request("GET", Path("guilds", guild_id, "webhooks"), requestOptions), | ||
}; | ||
exports.Emoji = { | ||
Get: (guild_id, emoji_id, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/emojis/" + emoji_id, requestOptions ?? defaultRequestOptions), | ||
Add: (guild_id, params, requestOptions) => request_1.Request("POST", "/guilds/" + guild_id + "/emojis", requestOptions ?? defaultRequestOptions, params), | ||
Modify: (guild_id, emoji_id, params, requestOptions) => request_1.Request("PATCH", "/guilds/" + guild_id + "/emojis/" + emoji_id, requestOptions ?? defaultRequestOptions, params), | ||
Delete: (guild_id, emoji_id, requestOptions) => request_1.Request("DELETE", "/guilds/" + guild_id + "/emojis/" + emoji_id, requestOptions ?? defaultRequestOptions), | ||
export const Emoji = { | ||
Get: (guild_id, emoji_id, requestOptions) => Request("GET", Path("guilds", guild_id, "emojis", emoji_id), requestOptions), | ||
Add: (guild_id, params, requestOptions) => Request("POST", Path("guilds", guild_id, "emojis"), requestOptions, params), | ||
Modify: (guild_id, emoji_id, params, requestOptions) => Request("PATCH", Path("guilds", guild_id, "emojis", emoji_id), requestOptions, params), | ||
Delete: (guild_id, emoji_id, requestOptions) => Request("DELETE", Path("guilds", guild_id, "emojis", emoji_id), requestOptions), | ||
}; | ||
exports.Member = { | ||
Get: (guild_id, user_id, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/members/" + user_id, requestOptions ?? defaultRequestOptions), | ||
Add: (guild_id, user_id, params, requestOptions) => request_1.Request("PUT", "/guilds/" + guild_id + "/members/" + user_id, requestOptions ?? defaultRequestOptions, params), | ||
Modify: (guild_id, user_id, params, requestOptions) => request_1.Request("PATCH", "/guilds/" + guild_id + "/members/" + user_id, requestOptions ?? defaultRequestOptions, params), | ||
ModifyCurrentNick: (guild_id, params, requestOptions) => request_1.Request("PATCH", "/guilds/" + guild_id + "/members" + "/@me" + "/nick", requestOptions ?? defaultRequestOptions, params), | ||
AddRole: (guild_id, user_id, role_id, requestOptions) => request_1.Request("PUT", "/guilds/" + guild_id + "/members/" + user_id + "/roles/" + role_id, requestOptions ?? defaultRequestOptions), | ||
RemoveRole: (guild_id, user_id, role_id, requestOptions) => request_1.Request("DELETE", "/guilds/" + guild_id + "/members/" + user_id + "/roles/" + role_id, requestOptions ?? defaultRequestOptions), | ||
Remove: (guild_id, user_id, requestOptions) => request_1.Request("DELETE", "/guilds/" + guild_id + "/members/" + user_id, requestOptions ?? defaultRequestOptions), | ||
export const Member = { | ||
Get: (guild_id, user_id, requestOptions) => Request("GET", Path("guilds", guild_id, "members", user_id), requestOptions), | ||
Add: (guild_id, user_id, params, requestOptions) => Request("PUT", Path("guilds", guild_id, "members", user_id), requestOptions, params), | ||
Modify: (guild_id, user_id, params, requestOptions) => Request("PATCH", Path("guilds", guild_id, "members", user_id), requestOptions, params), | ||
ModifyCurrentNick: (guild_id, params, requestOptions) => Request("PATCH", Path("guilds", guild_id, "members", "@me", "nick"), requestOptions, params), | ||
AddRole: (guild_id, user_id, role_id, requestOptions) => Request("PUT", Path("guilds", guild_id, "members", user_id, "roles", role_id), requestOptions), | ||
RemoveRole: (guild_id, user_id, role_id, requestOptions) => Request("DELETE", Path("guilds", guild_id, "members", user_id, "roles", role_id), requestOptions), | ||
Remove: (guild_id, user_id, requestOptions) => Request("DELETE", Path("guilds", guild_id, "members", user_id), requestOptions), | ||
}; | ||
exports.Ban = { | ||
Get: (guild_id, user_id, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/bans/" + user_id, requestOptions ?? defaultRequestOptions), | ||
Add: (guild_id, user_id, params, requestOptions) => request_1.Request("PUT", "/guilds/" + guild_id + "/bans/" + user_id, requestOptions ?? defaultRequestOptions, params), | ||
Remove: (guild_id, user_id, requestOptions) => request_1.Request("DELETE", "/guilds/" + guild_id + "/bans/" + user_id, requestOptions ?? defaultRequestOptions), | ||
export const Ban = { | ||
Get: (guild_id, user_id, requestOptions) => Request("GET", Path("guilds", guild_id, "bans", user_id), requestOptions), | ||
Add: (guild_id, user_id, params, requestOptions) => Request("PUT", Path("guilds", guild_id, "bans", user_id), requestOptions, params), | ||
Remove: (guild_id, user_id, requestOptions) => Request("DELETE", Path("guilds", guild_id, "bans", user_id), requestOptions), | ||
}; | ||
exports.Role = { | ||
Create: (guild_id, params, requestOptions) => request_1.Request("POST", "/guilds/" + guild_id + "/roles", requestOptions ?? defaultRequestOptions, params), | ||
Modify: (guild_id, role_id, params, requestOptions) => request_1.Request("PATCH", "/guilds/" + guild_id + "/roles/" + role_id, requestOptions ?? defaultRequestOptions, params), | ||
Delete: (guild_id, role_id, requestOptions) => request_1.Request("DELETE", "/guilds/" + guild_id + "/roles/" + role_id, requestOptions ?? defaultRequestOptions), | ||
export const Role = { | ||
Create: (guild_id, params, requestOptions) => Request("POST", Path("guilds", guild_id, "roles"), requestOptions, params), | ||
Modify: (guild_id, role_id, params, requestOptions) => Request("PATCH", Path("guilds", guild_id, "roles", role_id), requestOptions, params), | ||
Delete: (guild_id, role_id, requestOptions) => Request("DELETE", Path("guilds", guild_id, "roles", role_id), requestOptions), | ||
}; | ||
exports.Widget = { | ||
GetSettings: (guild_id, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/widget", requestOptions ?? defaultRequestOptions), | ||
Modify: (guild_id, params, requestOptions) => request_1.Request("PATCH", "/guilds/" + guild_id + "/widget", requestOptions ?? defaultRequestOptions, params), | ||
Get: (guild_id, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/widget.json", requestOptions ?? defaultRequestOptions), | ||
GetImage: (guild_id, params, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/widget.png" + QueryString(params), requestOptions ?? defaultRequestOptions), | ||
export const Widget = { | ||
GetSettings: (guild_id, requestOptions) => Request("GET", Path("guilds", guild_id, "widget"), requestOptions), | ||
Modify: (guild_id, params, requestOptions) => Request("PATCH", Path("guilds", guild_id, "widget"), requestOptions, params), | ||
Get: (guild_id, requestOptions) => Request("GET", Path("guilds", guild_id, "widget.json"), requestOptions), | ||
GetImage: (guild_id, params, requestOptions) => Request("GET", Path("guilds", guild_id, "widget.png") + Query(params), requestOptions), | ||
}; | ||
exports.WelcomeScreen = { | ||
Get: (guild_id, requestOptions) => request_1.Request("GET", "/guilds/" + guild_id + "/welcome-screen", requestOptions ?? defaultRequestOptions), | ||
Modify: (guild_id, params, requestOptions) => request_1.Request("PATCH", "/guilds/" + guild_id + "/welcome-screen", requestOptions ?? defaultRequestOptions, params), | ||
export const WelcomeScreen = { | ||
Get: (guild_id, requestOptions) => Request("GET", Path("guilds", guild_id, "welcome-screen"), requestOptions), | ||
Modify: (guild_id, params, requestOptions) => Request("PATCH", Path("guilds", guild_id, "welcome-screen"), requestOptions, params), | ||
}; | ||
exports.Invite = { | ||
Create: (channel_id, params, requestOptions) => request_1.Request("POST", "/channels/" + channel_id + "/invites", requestOptions ?? defaultRequestOptions, params), | ||
Get: (invite_code, params, requestOptions) => request_1.Request("GET", "/invites/" + invite_code + QueryString(params), requestOptions ?? defaultRequestOptions), | ||
Delete: (invite_code, requestOptions) => request_1.Request("DELETE", "/invites/" + invite_code, requestOptions ?? defaultRequestOptions), | ||
export const Invite = { | ||
Create: (channel_id, params, requestOptions) => Request("POST", Path("channels", channel_id, "invites"), requestOptions, params), | ||
Get: (invite_code, params, requestOptions) => Request("GET", Path("invites", invite_code) + Query(params), requestOptions), | ||
Delete: (invite_code, requestOptions) => Request("DELETE", Path("invites", invite_code), requestOptions), | ||
}; | ||
exports.Template = { | ||
Get: (template_code, requestOptions) => request_1.Request("GET", "/guilds" + "/templates/" + template_code, requestOptions ?? defaultRequestOptions), | ||
Create: (guild_id, params, requestOptions) => request_1.Request("POST", "/guilds/" + guild_id + "/templates", requestOptions ?? defaultRequestOptions, params), | ||
Sync: (guild_id, template_code, requestOptions) => request_1.Request("PUT", "/guilds/" + guild_id + "/templates/" + template_code, requestOptions ?? defaultRequestOptions), | ||
Modify: (guild_id, template_code, params, requestOptions) => request_1.Request("PATCH", "/guilds/" + guild_id + "/templates/" + template_code, requestOptions ?? defaultRequestOptions, params), | ||
Delete: (guild_id, template_code, requestOptions) => request_1.Request("DELETE", "/guilds/" + guild_id + "/templates/" + template_code, requestOptions ?? defaultRequestOptions), | ||
export const Template = { | ||
Get: (template_code, requestOptions) => Request("GET", Path("guilds", "templates", template_code), requestOptions), | ||
Create: (guild_id, params, requestOptions) => Request("POST", Path("guilds", guild_id, "templates"), requestOptions, params), | ||
Sync: (guild_id, template_code, requestOptions) => Request("PUT", Path("guilds", guild_id, "templates", template_code), requestOptions), | ||
Modify: (guild_id, template_code, params, requestOptions) => Request("PATCH", Path("guilds", guild_id, "templates", template_code), requestOptions, params), | ||
Delete: (guild_id, template_code, requestOptions) => Request("DELETE", Path("guilds", guild_id, "templates", template_code), requestOptions), | ||
}; | ||
exports.User = { | ||
GetCurrent: (requestOptions) => request_1.Request("GET", "/users/" + "/@me", requestOptions ?? defaultRequestOptions), | ||
Get: (user_id, requestOptions) => request_1.Request("GET", "/users/" + user_id, requestOptions ?? defaultRequestOptions), | ||
ModifyCurrent: (params, requestOptions) => request_1.Request("PATCH", "/users/" + "/@me", requestOptions ?? defaultRequestOptions, params), | ||
GetCurrentGuilds: (params, requestOptions) => request_1.Request("GET", "/users/" + "/@me/" + "/guilds" + QueryString(params), requestOptions ?? defaultRequestOptions), | ||
LeaveGuild: (guild_id, requestOptions) => request_1.Request("DELETE", "/users" + "/@me" + "/guilds/" + guild_id, requestOptions ?? defaultRequestOptions), | ||
CreateDM: (params, requestOptions) => request_1.Request("POST", "/users" + "/@me" + "/channels", requestOptions ?? defaultRequestOptions, params), | ||
GetConnections: (requestOptions) => request_1.Request("GET", "/users" + "/@me" + "/connections", requestOptions ?? defaultRequestOptions), | ||
export const User = { | ||
GetCurrent: (requestOptions) => Request("GET", Path("users", "@me"), requestOptions), | ||
Get: (user_id, requestOptions) => Request("GET", Path("users", user_id), requestOptions), | ||
ModifyCurrent: (params, requestOptions) => Request("PATCH", Path("users", "@me"), requestOptions, params), | ||
GetCurrentGuilds: (params, requestOptions) => Request("GET", Path("users", "@me", "guilds") + Query(params), requestOptions), | ||
LeaveGuild: (guild_id, requestOptions) => Request("DELETE", Path("users", "@me", "guilds", guild_id), requestOptions), | ||
CreateDM: (params, requestOptions) => Request("POST", Path("users", "@me", "channels"), requestOptions, params), | ||
GetConnections: (requestOptions) => Request("GET", Path("users", "@me", "connections"), requestOptions), | ||
}; | ||
exports.Voice = { | ||
ListRegions: (requestOptions) => request_1.Request("GET", "/voice" + "/regions", requestOptions ?? defaultRequestOptions), | ||
UpdateCurrentState: (guild_id, params, requestOptions) => request_1.Request("PATCH", "/guilds/" + guild_id + "/voice-states" + "/@me", requestOptions ?? defaultRequestOptions, params), | ||
UpdateUserState: (guild_id, user_id, params, requestOptions) => request_1.Request("PATCH", "/guilds/" + guild_id + "/voice-states/" + user_id, requestOptions ?? defaultRequestOptions, params), | ||
export const Voice = { | ||
ListRegions: (requestOptions) => Request("GET", Path("voice", "regions"), requestOptions), | ||
UpdateCurrentState: (guild_id, params, requestOptions) => Request("PATCH", Path("guilds", guild_id, "voice-states", "@me"), requestOptions, params), | ||
UpdateUserState: (guild_id, user_id, params, requestOptions) => Request("PATCH", Path("guilds", guild_id, "voice-states", user_id), requestOptions, params), | ||
}; | ||
exports.Webhook = { | ||
Create: (channel_id, params, requestOptions) => request_1.Request("POST", "/channels/" + channel_id + "/webhooks", requestOptions ?? defaultRequestOptions, params), | ||
Get: (webhook_id, requestOptions) => request_1.Request("GET", "/webhooks/" + webhook_id, requestOptions ?? defaultRequestOptions), | ||
GetWithToken: (webhook_id, webhook_token, requestOptions) => request_1.Request("GET", "/webhooks/" + webhook_id + '/' + webhook_token, requestOptions ?? defaultRequestOptions), | ||
Modify: (webhook_id, params, requestOptions) => request_1.Request("PATCH", "/webhooks/" + webhook_id, requestOptions ?? defaultRequestOptions, params), | ||
ModifyWithToken: (webhook_id, webhook_token, params, requestOptions) => request_1.Request("PATCH", "/webhooks/" + webhook_id + '/' + webhook_token, requestOptions ?? defaultRequestOptions, params), | ||
Delete: (webhook_id, requestOptions) => request_1.Request("DELETE", "/webhooks/" + webhook_id, requestOptions ?? defaultRequestOptions), | ||
DeleteWithToken: (webhook_id, webhook_token, requestOptions) => request_1.Request("DELETE", "/webhooks/" + webhook_id + '/' + webhook_token, requestOptions ?? defaultRequestOptions), | ||
Execute: (webhook_id, webhook_token, params1, params2, requestOptions) => request_1.Request("POST", "/webhooks/" + webhook_id + '/' + webhook_token + QueryString(params2), requestOptions ?? defaultRequestOptions, params1), | ||
ExecuteSlack: (webhook_id, webhook_token, params, requestOptions) => request_1.Request("POST", "/webhooks/" + webhook_id + '/' + webhook_token + "/slack" + QueryString(params), requestOptions ?? defaultRequestOptions), | ||
ExecuteGitHub: (webhook_id, webhook_token, params, requestOptions) => request_1.Request("POST", "/webhooks/" + webhook_id + '/' + webhook_token + "/github" + QueryString(params), requestOptions ?? defaultRequestOptions), | ||
GetMessage: (webhook_id, webhook_token, message_id, requestOptions) => request_1.Request("GET", "/webhooks/" + webhook_id + '/' + webhook_token + "/messages/" + message_id, requestOptions ?? defaultRequestOptions), | ||
EditMessage: (webhook_id, webhook_token, message_id, params, requestOptions) => request_1.Request("PATCH", "/webhooks/" + webhook_id + '/' + webhook_token + "/messages/" + message_id, requestOptions ?? defaultRequestOptions, params), | ||
DeleteMessage: (webhook_id, webhook_token, message_id, requestOptions) => request_1.Request("DELETE", "/webhooks/" + webhook_id + '/' + webhook_token + "/messages/" + message_id, requestOptions ?? defaultRequestOptions), | ||
export const Webhook = { | ||
Create: (channel_id, params, requestOptions) => Request("POST", Path("channels", channel_id, "webhooks"), requestOptions, params), | ||
Get: (webhook_id, requestOptions) => Request("GET", Path("webhooks", webhook_id), requestOptions), | ||
GetWithToken: (webhook_id, webhook_token, requestOptions) => Request("GET", Path("webhooks", webhook_id, webhook_token), requestOptions), | ||
Modify: (webhook_id, params, requestOptions) => Request("PATCH", Path("webhooks", webhook_id), requestOptions, params), | ||
ModifyWithToken: (webhook_id, webhook_token, params, requestOptions) => Request("PATCH", Path("webhooks", webhook_id, webhook_token), requestOptions, params), | ||
Delete: (webhook_id, requestOptions) => Request("DELETE", Path("webhooks", webhook_id), requestOptions), | ||
DeleteWithToken: (webhook_id, webhook_token, requestOptions) => Request("DELETE", Path("webhooks", webhook_id, webhook_token), requestOptions), | ||
Execute: (webhook_id, webhook_token, params1, params2, requestOptions) => Request("POST", Path("webhooks", webhook_id, webhook_token) + Query(params2), requestOptions, params1), | ||
ExecuteSlack: (webhook_id, webhook_token, params, requestOptions) => Request("POST", Path("webhooks", webhook_id, webhook_token, "slack") + Query(params), requestOptions), | ||
ExecuteGitHub: (webhook_id, webhook_token, params, requestOptions) => Request("POST", Path("webhooks", webhook_id, webhook_token, "github") + Query(params), requestOptions), | ||
GetMessage: (webhook_id, webhook_token, message_id, requestOptions) => Request("GET", Path("webhooks", webhook_id, webhook_token, "messages", message_id), requestOptions), | ||
EditMessage: (webhook_id, webhook_token, message_id, params, requestOptions) => Request("PATCH", Path("webhooks", webhook_id, webhook_token, "messages", message_id), requestOptions, params), | ||
DeleteMessage: (webhook_id, webhook_token, message_id, requestOptions) => Request("DELETE", Path("webhooks", webhook_id, webhook_token, "messages", message_id), requestOptions), | ||
}; | ||
exports.Application = { | ||
GetGlobalCommands: (application_id, requestOptions) => request_1.Request("GET", "/applications/" + application_id + "/commands", requestOptions ?? defaultRequestOptions), | ||
CreateGlobalCommand: (application_id, params, requestOptions) => request_1.Request("POST", "/applications/" + application_id + "/commands", requestOptions ?? defaultRequestOptions, params), | ||
GetGlobalCommand: (application_id, command_id, requestOptions) => request_1.Request("GET", "/applications/" + application_id + "/commands/" + command_id, requestOptions ?? defaultRequestOptions), | ||
EditGlobalCommand: (application_id, command_id, params, requestOptions) => request_1.Request("PATCH", "/applications/" + application_id + "/commands/" + command_id, requestOptions ?? defaultRequestOptions, params), | ||
DeleteGlobalCommand: (application_id, command_id, requestOptions) => request_1.Request("DELETE", "/applications/" + application_id + "/commands/" + command_id, requestOptions ?? defaultRequestOptions), | ||
GetGuildCommands: (application_id, guild_id, requestOptions) => request_1.Request("GET", "/applications/" + application_id + "/guilds/" + guild_id + "/commands", requestOptions ?? defaultRequestOptions), | ||
CreateGuildCommand: (application_id, guild_id, params, requestOptions) => request_1.Request("POST", "/applications/" + application_id + "/guilds/" + guild_id + "/commands", requestOptions ?? defaultRequestOptions, params), | ||
GetGuildCommand: (application_id, guild_id, command_id, requestOptions) => request_1.Request("GET", "/applications/" + application_id + "/guilds/" + guild_id + "/commands/" + command_id, requestOptions ?? defaultRequestOptions), | ||
EditGuildCommand: (application_id, guild_id, command_id, params, requestOptions) => request_1.Request("PATCH", "/applications/" + application_id + "/guilds/" + guild_id + "/commands/" + command_id, requestOptions ?? defaultRequestOptions, params), | ||
DeleteGuildCommand: (application_id, guild_id, command_id, requestOptions) => request_1.Request("DELETE", "/applications/" + application_id + "/guilds/" + guild_id + "/commands/" + command_id, requestOptions ?? defaultRequestOptions), | ||
CreateInteractionResponse: (interaction_id, interaction_token, params, requestOptions) => request_1.Request("POST", "/interactions/" + interaction_id + '/' + interaction_token + "/callback", requestOptions ?? defaultRequestOptions, params), | ||
GetOriginalInteractionResponse: (application_id, interaction_token, requestOptions) => request_1.Request("GET", "/webhooks/" + application_id + '/' + interaction_token + "/messages" + "/@original", requestOptions ?? defaultRequestOptions), | ||
EditOriginalInteractionResponse: (application_id, interaction_token, params, requestOptions) => request_1.Request("PATCH", "/webhooks/" + application_id + '/' + interaction_token + "/messages" + "/@original", requestOptions ?? defaultRequestOptions, params), | ||
DeleteOriginalInteractionResponse: (application_id, interaction_token, requestOptions) => request_1.Request("DELETE", "/webhooks/" + application_id + '/' + interaction_token + "/messages" + "/@original", requestOptions ?? defaultRequestOptions), | ||
CreateFollowupMessage: (application_id, interaction_token, params, requestOptions) => request_1.Request("POST", "/webhooks/" + application_id + '/' + interaction_token, requestOptions ?? defaultRequestOptions, params), | ||
GetFollowupMessage: (application_id, interaction_token, message_id, requestOptions) => request_1.Request("GET", "/webhooks/" + application_id + '/' + interaction_token + "/messages/" + message_id, requestOptions ?? defaultRequestOptions), | ||
EditFollowupMessage: (application_id, interaction_token, message_id, params, requestOptions) => request_1.Request("PATCH", "/webhooks/" + application_id + '/' + interaction_token + "/messages/" + message_id, requestOptions ?? defaultRequestOptions, params), | ||
DeleteFollowupMessage: (application_id, interaction_token, message_id, requestOptions) => request_1.Request("DELETE", "/webhooks/" + application_id + '/' + interaction_token + "/messages/" + message_id, requestOptions ?? defaultRequestOptions), | ||
GetGuildCommandPermissions: (application_id, guild_id, requestOptions) => request_1.Request("GET", "/applications/" + application_id + "/guilds/" + guild_id + "/commands" + "/permissions", requestOptions ?? defaultRequestOptions), | ||
GetCommandPermissions: (application_id, guild_id, command_id, requestOptions) => request_1.Request("GET", "/applications/" + application_id + "/guilds/" + guild_id + "/commands/" + command_id + "/permissions", requestOptions ?? defaultRequestOptions), | ||
EditCommandPermissions: (application_id, guild_id, command_id, params, requestOptions) => request_1.Request("PUT", "/applications/" + application_id + "/guilds/" + guild_id + "/commands/" + command_id + "/permissions", requestOptions ?? defaultRequestOptions, params), | ||
BatchEditCommandPermissions: (application_id, guild_id, params, requestOptions) => request_1.Request("PUT", "/applications/" + application_id + "/guilds/" + guild_id + "/commands" + "/permissions", requestOptions ?? defaultRequestOptions, params), | ||
export const Application = { | ||
GetGlobalCommands: (application_id, requestOptions) => Request("GET", Path("applications", application_id, "commands"), requestOptions), | ||
CreateGlobalCommand: (application_id, params, requestOptions) => Request("POST", Path("applications", application_id, "commands"), requestOptions, params), | ||
GetGlobalCommand: (application_id, command_id, requestOptions) => Request("GET", Path("applications", application_id, "commands", command_id), requestOptions), | ||
EditGlobalCommand: (application_id, command_id, params, requestOptions) => Request("PATCH", Path("applications", application_id, "commands", command_id), requestOptions, params), | ||
DeleteGlobalCommand: (application_id, command_id, requestOptions) => Request("DELETE", Path("applications", application_id, "commands", command_id), requestOptions), | ||
GetGuildCommands: (application_id, guild_id, requestOptions) => Request("GET", Path("applications", application_id, "guilds", guild_id, "commands"), requestOptions), | ||
CreateGuildCommand: (application_id, guild_id, params, requestOptions) => Request("POST", Path("applications", application_id, "guilds", guild_id, "commands"), requestOptions, params), | ||
GetGuildCommand: (application_id, guild_id, command_id, requestOptions) => Request("GET", Path("applications", application_id, "guilds", guild_id, "commands", command_id), requestOptions), | ||
EditGuildCommand: (application_id, guild_id, command_id, params, requestOptions) => Request("PATCH", Path("applications", application_id, "guilds", guild_id, "commands", command_id), requestOptions, params), | ||
DeleteGuildCommand: (application_id, guild_id, command_id, requestOptions) => Request("DELETE", Path("applications", application_id, "guilds", guild_id, "commands", command_id), requestOptions), | ||
CreateInteractionResponse: (interaction_id, interaction_token, params, requestOptions) => Request("POST", Path("interactions", interaction_id, interaction_token, "callback"), requestOptions, params), | ||
GetOriginalInteractionResponse: (application_id, interaction_token, requestOptions) => Request("GET", Path("webhooks", application_id, interaction_token, "messages", "@original"), requestOptions), | ||
EditOriginalInteractionResponse: (application_id, interaction_token, params, requestOptions) => Request("PATCH", Path("webhooks", application_id, interaction_token, "messages", "@original"), requestOptions, params), | ||
DeleteOriginalInteractionResponse: (application_id, interaction_token, requestOptions) => Request("DELETE", Path("webhooks", application_id, interaction_token, "messages", "@original"), requestOptions), | ||
CreateFollowupMessage: (application_id, interaction_token, params, requestOptions) => Request("POST", Path("webhooks", application_id, interaction_token), requestOptions, params), | ||
GetFollowupMessage: (application_id, interaction_token, message_id, requestOptions) => Request("GET", Path("webhooks", application_id, interaction_token, "messages", message_id), requestOptions), | ||
EditFollowupMessage: (application_id, interaction_token, message_id, params, requestOptions) => Request("PATCH", Path("webhooks", application_id, interaction_token, "messages", message_id), requestOptions, params), | ||
DeleteFollowupMessage: (application_id, interaction_token, message_id, requestOptions) => Request("DELETE", Path("webhooks", application_id, interaction_token, "messages", message_id), requestOptions), | ||
GetGuildCommandPermissions: (application_id, guild_id, requestOptions) => Request("GET", Path("applications", application_id, "guilds", guild_id, "commands", "permissions"), requestOptions), | ||
GetCommandPermissions: (application_id, guild_id, command_id, requestOptions) => Request("GET", Path("applications", application_id, "guilds", guild_id, "commands", command_id, "permissions"), requestOptions), | ||
EditCommandPermissions: (application_id, guild_id, command_id, params, requestOptions) => Request("PUT", Path("applications", application_id, "guilds", guild_id, "commands", command_id, "permissions"), requestOptions, params), | ||
BatchEditCommandPermissions: (application_id, guild_id, params, requestOptions) => Request("PUT", Path("applications", application_id, "guilds", guild_id, "commands", "permissions"), requestOptions, params), | ||
}; | ||
exports.OAuth2 = { | ||
TokenExchange: (params, requestOptions) => request_1.Request("POST", "/oauth2" + "/token", requestOptions ?? defaultRequestOptions, ParamString(params)), | ||
GetCurrentApplicationInformation: (requestOptions) => request_1.Request("GET", "/oauth2" + "/applications" + "/@me", requestOptions ?? defaultRequestOptions), | ||
GetCurrentAuthorizationInformation: (requestOptions) => request_1.Request("GET", "/oauth2" + "/@me", requestOptions ?? defaultRequestOptions), | ||
export const OAuth2 = { | ||
TokenExchange: (params, requestOptions) => Request("POST", Path("oauth2", "token"), requestOptions, Param(params)), | ||
GetCurrentApplicationInformation: (requestOptions) => Request("GET", Path("oauth2", "applications", "@me"), requestOptions), | ||
GetCurrentAuthorizationInformation: (requestOptions) => Request("GET", Path("oauth2", "@me"), requestOptions), | ||
}; | ||
exports.Thread = { | ||
Modify: (channel_id, params, requestOptions) => request_1.Request("PATCH", "/channels/" + channel_id, requestOptions ?? defaultRequestOptions, params), | ||
Delete: (channel_id, requestOptions) => request_1.Request("DELETE", "/channels/" + channel_id, requestOptions ?? defaultRequestOptions), | ||
StartWithMessage: (channel_id, message_id, params, requestOptions) => request_1.Request("POST", "/channels/" + channel_id + "/messages/" + message_id + "/threads", requestOptions ?? defaultRequestOptions, params), | ||
Start: (channel_id, params, requestOptions) => request_1.Request("POST", "/channels/" + channel_id + "/threads", requestOptions ?? defaultRequestOptions, params), | ||
Join: (channel_id, requestOptions) => request_1.Request("PUT", "/channels/" + channel_id + "/thread-members" + "/@me", requestOptions ?? defaultRequestOptions), | ||
AddMember: (channel_id, user_id, requestOptions) => request_1.Request("PUT", "/channels/" + channel_id + "/thread-members/" + user_id, requestOptions ?? defaultRequestOptions), | ||
Leave: (channel_id, requestOptions) => request_1.Request("DELETE", "/channels/" + channel_id + "/thread-members" + "/@me", requestOptions ?? defaultRequestOptions), | ||
RemoveMember: (channel_id, user_id, requestOptions) => request_1.Request("DELETE", "/channels/" + channel_id + "/thread-members/" + user_id, requestOptions ?? defaultRequestOptions), | ||
ListMembers: (channel_id, requestOptions) => request_1.Request("GET", "/channels/" + channel_id + "/thread-members", requestOptions ?? defaultRequestOptions), | ||
export const Thread = { | ||
Modify: (channel_id, params, requestOptions) => Request("PATCH", Path("channels", channel_id), requestOptions, params), | ||
Delete: (channel_id, requestOptions) => Request("DELETE", Path("channels", channel_id), requestOptions), | ||
StartWithMessage: (channel_id, message_id, params, requestOptions) => Request("POST", Path("channels", channel_id, "messages", message_id, "threads"), requestOptions, params), | ||
Start: (channel_id, params, requestOptions) => Request("POST", Path("channels", channel_id, "threads"), requestOptions, params), | ||
Join: (channel_id, requestOptions) => Request("PUT", Path("channels", channel_id, "thread-members", "@me"), requestOptions), | ||
AddMember: (channel_id, user_id, requestOptions) => Request("PUT", Path("channels", channel_id, "thread-members", user_id), requestOptions), | ||
Leave: (channel_id, requestOptions) => Request("DELETE", Path("channels", channel_id, "thread-members", "@me"), requestOptions), | ||
RemoveMember: (channel_id, user_id, requestOptions) => Request("DELETE", Path("channels", channel_id, "thread-members", user_id), requestOptions), | ||
ListMembers: (channel_id, requestOptions) => Request("GET", Path("channels", channel_id, "thread-members"), requestOptions), | ||
}; | ||
exports.StageInstance = { | ||
Create: (params, requestOptions) => request_1.Request("POST", "/stage-instances", requestOptions ?? defaultRequestOptions, params), | ||
Get: (channel_id, requestOptions) => request_1.Request("GET", "/stage-instances/" + channel_id, requestOptions ?? defaultRequestOptions), | ||
Modify: (channel_id, params, requestOptions) => request_1.Request("PATCH", "/stage-instances/" + channel_id, requestOptions ?? defaultRequestOptions, params), | ||
Delete: (channel_id, requestOptions) => request_1.Request("DELETE", "/stage-instances/" + channel_id, requestOptions ?? defaultRequestOptions), | ||
export const StageInstance = { | ||
Create: (params, requestOptions) => Request("POST", "stage-instances", requestOptions, params), | ||
Get: (channel_id, requestOptions) => Request("GET", Path("stage-instances", channel_id), requestOptions), | ||
Modify: (channel_id, params, requestOptions) => Request("PATCH", Path("stage-instances", channel_id), requestOptions, params), | ||
Delete: (channel_id, requestOptions) => Request("DELETE", Path("stage-instances", channel_id), requestOptions), | ||
}; |
/// <reference types="node" /> | ||
import { EventEmitter } from 'events'; | ||
import { Intents, ActivityTypes, StatusTypes } from './helpers'; | ||
import { Authorization } from './request'; | ||
import { Intents, ActivityTypes, StatusTypes } from './helpers.js'; | ||
import { Authorization } from './request.js'; | ||
import type { EventHandler } from './events'; | ||
@@ -6,0 +6,0 @@ import type { User } from './types'; |
@@ -1,14 +0,8 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ClientEvents = exports.Client = void 0; | ||
const ws_1 = __importDefault(require("ws")); | ||
const events_1 = require("events"); | ||
const helpers_1 = require("./helpers"); | ||
const util_1 = require("./util"); | ||
const request_1 = require("./request"); | ||
import WebSocket from 'ws'; | ||
import { EventEmitter } from 'events'; | ||
import { API_VERSION, Intents, TokenTypes } from './helpers.js'; | ||
import { SafeJsonParse, Sleep } from './util.js'; | ||
import { Request } from './request.js'; | ||
const fatalCodes = [4004, 4010, 4011, 4012, 4013, 4014], dropCodes = [4007, 4009]; | ||
class Client extends events_1.EventEmitter { | ||
export class Client extends EventEmitter { | ||
constructor() { | ||
@@ -18,3 +12,3 @@ super(); | ||
this._lastHeartbeatAck = false; | ||
this._eventHandler = new events_1.EventEmitter(); | ||
this._eventHandler = new EventEmitter(); | ||
this._props = { $os: 'linux', $browser: 'bot', $device: 'bot' }; | ||
@@ -26,5 +20,5 @@ this._wsConnect = async (resume) => { | ||
this._lastSequence = 0; | ||
await util_1.Sleep(5000); | ||
await Sleep(5000); | ||
} | ||
const response = await request_1.Request('GET', this._auth?.authorization.type == helpers_1.TokenTypes.BOT ? | ||
const response = await Request('GET', this._auth?.authorization.type == TokenTypes.BOT ? | ||
'/gateway/bot' : | ||
@@ -39,3 +33,3 @@ '/gateway', this._auth).catch(() => { }); | ||
try { | ||
this._ws = new ws_1.default(`${response.url}?v=${helpers_1.API_VERSION}`); | ||
this._ws = new WebSocket(`${response.url}?v=${API_VERSION}`); | ||
} | ||
@@ -60,3 +54,3 @@ catch { | ||
this._onMessage = (data) => { | ||
const intent = util_1.SafeJsonParse(String(data)); | ||
const intent = SafeJsonParse(String(data)); | ||
if (!intent) | ||
@@ -112,3 +106,3 @@ return; | ||
properties: this._props, | ||
intents: this._intents ?? helpers_1.Intents.SYSTEM, | ||
intents: this._intents ?? Intents.SYSTEM, | ||
shard: this._shard, | ||
@@ -171,4 +165,3 @@ }); | ||
} | ||
exports.Client = Client; | ||
var ClientEvents; | ||
export var ClientEvents; | ||
(function (ClientEvents) { | ||
@@ -181,2 +174,2 @@ ClientEvents["CONNECT"] = "connect"; | ||
ClientEvents["FATAL"] = "fatal"; | ||
})(ClientEvents = exports.ClientEvents || (exports.ClientEvents = {})); | ||
})(ClientEvents || (ClientEvents = {})); |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Events = void 0; | ||
var Events; | ||
export var Events; | ||
(function (Events) { | ||
@@ -55,2 +52,2 @@ Events["READY"] = "READY"; | ||
Events["WEBHOOKS_UPDATE"] = "WEBHOOKS_UPDATE"; | ||
})(Events = exports.Events || (exports.Events = {})); | ||
})(Events || (Events = {})); |
@@ -1,2 +0,2 @@ | ||
export declare const HOST: "https://discord.com", API: "https://discord.com/api", API_VERSION = 9, API_PATH: "https://discord.com/api/v9", CDN = "https://cdn.discordapp.com"; | ||
export declare const HOST = "https://discord.com", API: "https://discord.com/api", API_VERSION = 9, API_PATH: "https://discord.com/api/v9", CDN = "https://cdn.discordapp.com"; | ||
export declare enum TokenTypes { | ||
@@ -3,0 +3,0 @@ BOT = "Bot", |
@@ -1,7 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TimestampStyles = exports.ApplicationFlags = exports.InviteTargetTypes = exports.GuildNSFWLevel = exports.PrivacyLevel = exports.ButtonStyles = exports.ComponentTypes = exports.VideoQualityModes = exports.SpeakingStates = exports.VoiceEncryptionModes = exports.MembershipStates = exports.OAuth2GrantTypes = exports.OAuth2Scopes = exports.InteractionResponseFlags = exports.InteractionResponseTypes = exports.InteractionTypes = exports.ApplicationCommandPermissionType = exports.ApplicationCommandOptionTypes = exports.ActivityFlags = exports.WebhookTypes = exports.VisibilityTypes = exports.PremiumTypes = exports.UserFlags = exports.WidgetStyleOptions = exports.StatusTypes = exports.ActivityTypes = exports.PremiumTier = exports.IntegrationExpireBehaviors = exports.GuildFeatures = exports.SystemChannelFlags = exports.VerificationLevel = exports.MFA_Level = exports.ExplicitContentFilterLevel = exports.DefaultMessageNotificationLevel = exports.AllowedMentionTypes = exports.PermissionsOverwriteTypes = exports.MessageStickerFormatTypes = exports.MessageFlags = exports.MessageActivityTypes = exports.MessageTypes = exports.ChannelTypes = exports.AuditLogEvents = exports.Intents = exports.Permissions = exports.TokenTypes = exports.CDN = exports.API_PATH = exports.API_VERSION = exports.API = exports.HOST = void 0; | ||
exports.ThreadArchiveDuration = void 0; | ||
exports.HOST = 'https://discord.com', exports.API = `${exports.HOST}/api`, exports.API_VERSION = 9, exports.API_PATH = `${exports.API}/v${exports.API_VERSION}`, exports.CDN = 'https://cdn.discordapp.com'; | ||
var TokenTypes; | ||
export const HOST = 'https://discord.com', API = `${HOST}/api`, API_VERSION = 9, API_PATH = `${API}/v${API_VERSION}`, CDN = 'https://cdn.discordapp.com'; | ||
export var TokenTypes; | ||
(function (TokenTypes) { | ||
@@ -11,4 +7,4 @@ TokenTypes["BOT"] = "Bot"; | ||
TokenTypes["NONE"] = ""; | ||
})(TokenTypes = exports.TokenTypes || (exports.TokenTypes = {})); | ||
exports.Permissions = { | ||
})(TokenTypes || (TokenTypes = {})); | ||
export const Permissions = { | ||
NO_PERMISSIONS: 0n, | ||
@@ -52,3 +48,3 @@ CREATE_INSTANT_INVITE: 0x0000000001n, | ||
}; | ||
var Intents; | ||
export var Intents; | ||
(function (Intents) { | ||
@@ -71,4 +67,4 @@ Intents[Intents["SYSTEM"] = 0] = "SYSTEM"; | ||
Intents[Intents["DIRECT_MESSAGE_TYPING"] = 16384] = "DIRECT_MESSAGE_TYPING"; | ||
})(Intents = exports.Intents || (exports.Intents = {})); | ||
var AuditLogEvents; | ||
})(Intents || (Intents = {})); | ||
export var AuditLogEvents; | ||
(function (AuditLogEvents) { | ||
@@ -119,4 +115,4 @@ AuditLogEvents[AuditLogEvents["GUILD_UPDATE"] = 1] = "GUILD_UPDATE"; | ||
AuditLogEvents[AuditLogEvents["THREAD_DELETE"] = 112] = "THREAD_DELETE"; | ||
})(AuditLogEvents = exports.AuditLogEvents || (exports.AuditLogEvents = {})); | ||
var ChannelTypes; | ||
})(AuditLogEvents || (AuditLogEvents = {})); | ||
export var ChannelTypes; | ||
(function (ChannelTypes) { | ||
@@ -134,4 +130,4 @@ ChannelTypes[ChannelTypes["GUILD_TEXT"] = 0] = "GUILD_TEXT"; | ||
ChannelTypes[ChannelTypes["GUILD_STAGE_VOICE"] = 13] = "GUILD_STAGE_VOICE"; | ||
})(ChannelTypes = exports.ChannelTypes || (exports.ChannelTypes = {})); | ||
var MessageTypes; | ||
})(ChannelTypes || (ChannelTypes = {})); | ||
export var MessageTypes; | ||
(function (MessageTypes) { | ||
@@ -160,4 +156,4 @@ MessageTypes[MessageTypes["DEFAULT"] = 0] = "DEFAULT"; | ||
MessageTypes[MessageTypes["GUILD_INVITE_REMINDER"] = 22] = "GUILD_INVITE_REMINDER"; | ||
})(MessageTypes = exports.MessageTypes || (exports.MessageTypes = {})); | ||
var MessageActivityTypes; | ||
})(MessageTypes || (MessageTypes = {})); | ||
export var MessageActivityTypes; | ||
(function (MessageActivityTypes) { | ||
@@ -168,4 +164,4 @@ MessageActivityTypes[MessageActivityTypes["JOIN"] = 1] = "JOIN"; | ||
MessageActivityTypes[MessageActivityTypes["JOIN_REQUEST"] = 5] = "JOIN_REQUEST"; | ||
})(MessageActivityTypes = exports.MessageActivityTypes || (exports.MessageActivityTypes = {})); | ||
var MessageFlags; | ||
})(MessageActivityTypes || (MessageActivityTypes = {})); | ||
export var MessageFlags; | ||
(function (MessageFlags) { | ||
@@ -181,4 +177,4 @@ MessageFlags[MessageFlags["NO_FLAGS"] = 0] = "NO_FLAGS"; | ||
MessageFlags[MessageFlags["LOADING"] = 128] = "LOADING"; | ||
})(MessageFlags = exports.MessageFlags || (exports.MessageFlags = {})); | ||
var MessageStickerFormatTypes; | ||
})(MessageFlags || (MessageFlags = {})); | ||
export var MessageStickerFormatTypes; | ||
(function (MessageStickerFormatTypes) { | ||
@@ -188,9 +184,9 @@ MessageStickerFormatTypes[MessageStickerFormatTypes["PNG"] = 1] = "PNG"; | ||
MessageStickerFormatTypes[MessageStickerFormatTypes["LOTTIE"] = 3] = "LOTTIE"; | ||
})(MessageStickerFormatTypes = exports.MessageStickerFormatTypes || (exports.MessageStickerFormatTypes = {})); | ||
var PermissionsOverwriteTypes; | ||
})(MessageStickerFormatTypes || (MessageStickerFormatTypes = {})); | ||
export var PermissionsOverwriteTypes; | ||
(function (PermissionsOverwriteTypes) { | ||
PermissionsOverwriteTypes[PermissionsOverwriteTypes["ROLE"] = 0] = "ROLE"; | ||
PermissionsOverwriteTypes[PermissionsOverwriteTypes["MEMBER"] = 1] = "MEMBER"; | ||
})(PermissionsOverwriteTypes = exports.PermissionsOverwriteTypes || (exports.PermissionsOverwriteTypes = {})); | ||
var AllowedMentionTypes; | ||
})(PermissionsOverwriteTypes || (PermissionsOverwriteTypes = {})); | ||
export var AllowedMentionTypes; | ||
(function (AllowedMentionTypes) { | ||
@@ -200,9 +196,9 @@ AllowedMentionTypes["ROLE_MENTIONS"] = "roles"; | ||
AllowedMentionTypes["EVERYONE_MENTIONS"] = "everyone"; | ||
})(AllowedMentionTypes = exports.AllowedMentionTypes || (exports.AllowedMentionTypes = {})); | ||
var DefaultMessageNotificationLevel; | ||
})(AllowedMentionTypes || (AllowedMentionTypes = {})); | ||
export var DefaultMessageNotificationLevel; | ||
(function (DefaultMessageNotificationLevel) { | ||
DefaultMessageNotificationLevel[DefaultMessageNotificationLevel["ALL_MESSAGES"] = 0] = "ALL_MESSAGES"; | ||
DefaultMessageNotificationLevel[DefaultMessageNotificationLevel["ONLY_MENTIONS"] = 1] = "ONLY_MENTIONS"; | ||
})(DefaultMessageNotificationLevel = exports.DefaultMessageNotificationLevel || (exports.DefaultMessageNotificationLevel = {})); | ||
var ExplicitContentFilterLevel; | ||
})(DefaultMessageNotificationLevel || (DefaultMessageNotificationLevel = {})); | ||
export var ExplicitContentFilterLevel; | ||
(function (ExplicitContentFilterLevel) { | ||
@@ -212,9 +208,9 @@ ExplicitContentFilterLevel[ExplicitContentFilterLevel["DISABLED"] = 0] = "DISABLED"; | ||
ExplicitContentFilterLevel[ExplicitContentFilterLevel["ALL_MEMBERS"] = 2] = "ALL_MEMBERS"; | ||
})(ExplicitContentFilterLevel = exports.ExplicitContentFilterLevel || (exports.ExplicitContentFilterLevel = {})); | ||
var MFA_Level; | ||
})(ExplicitContentFilterLevel || (ExplicitContentFilterLevel = {})); | ||
export var MFA_Level; | ||
(function (MFA_Level) { | ||
MFA_Level[MFA_Level["NONE"] = 0] = "NONE"; | ||
MFA_Level[MFA_Level["ELEVATED"] = 1] = "ELEVATED"; | ||
})(MFA_Level = exports.MFA_Level || (exports.MFA_Level = {})); | ||
var VerificationLevel; | ||
})(MFA_Level || (MFA_Level = {})); | ||
export var VerificationLevel; | ||
(function (VerificationLevel) { | ||
@@ -226,4 +222,4 @@ VerificationLevel[VerificationLevel["NONE"] = 0] = "NONE"; | ||
VerificationLevel[VerificationLevel["VERY_HIGH"] = 4] = "VERY_HIGH"; | ||
})(VerificationLevel = exports.VerificationLevel || (exports.VerificationLevel = {})); | ||
var SystemChannelFlags; | ||
})(VerificationLevel || (VerificationLevel = {})); | ||
export var SystemChannelFlags; | ||
(function (SystemChannelFlags) { | ||
@@ -234,4 +230,4 @@ SystemChannelFlags[SystemChannelFlags["NO_FLAGS"] = 0] = "NO_FLAGS"; | ||
SystemChannelFlags[SystemChannelFlags["SUPPRESS_GUILD_REMINDER_NOTIFICATIONS"] = 4] = "SUPPRESS_GUILD_REMINDER_NOTIFICATIONS"; | ||
})(SystemChannelFlags = exports.SystemChannelFlags || (exports.SystemChannelFlags = {})); | ||
var GuildFeatures; | ||
})(SystemChannelFlags || (SystemChannelFlags = {})); | ||
export var GuildFeatures; | ||
(function (GuildFeatures) { | ||
@@ -259,9 +255,9 @@ GuildFeatures["ANIMATED_ICON"] = "ANIMATED_ICON"; | ||
GuildFeatures["PRIVATE_THREADS"] = "PRIVATE_THREADS"; | ||
})(GuildFeatures = exports.GuildFeatures || (exports.GuildFeatures = {})); | ||
var IntegrationExpireBehaviors; | ||
})(GuildFeatures || (GuildFeatures = {})); | ||
export var IntegrationExpireBehaviors; | ||
(function (IntegrationExpireBehaviors) { | ||
IntegrationExpireBehaviors[IntegrationExpireBehaviors["REMOVE_ROLE"] = 0] = "REMOVE_ROLE"; | ||
IntegrationExpireBehaviors[IntegrationExpireBehaviors["KICK"] = 1] = "KICK"; | ||
})(IntegrationExpireBehaviors = exports.IntegrationExpireBehaviors || (exports.IntegrationExpireBehaviors = {})); | ||
var PremiumTier; | ||
})(IntegrationExpireBehaviors || (IntegrationExpireBehaviors = {})); | ||
export var PremiumTier; | ||
(function (PremiumTier) { | ||
@@ -272,4 +268,4 @@ PremiumTier[PremiumTier["NONE"] = 0] = "NONE"; | ||
PremiumTier[PremiumTier["TIER_3"] = 3] = "TIER_3"; | ||
})(PremiumTier = exports.PremiumTier || (exports.PremiumTier = {})); | ||
var ActivityTypes; | ||
})(PremiumTier || (PremiumTier = {})); | ||
export var ActivityTypes; | ||
(function (ActivityTypes) { | ||
@@ -282,4 +278,4 @@ ActivityTypes[ActivityTypes["PLAYING"] = 0] = "PLAYING"; | ||
ActivityTypes[ActivityTypes["COMPETING"] = 5] = "COMPETING"; | ||
})(ActivityTypes = exports.ActivityTypes || (exports.ActivityTypes = {})); | ||
var StatusTypes; | ||
})(ActivityTypes || (ActivityTypes = {})); | ||
export var StatusTypes; | ||
(function (StatusTypes) { | ||
@@ -291,4 +287,4 @@ StatusTypes["ONLINE"] = "online"; | ||
StatusTypes["OFFLINE"] = "offline"; | ||
})(StatusTypes = exports.StatusTypes || (exports.StatusTypes = {})); | ||
var WidgetStyleOptions; | ||
})(StatusTypes || (StatusTypes = {})); | ||
export var WidgetStyleOptions; | ||
(function (WidgetStyleOptions) { | ||
@@ -300,4 +296,4 @@ WidgetStyleOptions["SHIELD"] = "shield"; | ||
WidgetStyleOptions["BANNER4"] = "banner4"; | ||
})(WidgetStyleOptions = exports.WidgetStyleOptions || (exports.WidgetStyleOptions = {})); | ||
var UserFlags; | ||
})(WidgetStyleOptions || (WidgetStyleOptions = {})); | ||
export var UserFlags; | ||
(function (UserFlags) { | ||
@@ -318,4 +314,4 @@ UserFlags[UserFlags["NO_FLAGS"] = 0] = "NO_FLAGS"; | ||
UserFlags[UserFlags["DISCORD_CERTIFIED_MODERATOR"] = 262144] = "DISCORD_CERTIFIED_MODERATOR"; | ||
})(UserFlags = exports.UserFlags || (exports.UserFlags = {})); | ||
var PremiumTypes; | ||
})(UserFlags || (UserFlags = {})); | ||
export var PremiumTypes; | ||
(function (PremiumTypes) { | ||
@@ -325,9 +321,9 @@ PremiumTypes[PremiumTypes["NONE"] = 0] = "NONE"; | ||
PremiumTypes[PremiumTypes["NITRO"] = 2] = "NITRO"; | ||
})(PremiumTypes = exports.PremiumTypes || (exports.PremiumTypes = {})); | ||
var VisibilityTypes; | ||
})(PremiumTypes || (PremiumTypes = {})); | ||
export var VisibilityTypes; | ||
(function (VisibilityTypes) { | ||
VisibilityTypes[VisibilityTypes["NONE"] = 0] = "NONE"; | ||
VisibilityTypes[VisibilityTypes["EVERYONE"] = 1] = "EVERYONE"; | ||
})(VisibilityTypes = exports.VisibilityTypes || (exports.VisibilityTypes = {})); | ||
var WebhookTypes; | ||
})(VisibilityTypes || (VisibilityTypes = {})); | ||
export var WebhookTypes; | ||
(function (WebhookTypes) { | ||
@@ -337,4 +333,4 @@ WebhookTypes[WebhookTypes["INCOMING"] = 1] = "INCOMING"; | ||
WebhookTypes[WebhookTypes["APPLICATION"] = 3] = "APPLICATION"; | ||
})(WebhookTypes = exports.WebhookTypes || (exports.WebhookTypes = {})); | ||
var ActivityFlags; | ||
})(WebhookTypes || (WebhookTypes = {})); | ||
export var ActivityFlags; | ||
(function (ActivityFlags) { | ||
@@ -348,4 +344,4 @@ ActivityFlags[ActivityFlags["NO_FLAGS"] = 0] = "NO_FLAGS"; | ||
ActivityFlags[ActivityFlags["PLAY"] = 32] = "PLAY"; | ||
})(ActivityFlags = exports.ActivityFlags || (exports.ActivityFlags = {})); | ||
var ApplicationCommandOptionTypes; | ||
})(ActivityFlags || (ActivityFlags = {})); | ||
export var ApplicationCommandOptionTypes; | ||
(function (ApplicationCommandOptionTypes) { | ||
@@ -362,9 +358,9 @@ ApplicationCommandOptionTypes[ApplicationCommandOptionTypes["SUB_COMMAND"] = 1] = "SUB_COMMAND"; | ||
ApplicationCommandOptionTypes[ApplicationCommandOptionTypes["NUMBER"] = 10] = "NUMBER"; | ||
})(ApplicationCommandOptionTypes = exports.ApplicationCommandOptionTypes || (exports.ApplicationCommandOptionTypes = {})); | ||
var ApplicationCommandPermissionType; | ||
})(ApplicationCommandOptionTypes || (ApplicationCommandOptionTypes = {})); | ||
export var ApplicationCommandPermissionType; | ||
(function (ApplicationCommandPermissionType) { | ||
ApplicationCommandPermissionType[ApplicationCommandPermissionType["ROLE"] = 1] = "ROLE"; | ||
ApplicationCommandPermissionType[ApplicationCommandPermissionType["USER"] = 2] = "USER"; | ||
})(ApplicationCommandPermissionType = exports.ApplicationCommandPermissionType || (exports.ApplicationCommandPermissionType = {})); | ||
var InteractionTypes; | ||
})(ApplicationCommandPermissionType || (ApplicationCommandPermissionType = {})); | ||
export var InteractionTypes; | ||
(function (InteractionTypes) { | ||
@@ -374,4 +370,4 @@ InteractionTypes[InteractionTypes["PING"] = 1] = "PING"; | ||
InteractionTypes[InteractionTypes["MESSAGE_COMPONENT"] = 3] = "MESSAGE_COMPONENT"; | ||
})(InteractionTypes = exports.InteractionTypes || (exports.InteractionTypes = {})); | ||
var InteractionResponseTypes; | ||
})(InteractionTypes || (InteractionTypes = {})); | ||
export var InteractionResponseTypes; | ||
(function (InteractionResponseTypes) { | ||
@@ -383,8 +379,8 @@ InteractionResponseTypes[InteractionResponseTypes["PONG"] = 1] = "PONG"; | ||
InteractionResponseTypes[InteractionResponseTypes["UPDATE_MESSAGE"] = 7] = "UPDATE_MESSAGE"; | ||
})(InteractionResponseTypes = exports.InteractionResponseTypes || (exports.InteractionResponseTypes = {})); | ||
var InteractionResponseFlags; | ||
})(InteractionResponseTypes || (InteractionResponseTypes = {})); | ||
export var InteractionResponseFlags; | ||
(function (InteractionResponseFlags) { | ||
InteractionResponseFlags[InteractionResponseFlags["EPHEMERAL"] = 64] = "EPHEMERAL"; | ||
})(InteractionResponseFlags = exports.InteractionResponseFlags || (exports.InteractionResponseFlags = {})); | ||
var OAuth2Scopes; | ||
})(InteractionResponseFlags || (InteractionResponseFlags = {})); | ||
export var OAuth2Scopes; | ||
(function (OAuth2Scopes) { | ||
@@ -414,14 +410,14 @@ OAuth2Scopes["ACTIVITIES_READ"] = "activities.read"; | ||
OAuth2Scopes["WEBHOOK_INCOMING"] = "webhook.incoming"; | ||
})(OAuth2Scopes = exports.OAuth2Scopes || (exports.OAuth2Scopes = {})); | ||
var OAuth2GrantTypes; | ||
})(OAuth2Scopes || (OAuth2Scopes = {})); | ||
export var OAuth2GrantTypes; | ||
(function (OAuth2GrantTypes) { | ||
OAuth2GrantTypes["AUTHORIZATION_CODE"] = "authorization_code"; | ||
OAuth2GrantTypes["REFRESH_TOKEN"] = "refresh_token"; | ||
})(OAuth2GrantTypes = exports.OAuth2GrantTypes || (exports.OAuth2GrantTypes = {})); | ||
var MembershipStates; | ||
})(OAuth2GrantTypes || (OAuth2GrantTypes = {})); | ||
export var MembershipStates; | ||
(function (MembershipStates) { | ||
MembershipStates[MembershipStates["INVITED"] = 1] = "INVITED"; | ||
MembershipStates[MembershipStates["ACCEPTED"] = 2] = "ACCEPTED"; | ||
})(MembershipStates = exports.MembershipStates || (exports.MembershipStates = {})); | ||
var VoiceEncryptionModes; | ||
})(MembershipStates || (MembershipStates = {})); | ||
export var VoiceEncryptionModes; | ||
(function (VoiceEncryptionModes) { | ||
@@ -431,4 +427,4 @@ VoiceEncryptionModes["XSALSA20_POLY1305"] = "xsalsa20_poly1305"; | ||
VoiceEncryptionModes["XSALSA20_POLY1305_LITE"] = "xsalsa20_poly1305_lite"; | ||
})(VoiceEncryptionModes = exports.VoiceEncryptionModes || (exports.VoiceEncryptionModes = {})); | ||
var SpeakingStates; | ||
})(VoiceEncryptionModes || (VoiceEncryptionModes = {})); | ||
export var SpeakingStates; | ||
(function (SpeakingStates) { | ||
@@ -439,9 +435,9 @@ SpeakingStates[SpeakingStates["NO_FLAGS"] = 0] = "NO_FLAGS"; | ||
SpeakingStates[SpeakingStates["PRIORITY"] = 4] = "PRIORITY"; | ||
})(SpeakingStates = exports.SpeakingStates || (exports.SpeakingStates = {})); | ||
var VideoQualityModes; | ||
})(SpeakingStates || (SpeakingStates = {})); | ||
export var VideoQualityModes; | ||
(function (VideoQualityModes) { | ||
VideoQualityModes[VideoQualityModes["AUTO"] = 1] = "AUTO"; | ||
VideoQualityModes[VideoQualityModes["FULL"] = 2] = "FULL"; | ||
})(VideoQualityModes = exports.VideoQualityModes || (exports.VideoQualityModes = {})); | ||
var ComponentTypes; | ||
})(VideoQualityModes || (VideoQualityModes = {})); | ||
export var ComponentTypes; | ||
(function (ComponentTypes) { | ||
@@ -451,4 +447,4 @@ ComponentTypes[ComponentTypes["ACTION_ROW"] = 1] = "ACTION_ROW"; | ||
ComponentTypes[ComponentTypes["SELECT_MENU"] = 3] = "SELECT_MENU"; | ||
})(ComponentTypes = exports.ComponentTypes || (exports.ComponentTypes = {})); | ||
var ButtonStyles; | ||
})(ComponentTypes || (ComponentTypes = {})); | ||
export var ButtonStyles; | ||
(function (ButtonStyles) { | ||
@@ -460,9 +456,9 @@ ButtonStyles[ButtonStyles["PRIMARY"] = 1] = "PRIMARY"; | ||
ButtonStyles[ButtonStyles["LINK"] = 5] = "LINK"; | ||
})(ButtonStyles = exports.ButtonStyles || (exports.ButtonStyles = {})); | ||
var PrivacyLevel; | ||
})(ButtonStyles || (ButtonStyles = {})); | ||
export var PrivacyLevel; | ||
(function (PrivacyLevel) { | ||
PrivacyLevel[PrivacyLevel["PUBLIC"] = 1] = "PUBLIC"; | ||
PrivacyLevel[PrivacyLevel["GUILD_ONLY"] = 2] = "GUILD_ONLY"; | ||
})(PrivacyLevel = exports.PrivacyLevel || (exports.PrivacyLevel = {})); | ||
var GuildNSFWLevel; | ||
})(PrivacyLevel || (PrivacyLevel = {})); | ||
export var GuildNSFWLevel; | ||
(function (GuildNSFWLevel) { | ||
@@ -473,9 +469,9 @@ GuildNSFWLevel[GuildNSFWLevel["DEFAULT"] = 0] = "DEFAULT"; | ||
GuildNSFWLevel[GuildNSFWLevel["AGE_RESTRICTED"] = 3] = "AGE_RESTRICTED"; | ||
})(GuildNSFWLevel = exports.GuildNSFWLevel || (exports.GuildNSFWLevel = {})); | ||
var InviteTargetTypes; | ||
})(GuildNSFWLevel || (GuildNSFWLevel = {})); | ||
export var InviteTargetTypes; | ||
(function (InviteTargetTypes) { | ||
InviteTargetTypes[InviteTargetTypes["STREAM"] = 1] = "STREAM"; | ||
InviteTargetTypes[InviteTargetTypes["EMBEDDED_APPLICATION"] = 2] = "EMBEDDED_APPLICATION"; | ||
})(InviteTargetTypes = exports.InviteTargetTypes || (exports.InviteTargetTypes = {})); | ||
var ApplicationFlags; | ||
})(InviteTargetTypes || (InviteTargetTypes = {})); | ||
export var ApplicationFlags; | ||
(function (ApplicationFlags) { | ||
@@ -489,4 +485,4 @@ ApplicationFlags[ApplicationFlags["NO_FLAGS"] = 0] = "NO_FLAGS"; | ||
ApplicationFlags[ApplicationFlags["EMBEDDED"] = 131072] = "EMBEDDED"; | ||
})(ApplicationFlags = exports.ApplicationFlags || (exports.ApplicationFlags = {})); | ||
var TimestampStyles; | ||
})(ApplicationFlags || (ApplicationFlags = {})); | ||
export var TimestampStyles; | ||
(function (TimestampStyles) { | ||
@@ -500,4 +496,4 @@ TimestampStyles["SHORT_TIME"] = "t"; | ||
TimestampStyles["RELATIVE_TIME"] = "R"; | ||
})(TimestampStyles = exports.TimestampStyles || (exports.TimestampStyles = {})); | ||
var ThreadArchiveDuration; | ||
})(TimestampStyles || (TimestampStyles = {})); | ||
export var ThreadArchiveDuration; | ||
(function (ThreadArchiveDuration) { | ||
@@ -508,2 +504,2 @@ ThreadArchiveDuration[ThreadArchiveDuration["_1_HOUR"] = 60] = "_1_HOUR"; | ||
ThreadArchiveDuration[ThreadArchiveDuration["_1_WEEK"] = 10080] = "_1_WEEK"; | ||
})(ThreadArchiveDuration = exports.ThreadArchiveDuration || (exports.ThreadArchiveDuration = {})); | ||
})(ThreadArchiveDuration || (ThreadArchiveDuration = {})); |
@@ -1,9 +0,9 @@ | ||
export { Client, ClientEvents } from './client'; | ||
export { Authorization } from './request'; | ||
export { Events } from './events'; | ||
export * as Actions from './actions'; | ||
export * as Helpers from './helpers'; | ||
export { Client, ClientEvents } from './client.js'; | ||
export { Authorization } from './request.js'; | ||
export { Events } from './events.js'; | ||
export * as Actions from './actions.js'; | ||
export * as Helpers from './helpers.js'; | ||
import type * as Types from './types'; | ||
export { Types }; | ||
export * as Tools from './tools'; | ||
export { Voice, VoiceEvents } from './voice'; | ||
export * as Tools from './tools.js'; | ||
export { Voice, VoiceEvents } from './voice.js'; |
@@ -1,35 +0,10 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.VoiceEvents = exports.Voice = exports.Tools = exports.Helpers = exports.Actions = exports.Events = exports.Authorization = exports.ClientEvents = exports.Client = void 0; | ||
var client_1 = require("./client"); | ||
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } }); | ||
Object.defineProperty(exports, "ClientEvents", { enumerable: true, get: function () { return client_1.ClientEvents; } }); | ||
var request_1 = require("./request"); | ||
Object.defineProperty(exports, "Authorization", { enumerable: true, get: function () { return request_1.Authorization; } }); | ||
var events_1 = require("./events"); | ||
Object.defineProperty(exports, "Events", { enumerable: true, get: function () { return events_1.Events; } }); | ||
exports.Actions = __importStar(require("./actions")); | ||
exports.Helpers = __importStar(require("./helpers")); | ||
exports.Tools = __importStar(require("./tools")); | ||
var voice_1 = require("./voice"); | ||
Object.defineProperty(exports, "Voice", { enumerable: true, get: function () { return voice_1.Voice; } }); | ||
Object.defineProperty(exports, "VoiceEvents", { enumerable: true, get: function () { return voice_1.VoiceEvents; } }); | ||
export { Client, ClientEvents } from './client.js'; | ||
export { Authorization } from './request.js'; | ||
export { Events } from './events.js'; | ||
import * as Actions_1 from './actions.js'; | ||
export { Actions_1 as Actions }; | ||
import * as Helpers_1 from './helpers.js'; | ||
export { Helpers_1 as Helpers }; | ||
import * as Tools_1 from './tools.js'; | ||
export { Tools_1 as Tools }; | ||
export { Voice, VoiceEvents } from './voice.js'; |
@@ -1,2 +0,2 @@ | ||
import { TokenTypes } from './helpers'; | ||
import { TokenTypes } from './helpers.js'; | ||
export declare class Authorization { | ||
@@ -27,2 +27,3 @@ private _type; | ||
}; | ||
export declare const SetDefOptions: (options?: RequestOptions | undefined) => RequestOptions | undefined; | ||
export declare const Request: (method: string, endpoint: string, options?: RequestOptions | undefined, data?: string | object | null | undefined) => Promise<any>; |
@@ -1,13 +0,7 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Request = exports.Authorization = void 0; | ||
const https_1 = __importDefault(require("https")); | ||
const util_1 = require("./util"); | ||
const helpers_1 = require("./helpers"); | ||
import https from 'https'; | ||
import { SafeJsonParse } from './util.js'; | ||
import { TokenTypes, API_PATH } from './helpers.js'; | ||
const DEFAULT_CONNECTION_TIMEOUT = 5000, DEFAULT_RETRY_COUNT = 5; | ||
class Authorization { | ||
constructor(token, type = helpers_1.TokenTypes.BOT) { | ||
export class Authorization { | ||
constructor(token, type = TokenTypes.BOT) { | ||
this._update = () => this._cache = this._type ? | ||
@@ -32,5 +26,6 @@ `${this._type} ${this._token}` : | ||
} | ||
exports.Authorization = Authorization; | ||
; | ||
const Request = (method, endpoint, options, data) => { | ||
let defOptions; | ||
export const SetDefOptions = (options) => defOptions = options; | ||
export const Request = (method, endpoint, options = defOptions, data) => { | ||
let content; | ||
@@ -55,12 +50,12 @@ const headers = {}; | ||
}; | ||
const URL = helpers_1.API_PATH + endpoint, retryCount = options?.rateLimit?.retryCount ?? DEFAULT_RETRY_COUNT, rateLimitCallback = options?.rateLimit?.callback; | ||
const url = `${API_PATH}/${endpoint}`, retryCount = options?.rateLimit?.retryCount ?? DEFAULT_RETRY_COUNT, rateLimitCallback = options?.rateLimit?.callback; | ||
return new Promise((resolve, reject) => { | ||
let attempts = 0; | ||
const TryRequest = () => { | ||
HttpsRequest(URL, requestOptions, content).then((result) => { | ||
HttpsRequest(url, requestOptions, content).then((result) => { | ||
const code = result.code; | ||
if ((code >= 200) && (code < 300)) | ||
return resolve(util_1.SafeJsonParse(result.data)); | ||
return resolve(SafeJsonParse(result.data)); | ||
if ((code >= 400) && (code < 500)) { | ||
const response = util_1.SafeJsonParse(result.data); | ||
const response = SafeJsonParse(result.data); | ||
if (code != 429) | ||
@@ -80,5 +75,4 @@ return reject({ code, response }); | ||
}; | ||
exports.Request = Request; | ||
const HttpsRequest = (url, options, content) => new Promise((resolve, reject) => { | ||
const request = https_1.default.request(url, options, (response) => { | ||
const request = https.request(url, options, (response) => { | ||
const code = response.statusCode; | ||
@@ -85,0 +79,0 @@ if (!code) |
@@ -1,2 +0,2 @@ | ||
import { Permissions as Flags, TimestampStyles } from './helpers'; | ||
import { Permissions as Flags, TimestampStyles } from './helpers.js'; | ||
import type { Guild, User, Application, Team, Emoji, Message, Channel, Role } from './types'; | ||
@@ -3,0 +3,0 @@ declare type Permission = typeof Flags[keyof typeof Flags]; |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CdnImages = exports.Link = exports.Format = exports.Mentions = exports.Permissions = void 0; | ||
const helpers_1 = require("./helpers"); | ||
exports.Permissions = { | ||
import { Permissions as Flags, CDN, HOST } from './helpers.js'; | ||
export const Permissions = { | ||
equals: (a, b) => BigInt(a) == BigInt(b), | ||
@@ -14,3 +11,3 @@ combine: (permissions) => { | ||
check: (source, permission) => (BigInt(source) & BigInt(permission)) == BigInt(permission), | ||
has: (source, permission) => exports.Permissions.check(source, helpers_1.Permissions.ADMINISTRATOR) || exports.Permissions.check(source, permission), | ||
has: (source, permission) => Permissions.check(source, Flags.ADMINISTRATOR) || Permissions.check(source, permission), | ||
add: (source, permission) => String(BigInt(source) | BigInt(permission)), | ||
@@ -20,3 +17,3 @@ remove: (source, permission) => String(BigInt(source) & ~BigInt(permission)), | ||
const EID = (value) => (typeof value == 'object') ? value.id : value; | ||
exports.Mentions = { | ||
export const Mentions = { | ||
User: (user) => `<@${EID(user)}>`, | ||
@@ -26,3 +23,3 @@ Channel: (channel) => `<#${EID(channel)}>`, | ||
}; | ||
exports.Format = { | ||
export const Format = { | ||
Emoji: (emoji) => `<${emoji.animated ? 'a' : ''}:${emoji.name}:${emoji.id}>`, | ||
@@ -43,19 +40,19 @@ Reaction: (emoji) => `${emoji.name}:${emoji.id}`, | ||
}; | ||
exports.Link = { | ||
Message: (message) => `${helpers_1.HOST}/channels/${message.guild_id ?? '@me'}/${message.channel_id}/${message.id}`, | ||
export const Link = { | ||
Message: (message) => `${HOST}/channels/${message.guild_id ?? '@me'}/${message.channel_id}/${message.id}`, | ||
}; | ||
const SizeExtOpt = (size, ext) => (ext ? `.${ext}` : '') + (size ? `?size=${size}` : ''); | ||
exports.CdnImages = { | ||
CustomEmoji: (emoji, size, ext) => `${helpers_1.CDN}/emojis/${EID(emoji)}${SizeExtOpt(size, ext)}`, | ||
GuildIcon: (guild, size, ext) => guild.icon ? `${helpers_1.CDN}/icons/${guild.id}/${guild.icon}${SizeExtOpt(size, ext)}` : null, | ||
GuildSplash: (guild, size, ext) => guild.splash ? `${helpers_1.CDN}/splashes/${guild.id}/${guild.splash}${SizeExtOpt(size, ext)}` : null, | ||
GuildDiscoverySplash: (guild, size, ext) => guild.discovery_splash ? `${helpers_1.CDN}/discovery-splashes/${guild.id}/${guild.discovery_splash}${SizeExtOpt(size, ext)}` : null, | ||
GuildBanner: (guild, size, ext) => guild.banner ? `${helpers_1.CDN}/banners/${guild.id}/${guild.banner}${SizeExtOpt(size, ext)}` : null, | ||
export const CdnImages = { | ||
CustomEmoji: (emoji, size, ext) => `${CDN}/emojis/${EID(emoji)}${SizeExtOpt(size, ext)}`, | ||
GuildIcon: (guild, size, ext) => guild.icon ? `${CDN}/icons/${guild.id}/${guild.icon}${SizeExtOpt(size, ext)}` : null, | ||
GuildSplash: (guild, size, ext) => guild.splash ? `${CDN}/splashes/${guild.id}/${guild.splash}${SizeExtOpt(size, ext)}` : null, | ||
GuildDiscoverySplash: (guild, size, ext) => guild.discovery_splash ? `${CDN}/discovery-splashes/${guild.id}/${guild.discovery_splash}${SizeExtOpt(size, ext)}` : null, | ||
GuildBanner: (guild, size, ext) => guild.banner ? `${CDN}/banners/${guild.id}/${guild.banner}${SizeExtOpt(size, ext)}` : null, | ||
UserAvatar: (user, size, ext) => user.avatar ? | ||
`${helpers_1.CDN}/avatars/${user.id}/${user.avatar}${SizeExtOpt(size, ext)}` : | ||
`${helpers_1.CDN}/embed/avatars/${Number(user.discriminator) % 5}.png`, | ||
ApplicationIcon: (application, size, ext) => application.icon ? `${helpers_1.CDN}/app-icons/${application.id}/${application.icon}${SizeExtOpt(size, ext)}` : null, | ||
ApplicationAsset: (application, asset_id, size, ext) => `${helpers_1.CDN}/app-assets/${EID(application)}/${asset_id}${SizeExtOpt(size, ext)}`, | ||
AchievementIcon: (application, achievement_id, icon_hash, size, ext) => `${helpers_1.CDN}/app-assets/${EID(application)}/achievements/${achievement_id}/icons/${icon_hash}${SizeExtOpt(size, ext)}`, | ||
TeamIcon: (team, size, ext) => team.icon ? `${helpers_1.CDN}/team-icons/${team.id}/${team.icon}${SizeExtOpt(size, ext)}` : null, | ||
`${CDN}/avatars/${user.id}/${user.avatar}${SizeExtOpt(size, ext)}` : | ||
`${CDN}/embed/avatars/${Number(user.discriminator) % 5}.png`, | ||
ApplicationIcon: (application, size, ext) => application.icon ? `${CDN}/app-icons/${application.id}/${application.icon}${SizeExtOpt(size, ext)}` : null, | ||
ApplicationAsset: (application, asset_id, size, ext) => `${CDN}/app-assets/${EID(application)}/${asset_id}${SizeExtOpt(size, ext)}`, | ||
AchievementIcon: (application, achievement_id, icon_hash, size, ext) => `${CDN}/app-assets/${EID(application)}/achievements/${achievement_id}/icons/${icon_hash}${SizeExtOpt(size, ext)}`, | ||
TeamIcon: (team, size, ext) => team.icon ? `${CDN}/team-icons/${team.id}/${team.icon}${SizeExtOpt(size, ext)}` : null, | ||
}; |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Sleep = exports.SafeJsonParse = void 0; | ||
const SafeJsonParse = (data) => { | ||
export const SafeJsonParse = (data) => { | ||
if (data != null) | ||
@@ -12,4 +9,2 @@ try { | ||
}; | ||
exports.SafeJsonParse = SafeJsonParse; | ||
const Sleep = (time) => new Promise((resolve) => setTimeout(resolve, time)); | ||
exports.Sleep = Sleep; | ||
export const Sleep = (time) => new Promise((resolve) => setTimeout(resolve, time)); |
/// <reference types="node" /> | ||
import { EventEmitter } from 'events'; | ||
import { VoiceEncryptionModes, SpeakingStates } from './helpers'; | ||
import { VoiceEncryptionModes, SpeakingStates } from './helpers.js'; | ||
export declare class Voice extends EventEmitter { | ||
@@ -5,0 +5,0 @@ private _ws?; |
@@ -1,13 +0,7 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.VoiceEvents = exports.Voice = void 0; | ||
const ws_1 = __importDefault(require("ws")); | ||
const events_1 = require("events"); | ||
const util_1 = require("./util"); | ||
import WebSocket from 'ws'; | ||
import { EventEmitter } from 'events'; | ||
import { SafeJsonParse, Sleep } from './util.js'; | ||
const VOICE_VERSION = 4; | ||
const fatalCodes = [4002, 4004, 4006, 4011, 4014], dropCodes = [4009]; | ||
class Voice extends events_1.EventEmitter { | ||
export class Voice extends EventEmitter { | ||
constructor() { | ||
@@ -21,7 +15,7 @@ super(); | ||
this._resume = false; | ||
await util_1.Sleep(5000); | ||
await Sleep(5000); | ||
} | ||
if (this._ws) | ||
return this.emit(VoiceEvents.WARN, 'Voice already connected.'); | ||
this._ws = new ws_1.default(`wss://${this._endpoint}?v=${VOICE_VERSION}`); | ||
this._ws = new WebSocket(`wss://${this._endpoint}?v=${VOICE_VERSION}`); | ||
this._ws.on('message', this._onMessage); | ||
@@ -42,3 +36,3 @@ this._ws.on('close', this._onClose); | ||
this._onMessage = (data) => { | ||
const intent = util_1.SafeJsonParse(String(data)); | ||
const intent = SafeJsonParse(String(data)); | ||
if (!intent) | ||
@@ -123,4 +117,3 @@ return; | ||
} | ||
exports.Voice = Voice; | ||
var VoiceEvents; | ||
export var VoiceEvents; | ||
(function (VoiceEvents) { | ||
@@ -132,2 +125,2 @@ VoiceEvents["CONNECT"] = "connect"; | ||
VoiceEvents["FATAL"] = "fatal"; | ||
})(VoiceEvents = exports.VoiceEvents || (exports.VoiceEvents = {})); | ||
})(VoiceEvents || (VoiceEvents = {})); |
{ | ||
"name": "discord-slim", | ||
"version": "2.1.9", | ||
"version": "2.2.0", | ||
"description": "Lightweight Discord API library for Node.js.", | ||
@@ -18,2 +18,3 @@ "author": "Hanabishi", | ||
], | ||
"type": "module", | ||
"main": "./dist/index.js", | ||
@@ -20,0 +21,0 @@ "types": "./dist/index.d.ts", |
@@ -36,3 +36,3 @@ # Discord Slim | ||
```js | ||
const { Client, ClientEvents, Authorization, Events, Actions, Helpers, Tools } = require('discord-slim'); | ||
import { Client, ClientEvents, Authorization, Events, Actions, Helpers, Tools } from 'discord-slim'; | ||
@@ -39,0 +39,0 @@ // Basic setup to control client operation. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Yes
158391
3452
1