Socket
Socket
Sign inDemoInstall

eris

Package Overview
Dependencies
4
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.9.0 to 0.10.0

lib/structures/NewsChannel.js

109

index.d.ts

@@ -5,3 +5,6 @@ declare module "eris" {

import { Readable as ReadableStream } from "stream";
import { Agent as HTTPAgent } from "http";
import { Agent as HTTPSAgent } from "https";
export const VERSION: string;
interface JSONCache { [s: string]: any; }

@@ -27,2 +30,3 @@

temporary?: boolean;
unique?: boolean;
}

@@ -94,2 +98,17 @@

interface OAuthApplicationInfo {
description: string,
name: string,
owner: {
username: string,
discriminator: string,
id: string,
avatar?: string,
},
bot_public: boolean,
bot_require_code_grant: boolean,
id: string,
icon?: string,
}
// To anyone snooping around this snippet of code and wondering

@@ -356,2 +375,7 @@ // "Why didn't they use a class for this? It would make the code cleaner!"

roles: string[],
id: string,
require_colons: boolean,
animated: boolean,
managed: boolean,
user: { name: string, discriminator: string, id: string, avatar: string }
} & EmojiBase;

@@ -365,2 +389,3 @@ interface IntegrationOptions { expireBehavior: string; expireGracePeriod: string; enableEmoticons: string; }

defaultNotifications?: number;
explicitContentFilter?: number;
afkChannelID?: string;

@@ -370,2 +395,3 @@ afkTimeout?: number;

splash?: string;
banner?: string;
}

@@ -390,3 +416,3 @@ interface MemberOptions { roles?: string[]; nick?: string; mute?: boolean; deaf?: boolean; channelID?: string; }

attachmentFilename?: string;
channelIDs: string[];
channelIDs?: string[];
}

@@ -426,2 +452,3 @@ interface SearchResults { totalResults: number; results: Array<Array<Message & { hit?: boolean }>>; }

latencyThreshold?: number;
agent?: HTTPAgent | HTTPSAgent
}

@@ -480,3 +507,4 @@ interface CommandClientOptions {

}
type CommandGeneratorFunction = (msg: Message, args: string[]) => Promise<MessageContent> | Promise<void> | MessageContent | void;
type CommandGeneratorFunction = (msg: Message, args: string[]) => Promise<MessageContent>
| Promise<void> | MessageContent | void;
type CommandGenerator = CommandGeneratorFunction | MessageContent | MessageContent[] | CommandGeneratorFunction[];

@@ -541,2 +569,3 @@

userLimit?: number,
rateLimitPerUser?: number,
nsfw?: boolean,

@@ -657,2 +686,3 @@ parentID?: string,

public getGuildInvites(guildID: string): Promise<Invite[]>;
public getGuildVanity(guildID: string): Promise<{code: Invite}>;
public banGuildMember(guildID: string, userID: string, deleteMessageDays?: number, reason?: string): Promise<void>;

@@ -663,2 +693,3 @@ public unbanGuildMember(guildID: string, userID: string, reason?: string): Promise<void>;

public getGuildBans(guildID: string): Promise<Array<{ reason?: string, user: User }>>;
public getGuildBan(guildID: string, userID: string): Promise<{ reason?: string, user: User }>;
public editGuildMember(guildID: string, memberID: string, options: MemberOptions, reason?: string): Promise<void>;

@@ -671,16 +702,3 @@ public addGuildMemberRole(guildID: string, memberID: string, roleID: string, reason?: string): Promise<void>;

public leaveGuild(guildID: string): Promise<void>;
public getOAuthApplication(appID?: string): Promise<{
description: string,
name: string,
owner: {
username: string,
discriminator: string,
id: string,
avatar?: string,
},
bot_public: boolean,
bot_require_code_grant: boolean,
id: string,
icon?: string,
}>;
public getOAuthApplication(appID?: string): Promise<OAuthApplicationInfo>;
public addRelationship(userID: string, block?: boolean): Promise<void>;

@@ -895,2 +913,3 @@ public removeRelationship(userID: string): Promise<void>;

public on(event: "speakingStart", listener: (userID: string) => void): this;
public on(event: "speakingStop", listener: (userID: string) => void): this;
public on(event: "end", listener: () => void): this;

@@ -919,5 +938,6 @@ public toJSON(simple?: boolean): JSONCache;

class VoiceDataStream {
export class VoiceDataStream extends EventEmitter {
public type: string;
public constructor(type: string);
public on(event: "data", listener: (data: Buffer, userID: string, timestamp: number, sequence: number) => void): this;
}

@@ -962,2 +982,5 @@

public map<R>(func: (i: T) => R): R[];
public reduce<U>(func: (accumulator: U, val: T) => U, initial?: U): U;
public every(func: (i: T) => boolean): boolean;
public some(func: (i: T) => boolean): boolean;
public update(obj: T, extra?: any, replace?: boolean): T;

@@ -1021,2 +1044,3 @@ public remove(obj: T | { id: string }): T;

public splash?: string;
public banner?: string;
public unavailable: boolean;

@@ -1041,3 +1065,3 @@ public large: boolean;

reason?: string,
): Promise<EmojiOptions>;
): Promise<Emoji>;
public editEmoji(

@@ -1047,3 +1071,3 @@ emojiID: string,

reason?: string,
): Promise<EmojiOptions>;
): Promise<Emoji>;
public deleteEmoji(emojiID: string, reason?: string): Promise<void>;

@@ -1070,2 +1094,3 @@ public createRole(options: RoleOptions, reason?: string): Promise<Role>;

public getInvites(): Promise<Invite[]>;
public getVanity(): Promise<{code: Invite}>;
public editMember(memberID: string, options: MemberOptions, reason?: string): Promise<void>;

