Skip to content

Commit

Permalink
Eris 0.15 typings (#56)
Browse files Browse the repository at this point in the history
* update types for upcoming eris 0.15 release

* update Eris peer dependency to require 0.15

* run CI against eris@0.15.x
  • Loading branch information
eritbh authored Apr 5, 2021
1 parent 806cd6a commit 7e70da6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
# Direct dependencies
yarn install
# Peer dependencies
npm i --no-save eris@0.13
npm i --no-save eris@0.15
- name: Build Typescript
run: |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
"typescript": "4"
},
"peerDependencies": {
"eris": "^0.13.0"
"eris": "^0.15.0"
}
}
10 changes: 5 additions & 5 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ export interface ClientOptions extends Eris.ClientOptions {

}

/** Information returned from the API about the bot's OAuth application. */
// TODO: obviated by https://github.com/abalabahaha/eris/pull/467
export interface ClientOAuthApplication extends Resolved<ReturnType<Client['getOAuthApplication']>> {
// nothing else added
}
/**
* Information returned from the API about the bot's OAuth application.
* @deprecated Use `Eris.OAuthApplicationInfo` instead (this is a direct alias)
*/
export type ClientOAuthApplication = Eris.OAuthApplicationInfo;

// A function that takes a message and a context argument and returns a prefix,
// an array of prefixes, or void.
Expand Down
2 changes: 1 addition & 1 deletion src/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export interface CommandRequirements {
* A list of permission strings the user must have. If set, the `guildOnly`
* option is implied.
*/
permissions?: string[];
permissions?: (keyof Eris.Constants["Permissions"])[];
/** A custom function that must return true to enable the command. */
custom?(msg: Eris.Message, args: string[], ctx: CommandContext): boolean | Promise<boolean>;
}
Expand Down
40 changes: 22 additions & 18 deletions src/EventListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,50 +48,54 @@ export class EventListener implements EventListenerOptions {
constructor(event: "channelCreate" | "channelDelete", listener: (channel: Eris.AnyChannel, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "channelPinUpdate", listener: (channel: Eris.TextableChannel, timestamp: number, oldTimestamp: number, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "channelRecipientAdd" | "channelRecipientRemove", listener: (channel: Eris.GroupChannel, user: Eris.User, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "channelUpdate", listener: (channel: Eris.AnyGuildChannel, oldChannel: Eris.OldGuildChannel, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "channelUpdate", listener: (channel: Eris.AnyChannel, oldChannel: Eris.OldGuildChannel | Eris.OldGroupChannel, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "connect" | "shardPreReady", listener: (id: number, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "friendSuggestionCreate", listener: (user: Eris.User, reasons: Eris.FriendSuggestionReasons, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "friendSuggestionDelete", listener: (user: Eris.User, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "guildAvailable" | "guildBanAdd" | "guildBanRemove", listener: (guild: Eris.Guild, user: Eris.User, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "guildDelete" | "guildUnavailable" | "guildCreate", listener: (guild: Eris.Guild, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "guildEmojisUpdate", listener: (guild: Eris.Guild, emojis: Eris.Emoji[], oldEmojis: Eris.Emoji[], context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "guildBanAdd" | "guildBanRemove", listener: (guild: Eris.Guild, user: Eris.User, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "guildAvailable" | "guildCreate", listener: (guild: Eris.Guild, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "guildDelete", listener: (guild: Eris.PossiblyUncachedGuild, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "guildEmojisUpdate", listener: (guild: Eris.PossiblyUncachedGuild, emojis: Eris.Emoji[], oldEmojis: Eris.Emoji[] | null, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "guildMemberAdd", listener: (guild: Eris.Guild, member: Eris.Member, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "guildMemberChunk", listener: (guild: Eris.Guild, members: Eris.Member[], context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "guildMemberRemove", listener: (guild: Eris.Guild, member: Eris.Member | Eris.MemberPartial, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "guildMemberUpdate", listener: (guild: Eris.Guild, member: Eris.Member, oldMember: { roles: string[]; nick?: string }, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "guildMemberUpdate", listener: (guild: Eris.Guild, member: Eris.Member, oldMember: { nick?: string; premiumSince: number; roles: string[]; pending?: boolean } | null, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "guildRoleCreate" | "guildRoleDelete", listener: (guild: Eris.Guild, role: Eris.Role, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "guildRoleUpdate", listener: (guild: Eris.Guild, role: Eris.Role, oldRole: Eris.OldRole, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "guildUnavailable" | "unavailableGuildCreate", listener: (guild: Eris.UnavailableGuild, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "guildUpdate", listener: (guild: Eris.Guild, oldGuild: Eris.OldGuild, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "hello", listener: (trace: string[], id: number, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "inviteCreate" | "inviteDelete", listener: (guild: Eris.Guild, invite: Eris.GuildInvite, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "messageCreate", listener: (message: Eris.Message, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "inviteCreate" | "inviteDelete", listener: (guild: Eris.Guild, invite: Eris.Invite, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "messageCreate", listener: (message: Eris.Message<Eris.PossiblyUncachedTextableChannel>, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "messageDelete" | "messageReactionRemoveAll", listener: (message: Eris.PossiblyUncachedMessage, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "messageReactionRemoveEmoji", listener: (message: Eris.PossiblyUncachedMessage, emoji: Eris.PartialEmoji, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "messageDeleteBulk", listener: (messages: Eris.PossiblyUncachedMessage[], context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "messageReactionAdd" | "messageReactionRemove", listener: (message: Eris.PossiblyUncachedMessage, emoji: Eris.Emoji, userID: string, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "messageUpdate", listener: (message: Eris.Message, oldMessage: Eris.OldMessage | undefined, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "presenceUpdate", listener: (other: Eris.Member | Eris.Relationship, oldPresence: Eris.Presence | undefined, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "messageReactionAdd", listener: (message: Eris.PossiblyUncachedMessage, emoji: Eris.Emoji, reactor: Eris.Member | { id: string }, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "messageReactionRemove", listener: (message: Eris.PossiblyUncachedMessage, emoji: Eris.PartialEmoji, userID: string, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "messageUpdate", listener: (message: Eris.Message<Eris.PossiblyUncachedTextableChannel>, oldMessage: Eris.OldMessage | null, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "presenceUpdate", listener: (other: Eris.Member | Eris.Relationship, oldPresence: Eris.Presence | null, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "rawREST", listener: (request: Eris.RawRESTRequest, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "rawWS" | "unknown", listener: (packet: Eris.RawPacket, id: number, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "relationshipAdd" | "relationshipRemove", listener: (relationship: Eris.Relationship, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "relationshipUpdate", listener: (relationship: Eris.Relationship, oldRelationship: { type: number }, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "typingStart", listener: (channel: Eris.TextableChannel, user: Eris.User, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "unavailableGuildCreate", listener: (guild: Eris.UnavailableGuild, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "userUpdate", listener: (user: Eris.User, oldUser: { username: string; discriminator: string; avatar?: string }, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "voiceChannelJoin", listener: (member: Eris.Member, newChannel: Eris.VoiceChannel, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "voiceChannelLeave", listener: (member: Eris.Member, oldChannel: Eris.VoiceChannel, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "voiceChannelSwitch", listener: (member: Eris.Member, newChannel: Eris.VoiceChannel, oldChannel: Eris.VoiceChannel, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "typingStart", listener: (channel: Eris.TextableChannel | { id: string }, user: Eris.User | { id: string }, member: Eris.Member | null, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "userUpdate", listener: (user: Eris.User, oldUser: Eris.PartialUser | null, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "voiceChannelJoin", listener: (member: Eris.Member, newChannel: Eris.AnyVoiceChannel, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "voiceChannelLeave", listener: (member: Eris.Member, oldChannel: Eris.AnyVoiceChannel, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "voiceChannelSwitch", listener: (member: Eris.Member, newChannel: Eris.AnyVoiceChannel, oldChannel: Eris.AnyVoiceChannel, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "voiceStateUpdate", listener: (member: Eris.Member, oldState: Eris.OldVoiceState, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "warn" | "debug", listener: (message: string, id: number, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "shardDisconnect" | "error" | "shardPreReady" | "connect",listener: (err: Error, id: number, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "webhooksUpdate", listener: (data: Eris.WebhookData, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "shardReady" | "shardResume", listener: (id: number, context: EventContext) => void, options?: EventListenerOptions);
constructor(event: "shardDisconnect" | "error", listener: (err: Error, id: number, context: EventContext) => void, options?: EventListenerOptions);

// Yuuko client events ripped from Client.ts
constructor (event: 'commandLoaded', listener: (cmd: Command, context: EventContext) => void, options?: EventListenerOptions);
constructor (event: 'preCommand', listener: (cmd: Command, msg: Eris.Message, args: string[], ctx: CommandContext, context: EventContext) => void, options?: EventListenerOptions);
constructor (event: 'postCommand', listener: (cmd: Command, msg: Eris.Message, args: string[], ctx: CommandContext, context: EventContext) => void, options?: EventListenerOptions);
constructor (event: 'invalidCommand', listener: (msg: Eris.Message, args: string[], ctx: CommandContext, context: EventContext) => void, options?: EventListenerOptions);

constructor(event: string, listener: Function, {
constructor(event: string, listener: (...args: any) => void, {
once = false
}: EventListenerOptions = {}) {
this.args = [event, listener];
Expand Down

0 comments on commit 7e70da6

Please sign in to comment.