fix: bunch of eris match errors

This commit is contained in:
Skillz
2023-03-01 18:28:46 -06:00
parent 9aaba0049c
commit c32e90edc2
17 changed files with 180 additions and 48 deletions

View File

@@ -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. */

View File

@@ -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 = {

View File

@@ -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) {

View File

@@ -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<BigString, PermissionOverwrite>()

View File

@@ -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)

View File

@@ -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)

View File

@@ -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<string, Message>
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
}

View File

@@ -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 */

View File

@@ -15,9 +15,9 @@ export class ThreadChannel extends GuildChannel {
/** The cached thread members that are in this channel. */
members: Collection<BigString, ThreadMember>
/** 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)

View File

@@ -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<GuildBan[]> {
async getBans(options?: GetGuildBansOptions): Promise<GuildBan[]> {
return await this.client.getGuildBans.call(this.client, this.id, options)
}

View File

@@ -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

View File

@@ -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. */

View File

@@ -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,

View File

@@ -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. */

View File

@@ -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

View File

@@ -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'

View File

@@ -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<ApplicationCommandOptionTypes.Boolean, boolean>;
export type InteractionDataOptionsChannel = InteractionDataOptionWithValue<ApplicationCommandOptionTypes.Channel, string>;
export type InteractionDataOptionsInteger = InteractionDataOptionWithValue<ApplicationCommandOptionTypes.Integer, number>;
export type InteractionDataOptionsMentionable = InteractionDataOptionWithValue<ApplicationCommandOptionTypes.Mentionable, string>;
export type InteractionDataOptionsNumber = InteractionDataOptionWithValue<ApplicationCommandOptionTypes.Number, number>;
export type InteractionDataOptionsRole = InteractionDataOptionWithValue<ApplicationCommandOptionTypes.Role, string>;
export type InteractionDataOptionsString = InteractionDataOptionWithValue<ApplicationCommandOptionTypes.String, string>;
export type InteractionDataOptionsUser = InteractionDataOptionWithValue<ApplicationCommandOptionTypes.User, string>;
export type InteractionDataOptionsWithValue = InteractionDataOptionsString | InteractionDataOptionsInteger | InteractionDataOptionsBoolean | InteractionDataOptionsUser | InteractionDataOptionsChannel | InteractionDataOptionsRole | InteractionDataOptionsMentionable | InteractionDataOptionsNumber;
export interface InteractionDataOptionWithValue<T extends ApplicationCommandOptionTypes, V = unknown> {
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;
}