@@ -1083,2 +1108,3 @@ public addMemberRole(memberID: string, roleID: string, reason?: string): Promise<void>;

public getBans(): Promise<User[]>;
public getBan(): Promise<{ reason?: string, user: User }>;
public editNickname(nick: string): Promise<void>;

@@ -1124,2 +1150,3 @@ public getWebhooks(): Promise<Webhook[]>;

userLimit?: number,
rateLimitPerUser?: number,
nsfw?: boolean,

@@ -1148,2 +1175,3 @@ },

public lastMessageID: string;
public rateLimitPerUser: number;
public messages: Collection<Message>;

@@ -1176,2 +1204,5 @@ public constructor(data: BaseData, guild: Guild, messageLimit: number);

public removeMessageReactions(messageID: string): Promise<void>;
public purge(
limit: number, filter?: (message: Message) => boolean, before?: string, after?: string
): Promise<number>;
public deleteMessage(messageID: string, reason?: string): Promise<void>;

@@ -1429,2 +1460,3 @@ public unsendMessage(messageID: string): Promise<void>;

public latency: number;
public client: Client;
public constructor(id: number, client: Client);

@@ -1551,5 +1583,42 @@ public connect(): void;

// TODO: Do we need all properties of Command, as it has a lot of stuff
export class Command {
public subcommands: { [s: string]: Command };
public subcommandAliases: { [alias: string]: Command };
public label: string;
public parentCommand?: Command;
public description: string;
public fullDescription: string;
public usage: string;
public aliases: string[];
public caseInsensitive: boolean;
public hooks: Hooks;
public requirements: {
userIDs?: string[] | GenericCheckFunction<string[]>,
roleIDs?: string[] | GenericCheckFunction<string[]>,
roleNames?: string[] | GenericCheckFunction<string[]>,
permissions?: { [s: string]: boolean } | GenericCheckFunction<{ [s: string]: boolean }>,
custom?: GenericCheckFunction<void>,
};
public deleteCommand: boolean;
public argsRequired: boolean;
public guildOnly: boolean;
public dmOnly: boolean;
public cooldown: number;
public cooldownExclusions: {
userIDs?: string[],
guildIDs?: string[],
channelIDs?: string[],
};
public restartCooldown: boolean;
public cooldownReturns: number;
public cooldownMessage: string | boolean | GenericCheckFunction<string>;
public invalidUsageMessage: string | boolean | GenericCheckFunction<string>;
public permissionMessage: string | boolean | GenericCheckFunction<string>;
public errorMessage: string | GenericCheckFunction<string>;
public reactionButtons: null | Array<{
emoji: string, type: string, response: CommandGenerator, execute?: () => string, responses?: Array<() => string>,
}>;
public reactionButtonTimeout: number;
public defaultSubcommandOptions: CommandOptions;
public hidden: boolean;
public constructor(label: string, generate: CommandGenerator, options?: CommandOptions);

@@ -1556,0 +1625,0 @@ public registerSubcommandAlias(alias: string, label: string): void;

@@ -27,2 +27,3 @@ "use strict";

Eris.Message = require("./lib/structures/Message");
Eris.NewsChannel = require("./lib/structures/NewsChannel");
Eris.Permission = require("./lib/structures/Permission");

@@ -29,0 +30,0 @@ Eris.PermissionOverwrite = require("./lib/structures/PermissionOverwrite");

32

lib/command/Command.js

@@ -41,6 +41,7 @@ "use strict";

* @arg {Function | String} [options.permissionMessage] A string or a function that returns a string to show when the user doesn't have permissions to use the command. The function is passed the Message object as a parameter.
* @arg {Array<{emoji: String, type: String, response: Function | String | Array<Function | String>}>} [options.reactionButtons] An array of objects specifying reaction buttons
* @arg {Array<{emoji: String, type: String, response: (Function | String | Array<Function | String>)}>} [options.reactionButtons] An array of objects specifying reaction buttons
* `emoji` specifies the button emoji. Custom emojis should be in format `emojiName:emojiID`
* `type` specifies the type of the reaction button, either "edit" or "cancel"
* `response` specifies the content to edit the message to when the reaction button is pressed. This accepts the same arguments as the `generator` parameter of this function, but with an extra userID parameter for generator functions (`function(msg, args, userID)`) describing the user that made the reaction
* `filter` specifies a function (`function(msg, emoji, userID)`) that filters message reactions. If the function returns false, the reaction is not treated as a valid reaction button response
* @arg {Number} [options.reactionButtonTimeout=60000] Time (in milliseconds) to wait before invalidating the command's reaction buttons

@@ -86,5 +87,11 @@ * @arg {Object} [options.requirements] A set of factors that limit who can call the command

this.cooldownExclusions = options.cooldownExclusions || {};
if(!this.cooldownExclusions.userIDs) this.cooldownExclusions.userIDs = [];
if(!this.cooldownExclusions.guildIDs) this.cooldownExclusions.guildIDs = [];
if(!this.cooldownExclusions.channelIDs) this.cooldownExclusions.channelIDs = [];
if(!this.cooldownExclusions.userIDs) {
this.cooldownExclusions.userIDs = [];
}
if(!this.cooldownExclusions.guildIDs) {
this.cooldownExclusions.guildIDs = [];
}
if(!this.cooldownExclusions.channelIDs) {
this.cooldownExclusions.channelIDs = [];
}
this.restartCooldown = !!options.restartCooldown;

@@ -118,3 +125,3 @@ this.cooldownReturns = options.cooldownReturns || 0;

} else {
throw new Error("Invalid reaction button response generator (index " + index + ")");
throw new Error(`Invalid reaction button response generator (index ${index})`);
}

@@ -142,3 +149,3 @@ }) : null;

} else {
throw new Error("Invalid command response generator (index " + index + ")");
throw new Error(`Invalid command response generator (index ${index})`);
}

