Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream Update (jumplink) #28

Open
wants to merge 8 commits into
base: jumplink
Choose a base branch
from
27 changes: 15 additions & 12 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ declare namespace Eris {
type ActivityType = BotActivityType | Constants["ActivityTypes"]["CUSTOM"];
type BotActivityType = Constants["ActivityTypes"][Exclude<keyof Constants["ActivityTypes"], "CUSTOM">];
type FriendSuggestionReasons = { name: string; platform_type: string; type: number }[];
type Status = "online" | "idle" | "dnd" | "offline";
type Status = "online" | "idle" | "dnd";
type SelfStatus = Status | "invisible";
type UserStatus = Status | "offline";

// Selfbot
type ConnectionVisibilityTypes = Constants["ConnectionVisibilityTypes"][keyof Constants["ConnectionVisibilityTypes"]];
Expand Down Expand Up @@ -526,6 +528,7 @@ declare namespace Eris {
}
interface EmbedVideo {
height?: number;
proxy_url?: string;
url?: string;
width?: number;
}
Expand Down Expand Up @@ -683,7 +686,7 @@ declare namespace Eris {
callDelete: [call: Call];
callRing: [call: Call];
callUpdate: [call: Call, oldCall: OldCall];
channelCreate: [channel: AnyChannel];
channelCreate: [channel: AnyGuildChannel];
channelDelete: [channel: AnyChannel];
channelPinUpdate: [channel: TextableChannel, timestamp: number, oldTimestamp: number];
channelRecipientAdd: [channel: GroupChannel, user: User];
Expand Down Expand Up @@ -1250,17 +1253,17 @@ declare namespace Eris {
activities: Activity[] | null;
afk: boolean;
since: number | null;
status: Status;
status: SelfStatus;
}
interface ClientStatus {
desktop: Status;
mobile: Status;
web: Status;
desktop: UserStatus;
mobile: UserStatus;
web: UserStatus;
}
interface Presence {
activities?: Activity[];
clientStatus?: ClientStatus;
status?: Status;
status?: UserStatus;
}

// Role
Expand Down Expand Up @@ -1808,10 +1811,10 @@ declare namespace Eris {
sendMessagesInThreads: 274877906944n;
startEmbeddedActivities: 549755813888n;
moderateMembers: 1099511627776n;
allGuild: 1101592527038n;
allText: 518349388881n;
allGuild: 1110182461630n;
allText: 535529258065n;
allVoice: 554385278737n;
all: 1228360646655n;
all: 2199023255551n;
};
PremiumTiers: {
NONE: 0;
Expand Down Expand Up @@ -2312,7 +2315,7 @@ declare namespace Eris {
): Promise<Connection>;
editSelfSettings(data: UserSettings): Promise<UserSettings>;
editStageInstance(channelID: string, options: StageInstanceOptions): Promise<StageInstance>;
editStatus(status: Status, activities?: ActivityPartial<BotActivityType>[] | ActivityPartial<BotActivityType>): void;
editStatus(status: SelfStatus, activities?: ActivityPartial<BotActivityType>[] | ActivityPartial<BotActivityType>): void;
editStatus(activities?: ActivityPartial<BotActivityType>[] | ActivityPartial<BotActivityType>): void;
editUserNote(userID: string, note: string): Promise<void>;
editWebhook(
Expand Down Expand Up @@ -3310,7 +3313,7 @@ declare namespace Eris {
createGuild(_guild: Guild): Guild;
disconnect(options?: { reconnect?: boolean | "auto" }, error?: Error): void;
editAFK(afk: boolean): void;
editStatus(status: Status, activities?: ActivityPartial<BotActivityType>[] | ActivityPartial<BotActivityType>): void;
editStatus(status: SelfStatus, activities?: ActivityPartial<BotActivityType>[] | ActivityPartial<BotActivityType>): void;
editStatus(activities?: ActivityPartial<BotActivityType>[] | ActivityPartial<BotActivityType>): void;
// @ts-ignore: Method override
emit(event: string, ...args: any[]): void;
Expand Down
6 changes: 3 additions & 3 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ class Client extends EventEmitter {
return Promise.resolve();
}
if(messageIDs.length === 1) {
return this.deleteMessage(channelID, messageIDs[0]);
return this.deleteMessage(channelID, messageIDs[0], reason);
}

const oldestAllowedSnowflake = (Date.now() - 1421280000000) * 4194304;
Expand All @@ -1106,7 +1106,7 @@ class Client extends EventEmitter {
return this.requestHandler.request("POST", Endpoints.CHANNEL_BULK_DELETE(channelID), true, {
messages: messageIDs.splice(0, 100),
reason: reason
}).then(() => this.deleteMessages(channelID, messageIDs));
}).then(() => this.deleteMessages(channelID, messageIDs, reason));
}
return this.requestHandler.request("POST", Endpoints.CHANNEL_BULK_DELETE(channelID), true, {
messages: messageIDs,
Expand Down Expand Up @@ -1571,7 +1571,7 @@ class Client extends EventEmitter {
});
}
/**
* Update a user's voice state - See [caveats](https://discord.com/developers/docs/resources/guild#update-others-voice-state-caveats)
* Update a user's voice state - See [caveats](https://discord.com/developers/docs/resources/guild#modify-user-voice-state-caveats)
* @arg {String} guildID The ID of the guild
* @arg {Object} options The properties to edit
* @arg {String} options.channelID The ID of the channel the user is currently in
Expand Down
2 changes: 2 additions & 0 deletions lib/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ Permissions.allGuild = Permissions.kickMembers
| Permissions.manageRoles
| Permissions.manageWebhooks
| Permissions.manageEmojisAndStickers
| Permissions.manageEvents
| Permissions.moderateMembers;
Permissions.allText = Permissions.createInstantInvite
| Permissions.manageChannels
Expand All @@ -412,6 +413,7 @@ Permissions.allText = Permissions.createInstantInvite
| Permissions.manageRoles
| Permissions.manageWebhooks
| Permissions.useApplicationCommands
| Permissions.manageThreads
| Permissions.createPublicThreads
| Permissions.createPrivateThreads
| Permissions.useExternalStickers
Expand Down
21 changes: 13 additions & 8 deletions lib/gateway/Shard.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class Shard extends EventEmitter {
}

if(this.ws.readyState !== WebSocket.CLOSED) {
this.ws.removeListener("message", this._onWSMessage);
this.ws.removeListener("close", this._onWSClose);
try {
if(options.reconnect && this.sessionID) {
Expand Down Expand Up @@ -620,7 +621,7 @@ class Shard extends EventEmitter {
* Fired when a user's avatar, discriminator or username changes
* @event Client#userUpdate
* @prop {User} user The updated user
* @prop {Object?} oldUser The old user data
* @prop {Object?} oldUser The old user data. If the user was uncached, this will be null
* @prop {String} oldUser.username The username of the user
* @prop {String} oldUser.discriminator The discriminator of the user
* @prop {String?} oldUser.avatar The hash of the user's avatar, or null if no avatar
Expand Down Expand Up @@ -1958,13 +1959,17 @@ class Shard extends EventEmitter {
break;
}
case "USER_UPDATE": {
const user = this.client.users.get(packet.d.id);
const oldUser = {
username: user.username,
discriminator: user.discriminator,
avatar: user.avatar
};
this.emit("userUpdate", user.update(packet.d), oldUser);
let user = this.client.users.get(packet.d.id);
let oldUser = null;
if(user) {
oldUser = {
username: user.username,
discriminator: user.discriminator,
avatar: user.avatar
};
}
user = this.client.users.update(packet.d, this.client);
this.emit("userUpdate", user, oldUser);
break;
}
case "RELATIONSHIP_ADD": {
Expand Down
2 changes: 1 addition & 1 deletion lib/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ class Guild extends Base {
}

/**
* Update a user's voice state - See [caveats](https://discord.com/developers/docs/resources/guild#update-others-voice-state-caveats)
* Update a user's voice state - See [caveats](https://discord.com/developers/docs/resources/guild#modify-user-voice-state-caveats)
* @arg {Object} options The properties to edit
* @arg {String} options.channelID The ID of the channel the user is currently in
* @arg {Date?} [options.requestToSpeakTimestamp] Sets the user's request to speak - this can only be used when the `userID` param is "@me"
Expand Down