diff --git a/packages/client/src/Client.ts b/packages/client/src/Client.ts index ecc285d3d..c14d4ff73 100644 --- a/packages/client/src/Client.ts +++ b/packages/client/src/Client.ts @@ -2367,6 +2367,11 @@ export class Client extends EventEmitter { export default Client export interface ClientOptions { + /** + * @deprecated this property does absolutely nothing. Please delete from ur code. Thanks. + * Keeping this only to preserve 1:1 api with eris. + */ + restMode?: boolean; /** The default allowed mentions you would like to use. */ allowedMentions?: AllowedMentions /** The default image format you would like to use. */ diff --git a/packages/client/src/Constants.ts b/packages/client/src/Constants.ts index 2b442cfde..91c5971ff 100644 --- a/packages/client/src/Constants.ts +++ b/packages/client/src/Constants.ts @@ -1,5 +1,5 @@ -export const GATEWAY_VERSION = 9; -export const REST_VERSION = 9; +export const GATEWAY_VERSION = 10; +export const REST_VERSION = 10; export const ActivityTypes = { GAME: 0, @@ -106,19 +106,19 @@ export const ButtonStyles = { LINK: 5 }; -export const ChannelTypes = { - GUILD_TEXT: 0, - DM: 1, - GUILD_VOICE: 2, - GROUP_DM: 3, - GUILD_CATEGORY: 4, - GUILD_NEWS: 5, - GUILD_STORE: 6, +export enum ChannelTypes { + GUILD_TEXT = 0, + DM = 1, + GUILD_VOICE = 2, + GROUP_DM = 3, + GUILD_CATEGORY = 4, + GUILD_NEWS = 5, + GUILD_STORE = 6, - GUILD_NEWS_THREAD: 10, - GUILD_PUBLIC_THREAD: 11, - GUILD_PRIVATE_THREAD: 12, - GUILD_STAGE_VOICE: 13, GUILD_STAGE: 13 // [DEPRECATED] + GUILD_NEWS_THREAD = 10, + GUILD_PUBLIC_THREAD = 11, + GUILD_PRIVATE_THREAD = 12, + GUILD_STAGE_VOICE = 13, GUILD_STAGE = 13 // [DEPRECATED] }; export const ComponentTypes = { diff --git a/packages/client/src/Structures/PermissionOverwrite.ts b/packages/client/src/Structures/PermissionOverwrite.ts index 8f613a3fa..c59e07b3f 100644 --- a/packages/client/src/Structures/PermissionOverwrite.ts +++ b/packages/client/src/Structures/PermissionOverwrite.ts @@ -1,10 +1,9 @@ import type { DiscordOverwrite, OverwriteTypes } from '@discordeno/types' import { Base } from '../Base.js' -import type { BigString } from '../Client.js' import Permission from './Permission.js' export class PermissionOverwrite extends Permission { - id: BigString + id: string type: OverwriteTypes constructor(data: DiscordOverwrite) { diff --git a/packages/client/src/Structures/channels/Guild.ts b/packages/client/src/Structures/channels/Guild.ts index c9a89a167..603c9bb7b 100644 --- a/packages/client/src/Structures/channels/Guild.ts +++ b/packages/client/src/Structures/channels/Guild.ts @@ -14,7 +14,7 @@ import Channel from './Channel.js' export class GuildChannel extends Channel { position: number name: string - parentID?: BigString | null + parentID?: string | null guild: Guild nsfw: boolean permissionOverwrites = new Collection() diff --git a/packages/client/src/Structures/channels/Private.ts b/packages/client/src/Structures/channels/Private.ts index d110a5291..0802c1b4a 100644 --- a/packages/client/src/Structures/channels/Private.ts +++ b/packages/client/src/Structures/channels/Private.ts @@ -9,7 +9,7 @@ import Channel from './Channel.js' export class PrivateChannel extends Channel { /** The ID of the last message in this channel */ - lastMessageID?: string | null + lastMessageID = "" // TODO: THIS A THING IN DMS???? /** The rate limit per user. */ rateLimitPerUser?: number @@ -21,7 +21,7 @@ export class PrivateChannel extends Channel { constructor(data: DiscordChannel, client: Client) { super(data, client) - this.lastMessageID = data.last_message_id + this.lastMessageID = data.last_message_id ?? "" this.rateLimitPerUser = data.rate_limit_per_user if (this.type === ChannelTypes.DM || this.type === undefined) { if (data.recipients?.[0]) this.recipient = new User(data.recipients[0], client) diff --git a/packages/client/src/Structures/channels/Text.ts b/packages/client/src/Structures/channels/Text.ts index 50116c318..95a86d1a5 100644 --- a/packages/client/src/Structures/channels/Text.ts +++ b/packages/client/src/Structures/channels/Text.ts @@ -27,7 +27,7 @@ export class TextChannel extends GuildChannel { /** The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled */ rateLimitPerUser: number | null /** The ID of the last message in this channel */ - lastMessageID?: string | null + lastMessageID = "" /** The timestamp of the last pinned message */ lastPinTimestamp?: number | null /** Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 */ @@ -44,7 +44,7 @@ export class TextChannel extends GuildChannel { this.rateLimitPerUser = data.rate_limit_per_user == null ? null : data.rate_limit_per_user - this.lastMessageID = data.last_message_id ?? null + this.lastMessageID = data.last_message_id ?? "" this.lastPinTimestamp = data.last_pin_timestamp ? Date.parse(data.last_pin_timestamp) : null this.update(data) diff --git a/packages/client/src/Structures/channels/TextVoice.ts b/packages/client/src/Structures/channels/TextVoice.ts index a79cbb434..c92171415 100644 --- a/packages/client/src/Structures/channels/TextVoice.ts +++ b/packages/client/src/Structures/channels/TextVoice.ts @@ -22,7 +22,7 @@ import VoiceChannel from './Voice.js' * @prop {Number} rateLimitPerUser The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled */ export class TextVoiceChannel extends VoiceChannel { - lastMessageID: string | null + lastMessageID = "" messages: Collection rateLimitPerUser: number | null @@ -33,7 +33,7 @@ export class TextVoiceChannel extends VoiceChannel { if (messageLimit == null) this.messages.limit = client.options.messageLimit else this.messages.limit = messageLimit - this.lastMessageID = data.last_message_id ?? null + this.lastMessageID = data.last_message_id ?? "" this.rateLimitPerUser = data.rate_limit_per_user == null ? null : data.rate_limit_per_user } diff --git a/packages/client/src/Structures/channels/threads/Member.ts b/packages/client/src/Structures/channels/threads/Member.ts index 99a0a5484..57a636b4d 100644 --- a/packages/client/src/Structures/channels/threads/Member.ts +++ b/packages/client/src/Structures/channels/threads/Member.ts @@ -1,5 +1,5 @@ /* eslint-disable no-useless-call */ -import type { BigString, DiscordThreadMember } from '@discordeno/types' +import type { DiscordThreadMember } from '@discordeno/types' import Base from '../../../Base.js' import type Client from '../../../Client.js' import type Member from '../../guilds/Member.js' @@ -9,7 +9,7 @@ export class ThreadMember extends Base { /** The user-thread settings of this member */ flags: number /** The ID of the thread this member is a part of */ - threadID: BigString + threadID: string /** Timestamp of when the member joined the thread */ joinTimestamp: number /** The guild member that this thread member belongs to. This will never be present when fetching over REST */ diff --git a/packages/client/src/Structures/channels/threads/Thread.ts b/packages/client/src/Structures/channels/threads/Thread.ts index 31394be0b..d2e32c20a 100644 --- a/packages/client/src/Structures/channels/threads/Thread.ts +++ b/packages/client/src/Structures/channels/threads/Thread.ts @@ -15,9 +15,9 @@ export class ThreadChannel extends GuildChannel { /** The cached thread members that are in this channel. */ members: Collection /** The id of the last message in this channel. */ - lastMessageID: BigString | null + lastMessageID: string /** The id of the user who created this thread. */ - ownerID: BigString + ownerID: string /** The approximate amount of members that have joined this thread. */ memberCount?: number /** The approximate amount of messages in this channel. */ @@ -48,7 +48,7 @@ export class ThreadChannel extends GuildChannel { this.messages = new Collection() this.messages.limit = messageLimit ?? client.options.messageLimit - this.lastMessageID = data.last_message_id ?? null + this.lastMessageID = data.last_message_id ?? "" this.ownerID = data.owner_id! this.update(data) diff --git a/packages/client/src/Structures/guilds/Guild.ts b/packages/client/src/Structures/guilds/Guild.ts index b79b3e11b..839d2de04 100644 --- a/packages/client/src/Structures/guilds/Guild.ts +++ b/packages/client/src/Structures/guilds/Guild.ts @@ -86,19 +86,19 @@ export class Guild extends Base { /** The client object */ client: Client /** The id of the guild owner. */ - ownerID: BigString + ownerID: string /** The id of the application. */ - applicationID?: BigString | null + applicationID?: string | null /** The id of the widget channel. */ - widgetChannelID?: BigString | null + widgetChannelID?: string | null /** The afk channel id if one is set. */ - afkChannelID?: BigString | null + afkChannelID?: string | null /** The system channel id if one is set. */ - systemChannelID?: BigString | null + systemChannelID?: string | null /** The public updates channel id if one is set. */ - publicUpdatesChannelID?: BigString | null + publicUpdatesChannelID?: string | null /** The rules channel id if one is set. */ - rulesChannelID?: BigString | null + rulesChannelID?: string | null /** The name of the guild. */ name?: string /** The description of the guild. */ @@ -700,7 +700,7 @@ export class Guild extends Base { } /** Get the ban list of the guild */ - async getBans(options: GetGuildBansOptions): Promise { + async getBans(options?: GetGuildBansOptions): Promise { return await this.client.getGuildBans.call(this.client, this.id, options) } diff --git a/packages/client/src/Structures/guilds/Member.ts b/packages/client/src/Structures/guilds/Member.ts index 5f5124bc6..8e2901b1a 100644 --- a/packages/client/src/Structures/guilds/Member.ts +++ b/packages/client/src/Structures/guilds/Member.ts @@ -8,7 +8,7 @@ import Base from '../../Base.js' import type Client from '../../Client.js' import type { ImageFormat, ImageSize } from '../../Client.js' import { GUILD_AVATAR } from '../../Endpoints.js' -import type { MemberOptions } from '../../typings.js' +import type { MemberOptions, Status } from '../../typings.js' import User from '../users/User.js' import type Guild from './Guild.js' @@ -16,7 +16,7 @@ export class Member extends Base { /** The client manager */ client: Client /** An array of role IDs this member is a part of */ - roles: BigString[] + roles: string[] /** The guild the member is in */ guild: Guild /** The user object of the member */ @@ -31,6 +31,8 @@ export class Member extends Base { pending?: boolean /** Timestamp of timeout expiry. If `null`, the member is not timed out */ communicationDisabledUntil?: number | null + /** The members current status */ + status?: Status; /** The compressed form of the members avatar. */ _avatar?: bigint diff --git a/packages/client/src/Structures/interactions/Autocomplete.ts b/packages/client/src/Structures/interactions/Autocomplete.ts index d27c28051..0618a097e 100644 --- a/packages/client/src/Structures/interactions/Autocomplete.ts +++ b/packages/client/src/Structures/interactions/Autocomplete.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/return-await */ /* eslint-disable no-useless-call */ /* eslint-disable @typescript-eslint/explicit-function-return-type */ -import type { BigString, DiscordInteraction, DiscordInteractionData } from '@discordeno/types' +import type { DiscordInteraction, DiscordInteractionData } from '@discordeno/types' import { InteractionResponseTypes } from '@discordeno/types' import type Client from '../../Client.js' import type { ApplicationCommandOptionChoice } from '../../typings.js' @@ -16,11 +16,11 @@ import Interaction from './Interaction.js' export class AutocompleteInteraction extends Interaction { /** The guild id if this interaction occurred in a guild. */ - guildID?: BigString + guildID?: string /** The permissions the app or bot has within the channel, the interaction was sent from. */ appPermissions?: Permission /** The channel id where this interaction was created in. */ - channelID: BigString + channelID: string /** The user who triggered the interaction. */ user: User /** The data attached to this interaction. */ diff --git a/packages/client/src/Structures/interactions/Command.ts b/packages/client/src/Structures/interactions/Command.ts index 25a45534c..bac8120c2 100644 --- a/packages/client/src/Structures/interactions/Command.ts +++ b/packages/client/src/Structures/interactions/Command.ts @@ -23,6 +23,7 @@ import type { import type Client from '../../Client.js' import type { AnyChannel, FileContent, InteractionContent, InteractionContentEdit } from '../../typings.js' export class CommandInteraction extends Interaction { + name: string = ""; channel: AnyChannel /** The type of component */ componentType?: MessageComponentTypes @@ -131,6 +132,7 @@ export class CommandInteraction extends Interaction { this.client.users.set(this.user.id, this.user) if (info.data) { + this.name = info.data.name; this.componentType = info.data.component_type this.customId = info.data.custom_id this.components = info.data.components @@ -143,6 +145,7 @@ export class CommandInteraction extends Interaction { get data() { return { + name: this.name, component_type: this.componentType, custom_id: this.customId, components: this.components, diff --git a/packages/client/src/Structures/interactions/Component.ts b/packages/client/src/Structures/interactions/Component.ts index f8987244c..ece0de745 100644 --- a/packages/client/src/Structures/interactions/Component.ts +++ b/packages/client/src/Structures/interactions/Component.ts @@ -15,9 +15,9 @@ import Interaction from './Interaction.js' export class ComponentInteraction extends Interaction { /** The channel id where this interaction occurred in. */ - channelID: BigString + channelID: string /** The guild id where this interaction occurred in. */ - guildID?: BigString + guildID?: string /** The member object if this interaction occurred in a guild. */ member?: Member /** The user object for the user that created this interaction. */ diff --git a/packages/client/src/Structures/interactions/Interaction.ts b/packages/client/src/Structures/interactions/Interaction.ts index 0a6d65d51..720e5583f 100644 --- a/packages/client/src/Structures/interactions/Interaction.ts +++ b/packages/client/src/Structures/interactions/Interaction.ts @@ -2,11 +2,10 @@ import type { DiscordInteraction, InteractionTypes } from '@discordeno/types' import Base from '../../Base.js' import type Client from '../../Client.js' -import type { BigString } from '../../Client.js' export class Interaction extends Base { client: Client - applicationID: BigString + applicationID: string token: string type: InteractionTypes version: 1 diff --git a/packages/client/src/index.ts b/packages/client/src/index.ts index fcc4bcaac..397f6395b 100644 --- a/packages/client/src/index.ts +++ b/packages/client/src/index.ts @@ -1,10 +1,105 @@ +import Base from './Base.js' +import type { ClientOptions } from './Client.js' import Client from './Client.js' -export default Client +import Collection from './Collection.js' +import * as Constants from './Constants.js' +import Shard from './gateway/Shard.js' +import RequestHandler from './RequestHandler.js' +import { CategoryChannel } from './Structures/channels/Category.js' +import Channel from './Structures/channels/Channel.js' +import Guild, { GuildChannel } from './Structures/channels/Guild.js' +import { NewsChannel } from './Structures/channels/News.js' +import { PrivateChannel } from './Structures/channels/Private.js' +import { StageChannel } from './Structures/channels/Stage.js' +import { TextChannel } from './Structures/channels/Text.js' +import { TextVoiceChannel } from './Structures/channels/TextVoice.js' +import Member, { ThreadMember } from './Structures/channels/threads/Member.js' +import { NewsThreadChannel } from './Structures/channels/threads/NewsThread.js' +import { PrivateThreadChannel } from './Structures/channels/threads/PrivateThread.js' +import { PublicThreadChannel } from './Structures/channels/threads/PublicThread.js' +import { ThreadChannel } from './Structures/channels/threads/Thread.js' +import { VoiceChannel } from './Structures/channels/Voice.js' +import { GuildIntegration } from './Structures/guilds/Integration.js' +import { GuildPreview } from './Structures/guilds/Preview.js' +import Role from './Structures/guilds/Role.js' +import StageInstance from './Structures/guilds/StageInstance.js' +import { GuildTemplate } from './Structures/guilds/Template.js' +import { UnavailableGuild } from './Structures/guilds/Unavailable.js' +import { VoiceState } from './Structures/guilds/VoiceState.js' +import { AutocompleteInteraction } from './Structures/interactions/Autocomplete.js' +import Command, { CommandInteraction } from './Structures/interactions/Command.js' +import { ComponentInteraction } from './Structures/interactions/Component.js' +import Interaction from './Structures/interactions/Interaction.js' +import { PingInteraction } from './Structures/interactions/Ping.js' +import { UnknownInteraction } from './Structures/interactions/Unknown.js' +import Invite from './Structures/Invite.js' +import Message from './Structures/Message.js' +import Permission from './Structures/Permission.js' +import PermissionOverwrite from './Structures/PermissionOverwrite.js' +import { ExtendedUser } from './Structures/users/Extended.js' +import User from './Structures/users/User.js' +import Bucket from './utils/Bucket.js' +import DiscordRESTError from './utils/DiscordRESTError.js' +// eslint-disable-next-line require-extensions/require-extensions +import { version as VERSION } from '../package.json' + +export function DiscordenoClient(token: string, options: ClientOptions): Client { + return new Client(token, options) +} + +DiscordenoClient.AutocompleteInteraction = AutocompleteInteraction +DiscordenoClient.Base = Base +DiscordenoClient.Bucket = Bucket +DiscordenoClient.CategoryChannel = CategoryChannel +DiscordenoClient.Channel = Channel +DiscordenoClient.CommandInteraction = CommandInteraction +DiscordenoClient.ComponentInteraction = ComponentInteraction +DiscordenoClient.Client = Client +DiscordenoClient.Collection = Collection +DiscordenoClient.Command = Command +// DiscordenoClient.CommandClient = CommandClient +DiscordenoClient.Constants = Constants +// DiscordenoClient.DiscordHTTPError = DiscordHTTPError +DiscordenoClient.DiscordRESTError = DiscordRESTError +DiscordenoClient.ExtendedUser = ExtendedUser +DiscordenoClient.Guild = Guild +DiscordenoClient.GuildChannel = GuildChannel +DiscordenoClient.GuildIntegration = GuildIntegration +DiscordenoClient.GuildPreview = GuildPreview +DiscordenoClient.GuildTemplate = GuildTemplate +DiscordenoClient.Interaction = Interaction +DiscordenoClient.Invite = Invite +DiscordenoClient.Member = Member +DiscordenoClient.Message = Message +DiscordenoClient.NewsChannel = NewsChannel +DiscordenoClient.NewsThreadChannel = NewsThreadChannel +DiscordenoClient.Permission = Permission +DiscordenoClient.PermissionOverwrite = PermissionOverwrite +DiscordenoClient.PingInteraction = PingInteraction +DiscordenoClient.PrivateChannel = PrivateChannel +DiscordenoClient.PrivateThreadChannel = PrivateThreadChannel +DiscordenoClient.PublicThreadChannel = PublicThreadChannel +DiscordenoClient.RequestHandler = RequestHandler +DiscordenoClient.Role = Role +DiscordenoClient.Shard = Shard +DiscordenoClient.StageChannel = StageChannel +DiscordenoClient.StageInstance = StageInstance +DiscordenoClient.TextChannel = TextChannel +DiscordenoClient.TextVoiceChannel = TextVoiceChannel +DiscordenoClient.ThreadChannel = ThreadChannel +DiscordenoClient.ThreadMember = ThreadMember +DiscordenoClient.UnavailableGuild = UnavailableGuild +DiscordenoClient.UnknownInteraction = UnknownInteraction +DiscordenoClient.User = User +DiscordenoClient.VERSION = VERSION +DiscordenoClient.VoiceChannel = VoiceChannel +DiscordenoClient.VoiceState = VoiceState export * from './Base.js' export * from './Client.js' export * from './Collection.js' export * from './Constants.js' +export * as Constants from './Constants.js' export * from './Endpoints.js' export * from './gateway/Shard.js' export * from './gateway/ShardManager.js' diff --git a/packages/client/src/typings.ts b/packages/client/src/typings.ts index 7f7079f8c..8c11ecbf4 100644 --- a/packages/client/src/typings.ts +++ b/packages/client/src/typings.ts @@ -3,7 +3,6 @@ import type { ApplicationCommandOptionTypes, ApplicationCommandPermissionTypes, ApplicationCommandTypes, - BigString, ButtonStyles, ChannelTypes, DefaultMessageNotificationLevels, @@ -200,7 +199,7 @@ export interface ApplicationCommandOption< type: T } export interface ApplicationCommandPermissions { - id: BigString + id: string permission: boolean type: ApplicationCommandPermissionTypes } @@ -977,3 +976,33 @@ export interface HTTPResponse { errors?: HTTPResponse headers: IncomingHttpHeaders } + +export type AnyInteraction = PingInteraction | CommandInteraction | ComponentInteraction | AutocompleteInteraction; +export type InteractionDataOptions = InteractionDataOptionsSubCommand | InteractionDataOptionsSubCommandGroup | InteractionDataOptionsWithValue; +export type InteractionDataOptionsBoolean = InteractionDataOptionWithValue; +export type InteractionDataOptionsChannel = InteractionDataOptionWithValue; +export type InteractionDataOptionsInteger = InteractionDataOptionWithValue; +export type InteractionDataOptionsMentionable = InteractionDataOptionWithValue; +export type InteractionDataOptionsNumber = InteractionDataOptionWithValue; +export type InteractionDataOptionsRole = InteractionDataOptionWithValue; +export type InteractionDataOptionsString = InteractionDataOptionWithValue; +export type InteractionDataOptionsUser = InteractionDataOptionWithValue; +export type InteractionDataOptionsWithValue = InteractionDataOptionsString | InteractionDataOptionsInteger | InteractionDataOptionsBoolean | InteractionDataOptionsUser | InteractionDataOptionsChannel | InteractionDataOptionsRole | InteractionDataOptionsMentionable | InteractionDataOptionsNumber; + +export interface InteractionDataOptionWithValue { + focused?: boolean; + name: string; + type: T; + value: V; +} + +export interface InteractionDataOptionsSubCommand { + name: string; + options?: InteractionDataOptions[]; + type: ApplicationCommandOptionTypes.SubCommand; +} +export interface InteractionDataOptionsSubCommandGroup { + name: string; + options: InteractionDataOptions[]; + type: ApplicationCommandOptionTypes.SubCommandGroup; +}