@@ -160,7 +167,3 @@ });

get fullLabel() {
if(this.parentCommand) {
return this.parentCommand.fullLabel + " " + this.label;
} else {
return this.label;
}
return `${this.parentCommand ? this.parentCommand.fullLabel + " " : ""}${this.label}`;
}

@@ -172,3 +175,3 @@

req = true;
if(this.requirements.custom(msg)){
if(this.requirements.custom(msg)) {
return true;

@@ -240,3 +243,3 @@ }

cooldownExclusionCheck(msg) {
return this.cooldownExclusions.channelIDs.includes(msg.channel.id) || this.cooldownExclusions.userIDs.includes(msg.author.id) && msg.channel.guild && this.cooldownExclusions.guildIDs.includes(msg.channel.guild.id);
return this.cooldownExclusions.channelIDs.includes(msg.channel.id) || this.cooldownExclusions.userIDs.includes(msg.author.id) || (msg.channel.guild && this.cooldownExclusions.guildIDs.includes(msg.channel.guild.id));
}

@@ -440,6 +443,7 @@

* @arg {Function | String} [options.permissionMessage] A string or a function that returns a string to show when the user doesn't have permissions to use the command
* @arg {Array<{emoji: String, type: String, response: Function | String | Array<Function | String>}>} [options.reactionButtons] An array of objects specifying reaction buttons
* @arg {Array<{emoji: String, type: String, response: (Function | String | Array<Function | String>)}>} [options.reactionButtons] An array of objects specifying reaction buttons
* `emoji` specifies the button emoji. Custom emojis should be in format `emojiName:emojiID`
* `type` specifies the type of the reaction button, either "edit" or "cancel"
* `response` specifies the content to edit the message to when the reaction button is pressed. This accepts the same arguments as the `generator` parameter of this function, but with an extra userID parameter for generator functions (`function(msg, args, userID)`) describing the user that made the reaction
* `filter` specifies a function (`function(msg, emoji, userID)`) that filters message reactions. If the function returns false, the reaction is not treated as a valid reaction button response
* @arg {Number} [options.reactionButtonTimeout=60000] Time (in milliseconds) to wait before invalidating the command's reaction buttons

@@ -446,0 +450,0 @@ * @arg {Object} [options.requirements] A set of factors that limit who can call the command

@@ -26,3 +26,3 @@ "use strict";

* @arg {String} [commandOptions.owner="an unknown user"] The owner to show in the default help command
* @arg {String|Array} [commandOptions.prefix="@mention "] The bot prefix. Can be either an array of prefixes or a single prefix. "@mention" will be automatically replaced with the bot's actual mention
* @arg {String | Array<String>} [commandOptions.prefix="@mention "] The bot prefix. Can be either an array of prefixes or a single prefix. "@mention" will be automatically replaced with the bot's actual mention
* @arg {Object} [commandOptions.defaultCommandOptions={}] Default command options. This object takes the same options as a normal Command

@@ -32,3 +32,3 @@ */

super(token, options);
this.commandOptions = {
this.commandOptions = Object.assign({
defaultHelpCommand: true,

@@ -41,9 +41,4 @@ description: "An Eris-based Discord bot",

prefix: "@mention ",
defaultCommandOptions: {}
};
if(typeof commandOptions === "object") {
for(const property of Object.keys(commandOptions)) {
this.commandOptions[property] = commandOptions[property];
}
}
defaultCommandOptions: {},
}, commandOptions);
this.guildPrefixes = {};

@@ -59,4 +54,4 @@ this.commands = {};

}
if(Array.isArray(this.commandOptions.prefix)){
for(const i in this.commandOptions.prefix){
if(Array.isArray(this.commandOptions.prefix)) {
for(let i = 0; i < this.commandOptions.prefix.length; ++i) {
this.commandOptions.prefix[i] = this.commandOptions.prefix[i].replace(/@mention/g, this.user.mention);

@@ -67,8 +62,5 @@ }

}
for(const key in this.guildPrefixes) {
if(!this.guildPrefixes.hasOwnProperty(key)) {
continue;
}
if(Array.isArray(this.guildPrefixes[key])){
for(const i in this.guildPrefixes[key]){
for(const key of Object.keys(this.guildPrefixes)) {
if(Array.isArray(this.guildPrefixes[key])) {
for(let i = 0; i < this.guildPrefixes[key].length; ++i) {
this.guildPrefixes[key][i] = this.guildPrefixes[key][i].replace(/@mention/g, this.user.mention);

@@ -101,11 +93,12 @@ }

}
label += " " + cur.label;
label += ` ${cur.label}`;
}
result += `**${msg.prefix}${label}** ${cur.usage}\n${cur.fullDescription}`;
if(Object.keys(cur.aliases).length > 0) {
if(cur.aliases.length > 0) {
result += `\n\n**Aliases:** ${cur.aliases.join(", ")}`;
}
if(Object.keys(cur.subcommands).length > 0) {
const subcommands = Object.keys(cur.subcommands);
if(subcommands.length > 0) {
result += "\n\n**Subcommands:**";
for(const subLabel in cur.subcommands) {
for(const subLabel of subcommands) {
if(cur.subcommands.hasOwnProperty(subLabel) && cur.subcommands[subLabel].permissionCheck(msg)) {

@@ -121,4 +114,3 @@ result += `\n **${subLabel}** - ${cur.subcommands[subLabel].description}`;

}
result += "\n";
result += "**Commands:**\n";
result += "\n**Commands:**\n";
for(const label in this.commands) {

@@ -159,3 +151,3 @@ if(this.commands.hasOwnProperty(label) && this.commands[label] && this.commands[label].permissionCheck(msg) && !this.commands[label].hidden) {

if((!this.commandOptions.ignoreSelf || msg.author.id !== this.user.id) && (!this.commandOptions.ignoreBots || !msg.author.bot) && (msg.prefix = this.checkPrefix(msg))) {
const args = msg.content.replace(/<@!/g, "<@").substring(msg.prefix.length).split(" ");
const args = msg.content.replace(/<@!/g, "<@").substring(msg.prefix.length).trim().split(/\s+/g);
const label = args.shift();

@@ -237,2 +229,6 @@ const command = this.resolveCommand(label);

if(action.filter && !action.filter(msg, emoji, userID)) {
return;
}
switch(action.type) {

@@ -266,16 +262,14 @@ case "cancel": {

* @arg {String} guildID The ID of the guild to override prefixes for
* @arg {String|Array} prefix The bot prefix. Can be either an array of prefixes or a single prefix. "@mention" will be automatically replaced with the bot's actual mention
* @arg {String | Array} prefix The bot prefix. Can be either an array of prefixes or a single prefix. "@mention" will be automatically replaced with the bot's actual mention
*/
registerGuildPrefix(guildID, prefix) {
if(!this.preReady){
if(!this.preReady) {
this.guildPrefixes[guildID] = prefix;
} else if(Array.isArray(prefix)) {
for(let i = 0; i < prefix.length; ++i) {
prefix[i] = prefix[i].replace(/@mention/g, this.user.mention);
}
this.guildPrefixes[guildID] = prefix;
} else {
if(Array.isArray(prefix)){
for(const i in prefix){
prefix[i] = prefix[i].replace(/@mention/g, this.user.mention);
}
this.guildPrefixes[guildID] = prefix;
} else {
this.guildPrefixes[guildID] = prefix.replace(/@mention/g, this.user.mention);
}
this.guildPrefixes[guildID] = prefix.replace(/@mention/g, this.user.mention);
}

@@ -286,3 +280,3 @@ }

let prefixes = this.commandOptions.prefix;
if(msg.channel.guild !== undefined && this.guildPrefixes[msg.channel.guild.id] !== undefined){
if(msg.channel.guild !== undefined && this.guildPrefixes[msg.channel.guild.id] !== undefined) {
prefixes = this.guildPrefixes[msg.channel.guild.id];

@@ -295,3 +289,3 @@ }

}
throw new Error("Unsupported prefix format | " + prefixes);
throw new Error(`Unsupported prefix format | ${prefixes}`);
}

@@ -307,3 +301,3 @@

if(!this.commands[label] && !(this.commands[(label = label.toLowerCase())] && (caseInsensitiveLabel = this.commands[label.toLowerCase()].caseInsensitive))) {
throw new Error("No command registered for " + label);
throw new Error(`No command registered for ${label}`);
}

@@ -350,6 +344,7 @@ alias = caseInsensitiveLabel === true ? alias.toLowerCase() : alias;

* @arg {Function | String} [options.permissionMessage] A string or a function that returns a string to show when the user doesn't have permissions to use the command
* @arg {Array<{emoji: String, type: String, response: Function | String | Array<Function | String>}>} [options.reactionButtons] An array of objects specifying reaction buttons
* @arg {Array<{emoji: String, type: String, response: (Function | String | Array<Function | String>)}>} [options.reactionButtons] An array of objects specifying reaction buttons
* `emoji` specifies the button emoji. Custom emojis should be in format `emojiName:emojiID`
* `type` specifies the type of the reaction button, either "edit" or "cancel"
* `response` specifies the content to edit the message to when the reaction button is pressed. This accepts the same arguments as the `generator` parameter of this function, but with an extra userID parameter for generator functions (`function(msg, args, userID)`) describing the user that made the reaction
* `filter` specifies a function (`function(msg, emoji, userID)`) that filters message reactions. If the function returns false, the reaction is not treated as a valid reaction button response
* @arg {Number} [options.reactionButtonTimeout=60000] Time (in milliseconds) to wait before invalidating the command's reaction buttons

@@ -380,3 +375,3 @@ * @arg {Object} [options.requirements] A set of factors that limit who can call the command

if(this.commands[label] || (this.commands[lowercaseCommand] && this.commands[lowercaseCommand].caseInsensitive)) {
throw new Error("You have already registered a command for " + label);
throw new Error(`You have already registered a command for ${label}`);
}

@@ -398,3 +393,3 @@ // Aliases are not deleted when deleting commands

if(this.commands[label]) {
throw new Error("You have already registered a command for " + label);
throw new Error(`You have already registered a command for ${label}`);
}

@@ -409,3 +404,3 @@ command = this.commandAliases[label];

if(this.commands[alias] || (this.commands[lowercaseCommand] && this.commands[lowercaseCommand].caseInsensitive)) {
throw new Error("You have already registered a command for alias " + alias);
throw new Error(`You have already registered a command for alias ${alias}`);
}

@@ -419,3 +414,3 @@ command = this.commandAliases[alias];

if(this.commands[alias]) {
throw new Error("You have already registered a command for alias " + alias);
throw new Error(`You have already registered a command for alias ${alias}`);
}

@@ -450,3 +445,3 @@ command = this.commandAliases[alias];

if(channelID) {
this.removeMessageReactions(channelID, id).catch(function(){});
this.removeMessageReactions(channelID, id).catch(() => {});
}

@@ -453,0 +448,0 @@ }

@@ -18,2 +18,7 @@ "use strict";

module.exports.ImageSizeBoundaries = {
MINIMUM: 16,
MAXIMUM: 2048
};
module.exports.GatewayOPCodes = {

@@ -98,3 +103,3 @@ EVENT: 0,

"Brace yourselves. %user% just joined the server.",
"%user% just joined. Hide your bananas.",
"%user% just joined... or did they?",
"%user% just arrived. Seems OP - please nerf.",

@@ -109,5 +114,5 @@ "%user% just slid into the server.",

"It's a bird! It's a plane! Nevermind, it's just %user%.",
"It's %user%! Praise the sun! \\[T]/",
"It's %user%! Praise the sun! \\\\[T]/",
"Never gonna give %user% up. Never gonna let %user% down.",
"Ha! %user% has joined! You activated my trap card!",
"%user% has joined the battle bus.",
"Cheers, love! %user%'s here!",

@@ -114,0 +119,0 @@ "Hey! Listen! %user% has joined!",

@@ -60,4 +60,4 @@ "use strict";

}
for(const other of this) {
if(!other[1].ready) {
for(const other of this.values()) {
if(!other.ready) {
return;

@@ -83,4 +83,4 @@ }

}
for(const other of this) {
if(!other[1].ready) {
for(const other of this.values()) {
if(!other.ready) {
return;

@@ -100,4 +100,4 @@ }

this._client.emit("shardDisconnect", error, shard.id);
for(const other of this) {
if(other[1].ready) {
for(const other of this.values()) {
if(other.ready) {
return;

@@ -104,0 +104,0 @@ }

@@ -40,2 +40,3 @@ "use strict";

module.exports.GUILD_INVITES = (guildID) => `/guilds/${guildID}/invites`;
module.exports.GUILD_VANITY_URL = (guildID) => `/guilds/${guildID}/vanity-url`;
module.exports.GUILD_MEMBER = (guildID, memberID) => `/guilds/${guildID}/members/${memberID}`;

@@ -42,0 +43,0 @@ module.exports.GUILD_MEMBER_NICK = (guildID, memberID) => `/guilds/${guildID}/members/${memberID}/nick`;

@@ -21,2 +21,3 @@ "use strict";

this.requestTimeout = client.options.requestTimeout;
this.agent = client.options.agent;
this.latencyRef = {

@@ -62,3 +63,3 @@ latency: 500,

* @arg {Object} [file] File object
* @arg {String} file.file A buffer containing file data
* @arg {Buffer} file.file A buffer containing file data
* @arg {String} file.name What to name the file

@@ -89,5 +90,2 @@ * @returns {Promise<Object>} Resolves with the returned JSON data

if(body && body.reason) { // Audit log reason sniping
if(body.reason === decodeURI(body.reason)) {
body.reason = encodeURIComponent(body.reason);
}
headers["X-Audit-Log-Reason"] = body.reason;

@@ -155,3 +153,4 @@ delete body.reason;

path: this.baseURL + finalURL,
headers: headers
headers: headers,
agent: this.agent
});

@@ -158,0 +157,0 @@

@@ -13,3 +13,3 @@ "use strict";

get createdAt() {
return (this.id / 4194304) + 1420070400000;
return Math.floor(this.id / 4194304) + 1420070400000;
}

@@ -16,0 +16,0 @@

"use strict";
const Channel = require("./Channel");
const Collection = require("../util/Collection");

@@ -19,3 +18,3 @@ const GuildChannel = require("./GuildChannel");

* @prop {Collection<PermissionOverwrite>} permissionOverwrites Collection of PermissionOverwrites in this channel
* @prop {Collection<Channel>?} channels A collection of guild channels that are part of this category
* @prop {Collection<GuildChannel>?} channels A collection of guild channels that are part of this category
*/

@@ -25,9 +24,9 @@ class CategoryChannel extends GuildChannel {

super(data, guild);
this.channels = new Collection(Channel);
this.channels = new Collection(GuildChannel);
if(guild) {
guild.channels.forEach((channel) => {
for(const channel of guild.channels.values()) {
if(channel.parentID === this.id) {
this.channels.add(channel);
}
});
}
}

@@ -34,0 +33,0 @@

@@ -6,3 +6,3 @@ "use strict";

/**
* Represents a channel. You also probably want to look at CategoryChannel, GroupChannel, PrivateChannel, TextChannel, and VoiceChannel.
* Represents a channel. You also probably want to look at CategoryChannel, GroupChannel, PrivateChannel, TextChannel, NewsChannel, and VoiceChannel.
* @prop {String} id The ID of the channel

@@ -9,0 +9,0 @@ * @prop {String} mention A string that mentions the channel

@@ -75,3 +75,3 @@ "use strict";

* @arg {String} [format] The filetype of the icon ("jpg", "png", "gif", or "webp")
* @arg {Number} [size] The size of the icon (128, 256, 512, 1024, 2048)
* @arg {Number} [size] The size of the icon (any power of two between 16 and 2048)
*/

@@ -82,3 +82,7 @@ dynamicIconURL(format, size) {

}
if(size < 16 || size > 1024 || (size & (size - 1))) {
if(
size < Constants.ImageSizeBoundaries.MINIMUM ||
size > Constants.ImageSizeBoundaries.MAXIMUM ||
(size & (size - 1))
) {
size = this._client.options.defaultImageSize;

@@ -85,0 +89,0 @@ }

@@ -6,8 +6,9 @@ "use strict";

const CDN_URL = require("../rest/Endpoints").CDN_URL;
const Channel = require("./Channel");
const Constants = require("../Constants");
const Collection = require("../util/Collection");
const GuildChannel = require("./GuildChannel");
const Member = require("./Member");
const Role = require("./Role");
const TextChannel = require("./TextChannel");
const NewsChannel = require("./NewsChannel");
const VoiceChannel = require("./VoiceChannel");

@@ -34,3 +35,3 @@

* @prop {Number} maxPresences The maximum number of people that can be online in a guild at once (returned from REST API only)
* @prop {Collection<Channel>} channels Collection of Channels in the guild
* @prop {Collection<GuildChannel>} channels Collection of Channels in the guild
* @prop {Collection<Member>} members Collection of Members in the guild

@@ -51,3 +52,3 @@ * @prop {Number} memberCount Number of members in the guild

this.joinedAt = Date.parse(data.joined_at);
this.channels = new Collection(Channel);
this.channels = new Collection(GuildChannel);
this.members = new Collection(Member);

@@ -65,8 +66,10 @@ this.memberCount = data.member_count;

for(let channel of data.channels) {
if(channel.type === 0) {
channel = this.channels.add(new TextChannel(channel, this), this);
} else if(channel.type === 2) {
if(channel.type === 2) {
channel = this.channels.add(new VoiceChannel(channel, this), this);
} else if(channel.type === 4) {
channel = this.channels.add(new CategoryChannel(channel, this), this);
} else if(channel.type === 5) {
channel = this.channels.add(new NewsChannel(channel, this), this);
} else if(channel.type === 0 || channel.last_message_id !== undefined) {
channel = this.channels.add(new TextChannel(channel, this), this);
} else {

@@ -120,3 +123,3 @@ channel = this.channels.add(channel, this);

if(client.options.seedVoiceConnections && voiceState.id === client.user.id && !client.voiceConnections.get(this.id)) {
process.nextTick(() => this.shard.client.joinVoiceChannel(voiceState.channel_id, false));
process.nextTick(() => this.shard.client.joinVoiceChannel(voiceState.channel_id));
}

@@ -133,2 +136,3 @@ }

this.splash = data.splash !== undefined ? data.splash : this.splash;
this.banner = data.banner !== undefined ? data.banner : this.banner;
this.region = data.region !== undefined ? data.region : this.region;

@@ -163,3 +167,3 @@ this.ownerID = data.owner_id !== undefined ? data.owner_id : this.ownerID;

* @arg {String} [format] The filetype of the icon ("jpg", "png", "gif", or "webp")
* @arg {Number} [size] The size of the icon (128, 256, 512, 1024, 2048)
* @arg {Number} [size] The size of the icon (any power of two between 16 and 2048)
*/

@@ -170,3 +174,7 @@ dynamicIconURL(format, size) {

}
if(size < 16 || size > 1024 || (size & (size - 1))) {
if(
size < Constants.ImageSizeBoundaries.MINIMUM ||
size > Constants.ImageSizeBoundaries.MAXIMUM ||
(size & (size - 1))
) {
size = this.shard.client.options.defaultImageSize;

@@ -181,2 +189,6 @@ }

get bannerURL() {
return this.banner ? `${CDN_URL}/banners/${this.id}/${this.banner}.jpg` : null;
}
/**

@@ -424,2 +436,10 @@ * Create a channel in the guild

/**
* Returns the vanity url of the guild
* @returns {Promise}
*/
getVanity() {
return this.shard.client.getGuildVanity.call(this.shard.client, this.id);
}
/**
* Edit a guild member

@@ -501,2 +521,4 @@ * @arg {String} memberID The ID of the member

* @arg {Number} [options.defaultNotifications] The default notification settings for the guild. 0 is "All Messages", 1 is "Only @mentions".
* @arg {Number} [options.explicitContentFilter] The level of the explicit content filter for messages/images in the guild. 0 disables message scanning, 1 enables scanning the messages of members without roles, 2 enables scanning for all messages.
* @arg {String} [options.systemChannelID] The ID of the system channel
* @arg {String} [options.afkChannelID] The ID of the AFK voice channel

@@ -506,2 +528,3 @@ * @arg {Number} [options.afkTimeout] The AFK timeout in seconds

* @arg {String} [options.splash] The guild splash image as a base64 data URI (VIP only). Note: base64 strings alone are not base64 data URI strings
* @arg {String} [options.banner] The guild banner image as a base64 data URI (VIP only). Note: base64 strings alone are not base64 data URI strings
* @arg {String} [reason] The reason to be displayed in audit logs

@@ -532,3 +555,3 @@ * @returns {Promise<Guild>}

* Get the ban list of the guild
* @returns {Promise<User[]>} Resolves with an array of {reason: String, user: User}
* @returns {Promise<Object[]>} Resolves with an array of {reason: String, user: User}
*/

@@ -567,3 +590,3 @@ getBans() {

const base = super.toJSON(true);
for(const prop of ["afkChannelID", "afkTimeout", "channels", "defaultNotifications", "emojis", "explicitContentFilter", "features", "icon", "joinedAt", "large", "maxPresences", "memberCount", "members", "mfaLevel", "name", "ownerID", "region", "roles", "splash", "unavailable", "verificationLevel"]) {
for(const prop of ["afkChannelID", "afkTimeout", "channels", "defaultNotifications", "emojis", "explicitContentFilter", "features", "icon", "joinedAt", "large", "maxPresences", "memberCount", "members", "mfaLevel", "name", "ownerID", "region", "roles", "splash", "banner", "unavailable", "verificationLevel"]) {
if(this[prop] !== undefined) {

@@ -570,0 +593,0 @@ base[prop] = this[prop] && this[prop].toJSON ? this[prop].toJSON() : this[prop];

@@ -14,3 +14,3 @@ "use strict";

* @prop {String} targetID The ID of the action target
* @prop {(CategoryChannel | Guild | Member | Invite | Role | Object | TextChannel | VoiceChannel)?} target The object of the action target
* @prop {(CategoryChannel | Guild | Member | Invite | Role | Object | TextChannel | VoiceChannel | NewsChannel)?} target The object of the action target
* If the item is not cached, this property will be null

@@ -17,0 +17,0 @@ * If the action targets a guild, this could be a Guild object

@@ -10,3 +10,3 @@ "use strict";

/**
* Represents a guild channel. You also probably want to look at CategoryChannel, TextChannel, and VoiceChannel.
* Represents a guild channel. You also probably want to look at CategoryChannel, TextChannel, NewsChannel, and VoiceChannel.
* @extends Channel

@@ -38,2 +38,3 @@ * @prop {String} id The ID of the channel

update(data) {
this.type = data.type !== undefined ? data.type : this.type;
this.name = data.name !== undefined ? data.name : this.name;

@@ -89,5 +90,6 @@ this.position = data.position !== undefined ? data.position : this.position;

* @arg {Number} [options.userLimit] The channel user limit (guild voice channels only)
* @arg {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (does not affect bots or users with manageMessages/manageChannel permissions) (guild text channels only)
* @arg {Number?} [options.parentID] The ID of the parent channel category for this channel (guild text/voice channels only)
* @arg {String} [reason] The reason to be displayed in audit logs
* @returns {Promise<CategoryChannel | TextChannel | VoiceChannel>}
* @returns {Promise<CategoryChannel | TextChannel | VoiceChannel | NewsChannel>}
*/

@@ -94,0 +96,0 @@ edit(options, reason) {

@@ -15,5 +15,10 @@ "use strict";

* @prop {Number} joinedAt Timestamp of when the member joined the guild
* @prop {String} status The member's status. Either "online", "idle", or "offline"
* @prop {String} status The member's status. Either "online", "idle", "dnd", or "offline"
* @prop {Object?} game The active game the member is playing
* @prop {String} game.name The name of the active game
* @prop {Object} clientStatus The member's per-client status
* @prop {String} clientStatus.web The member's status on web. Either "online", "idle", "dnd", or "offline". Will be "online" for bots
* @prop {String} clientStatus.desktop The member's status on desktop. Either "online", "idle", "dnd", or "offline". Will be "offline" for bots
* @prop {String} clientStatus.mobile The member's status on mobile. Either "online", "idle", "dnd", or "offline". Will be "offline" for bots
* @prop {Object[]} activities The member's current activities
* @prop {Number} game.type The type of the active game (0 is default, 1 is Twitch, 2 is YouTube)

@@ -37,3 +42,3 @@ * @prop {String?} game.url The url of the active game

class Member extends Base {
constructor(data, guild) {
constructor(data, guild, client) {
super(data.id);

@@ -49,3 +54,3 @@ if((this.guild = guild)) {

} else if(data.user) {
this.user = new User(data.user);
this.user = new User(data.user, client);
} else {

@@ -62,2 +67,4 @@ this.user = null;

this.joinedAt = data.joined_at !== undefined ? Date.parse(data.joined_at) : this.joinedAt;
this.clientStatus = data.client_status !== undefined ? Object.assign({ web: "offline", desktop: "offline", mobile: "offline" }, data.client_status) : this.clientStatus;
this.activities = data.activities;

@@ -64,0 +71,0 @@ if(data.mute !== undefined) {

@@ -11,3 +11,3 @@ "use strict";

* @prop {String} id The ID of the message
* @prop {PrivateChannel | TextChannel} channel The channel the message is in
* @prop {PrivateChannel | TextChannel | NewsChannel} channel The channel the message is in
* @prop {Number} timestamp Timestamp of message creation

@@ -104,3 +104,3 @@ * @prop {Number} type The type of the message

} else {
throw new Error("Unhandled MESSAGE_CREATE type: " + JSON.stringify(data, null, 2));
client.emit("warn", "Unhandled MESSAGE_CREATE type: " + JSON.stringify(data, null, 2));
}

@@ -120,3 +120,3 @@

this.mentions = data.mentions.map((mention) => {
let user = client.users.add(mention, client);
const user = client.users.add(mention, client);
if(mention.member && this.channel.guild) {

@@ -133,3 +133,3 @@ mention.member.id = mention.id;

this.pinned = data.pinned !== undefined ? !!data.pinned : this.pinned;
this.editedTimestamp = data.edited_timestamp !== null ? Date.parse(data.edited_timestamp) : this.editedTimestamp;
this.editedTimestamp = data.edited_timestamp != undefined ? Date.parse(data.edited_timestamp) : this.editedTimestamp;
this.tts = data.tts !== undefined ? data.tts : this.tts;

@@ -136,0 +136,0 @@ this.attachments = data.attachments !== undefined ? data.attachments : this.attachments;

@@ -25,2 +25,3 @@ "use strict";

this.lastMessageID = data.last_message_id;
this.rateLimitPerUser = data.rate_limit_per_user;
this.call = this.lastCall = null;

@@ -106,3 +107,3 @@ if(this.type === 1 || this.type === undefined) {

* @arg {Object} [file] A file object
* @arg {String} file.file A buffer containing file data
* @arg {Buffer} file.file A buffer containing file data
* @arg {String} file.name What to name the file

@@ -109,0 +110,0 @@ * @returns {Promise<Message>}

@@ -23,2 +23,3 @@ "use strict";

* @prop {String?} topic The topic of the channel
* @prop {Number} rateLimitPerUser The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled
*/

@@ -33,2 +34,3 @@ class TextChannel extends GuildChannel {

this.lastMessageID = data.last_message_id || null;
this.rateLimitPerUser = data.rate_limit_per_user == undefined ? null : data.rate_limit_per_user;
this.lastPinTimestamp = data.last_pin_timestamp ? Date.parse(data.last_pin_timestamp) : null;

@@ -40,3 +42,3 @@ this.update(data);

super.update(data);
this.rateLimitPerUser = data.rate_limit_per_user !== undefined ? data.rate_limit_per_user : this.rateLimitPerUser;
this.topic = data.topic !== undefined ? data.topic : this.topic;

@@ -154,3 +156,3 @@ }

* @arg {Object} [file] A file object
* @arg {String} file.file A buffer containing file data
* @arg {Buffer} file.file A buffer containing file data
* @arg {String} file.name What to name the file

@@ -259,3 +261,3 @@ * @returns {Promise<Message>}

const base = super.toJSON(true);
for(const prop of ["lastMessageID", "lastPinTimestamp", "messages", "topic"]) {
for(const prop of ["lastMessageID", "lastPinTimestamp", "messages", "rateLimitPerUser", "topic"]) {
if(this[prop] !== undefined) {

@@ -262,0 +264,0 @@ base[prop] = this[prop] && this[prop].toJSON ? this[prop].toJSON() : this[prop];

@@ -68,3 +68,3 @@ "use strict";

* @arg {String} [format] The filetype of the avatar ("jpg", "png", "gif", or "webp")
* @arg {Number} [size] The size of the avatar (128, 256, 512, 1024, 2048)
* @arg {Number} [size] The size of the avatar (any power of two between 16 and 2048)
*/

@@ -79,3 +79,7 @@ dynamicAvatarURL(format, size) {

}
if(size < 16 || size > 1024 || (size & (size - 1))) {
if(
size < Constants.ImageSizeBoundaries.MINIMUM ||
size > Constants.ImageSizeBoundaries.MAXIMUM ||
(size & (size - 1))
) {
size = this._client.options.defaultImageSize;

@@ -82,0 +86,0 @@ }

@@ -77,3 +77,9 @@ "use strict";

}
return Array.from(this.values())[Math.floor(Math.random() * this.size)];
const index = Math.floor(Math.random() * this.size);
const iter = this.values();
let res;
for(let i = 0; i <= index; i++) {
res = iter.next().value;
}
return res;
}

@@ -110,2 +116,46 @@

/**
* Returns a value resulting from applying a function to every element of the collection
* @arg {function} func A function that takes the previous value and the next item and returns a new value
* @arg {any} val The initial value passed to the function
* @returns {any} The final result
*/
reduce(func, initialValue) {
const iter = this.values();
let val;
let result = initialValue === undefined ? iter.next().value : initialValue;
while((val = iter.next().value) !== undefined) {
result = func(result, val);
}
return result;
}
/**
* Returns true if all elements satisfy the condition
* @arg {function} func A function that takes an object and returns true or false
* @returns {Boolean} Whether or not all elements satisfied the condition
*/
every(func) {
for(const item of this.values()) {
if(!func(item)) {
return false;
}
}
return true;
}
/**
* Returns true if at least one element satisfies the condition
* @arg {function} func A function that takes an object and returns true or false
* @returns {Boolean} Whether or not at least one element satisfied the condition
*/
some(func) {
for(const item of this.values()) {
if(func(item)) {
return true;
}
}
return false;
}
/**
* Update an object

@@ -112,0 +162,0 @@ * @arg {Object} obj The updated object data

@@ -168,4 +168,4 @@ "use strict";

}
} else if(this.current.options.voiceDataTimeout === -1 || this.current.bufferingTicks < this.current.options.voiceDataTimeout / this.current.options.frameDuration) { // wait for data
if(++this.current.bufferingTicks <= 0) {
} else if(this.current.options.voiceDataTimeout === -1 || this.current.bufferingTicks < this.current.options.voiceDataTimeout / (4 * this.current.options.frameDuration)) { // wait for data
if(++this.current.bufferingTicks === 1) {
this.setSpeaking(false);

@@ -172,0 +172,0 @@ } else {

@@ -501,4 +501,4 @@ "use strict";

}
} else if(this.current.options.voiceDataTimeout === -1 || this.current.bufferingTicks < this.current.options.voiceDataTimeout / this.current.options.frameDuration) { // wait for data
if(++this.current.bufferingTicks <= 0) {
} else if(this.current.options.voiceDataTimeout === -1 || this.current.bufferingTicks < this.current.options.voiceDataTimeout / (4 * this.current.options.frameDuration)) { // wait for data
if(++this.current.bufferingTicks === 1) {
this.setSpeaking(false);

@@ -640,18 +640,16 @@ }

}
if(data[0] === 0xBE && data[1] === 0xDE) { // RFC5285 Section 4.2: One-Byte Header
const rtpHeaderExtensionLength = data[2] << 8 | data[3];
let index = 4;
let byte;
for(let i = 0; i < rtpHeaderExtensionLength; ++i) {
byte = data[index];
const hasExtension = !!(msg[0] & 0b10000);
const cc = msg[0] & 0b1111;
if(cc > 0) {
data = data.slice(cc * 4);
}
// Not a RFC5285 One Byte Header Extension (not negotiated)
if(hasExtension) { // RFC3550 5.3.1: RTP Header Extension
const l = data[2] << 8 | data[3];
let index = 4 + l * 4;
while(data[index] == 0) {
++index;
const l = (byte & 0b1111) + 1;
index += l;
while(data[index] == 0) {
++index;
}
}
data = data.slice(index);
}
// Have not received a RFC5285 Section 4.3: Two-Byte Header yet, so that is unimplemented for now
if(this.receiveStreamOpus) {

@@ -658,0 +656,0 @@ /**

{
"name": "eris",
"version": "0.9.0",
"version": "0.10.0",
"description": "A NodeJS Discord library",
"main": "./index.js",
"engines": {
"node": ">=4.0.0"
"node": ">=8.0.0"
},

@@ -9,0 +9,0 @@ "scripts": {

@@ -9,3 +9,3 @@ Eris [![NPM version](https://img.shields.io/npm/v/eris.svg?style=flat-square)](https://npmjs.com/package/eris)

You will need NodeJS 4+. If you need voice support you will also need Python 2.7 and a C++ compiler. Refer to [the Getting Started section of the docs](https://abal.moe/Eris/docs.html) for more details.
You will need NodeJS 8+. If you need voice support you will also need Python 2.7 and a C++ compiler. Refer to [the Getting Started section of the docs](https://abal.moe/Eris/docs.html) for more details.

@@ -12,0 +12,0 @@ ```

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc