Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: minemidnight/eris-additions
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: PolestarLabs/eris-additions-plus
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
Loading
Showing with 60 additions and 16 deletions.
  1. +16 −9 lib/Channel/awaitMessages.js
  2. +6 −0 lib/Channel/send.js
  3. +1 −1 lib/Channel/sendEmbed.js
  4. +1 −1 lib/Channel/sendMessage.js
  5. +6 −2 lib/Eris/Embed.js
  6. +10 −0 lib/Message/deleteAfter.js
  7. +12 −0 lib/Message/reply.js
  8. +5 −0 lib/User/displayAvatarURL.js
  9. +3 −3 package.json
25 changes: 16 additions & 9 deletions lib/Channel/awaitMessages.js
Original file line number Diff line number Diff line change
@@ -38,16 +38,23 @@ class MessageCollector extends EventEmitter {

let listening = false;
module.exports = Eris => {
Eris.Channel.prototype.awaitMessages = function (filter, options) {
if(!listening) {
this.client.on("messageCreate", message => {
for(const collector of collectors) collector.verify(message);
});

listening = true;
}

Eris.Channel.prototype.awaitMessages = function (filter, options) {
checkListener(this)
const collector = new MessageCollector(this, filter, options);
return new Promise(resolve => collector.on("end", resolve));
};
Eris.Channel.prototype.createMessageCollector = function(filter, options) {
checkListener(this)
return new MessageCollector(this, filter, options);
}
};

function checkListener(CHANNEL){
if(!listening) {
CHANNEL.client.on("messageCreate", message => {
for(const collector of collectors) collector.verify(message);
});

listening = true;
}
}
6 changes: 6 additions & 0 deletions lib/Channel/send.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = Eris => {
Eris.TextChannel.prototype.send = Eris.TextChannel.prototype.createMessage;
Eris.PrivateChannel.prototype.send = Eris.PrivateChannel.prototype.createMessage;
Eris.ThreadChannel.prototype.send = Eris.TextChannel.prototype.createMessage;
Eris.PrivateThreadChannel.prototype.send = Eris.TextChannel.prototype.createMessage;
};
2 changes: 1 addition & 1 deletion lib/Channel/sendEmbed.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = Eris => {
Eris.Channel.prototype.sendEmbed = Eris.Channel.prototype.createEmbed;
Eris.TextChannel.prototype.sendEmbed = Eris.TextChannel.prototype.createEmbed;
};

module.exports.deps = ["Channel.createEmbed"];
2 changes: 1 addition & 1 deletion lib/Channel/sendMessage.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = Eris => {
Eris.Channel.prototype.sendMessage = Eris.Channel.prototype.createMessage;
Eris.TextChannel.prototype.sendMessage = Eris.TextChannel.prototype.createMessage;
};
8 changes: 6 additions & 2 deletions lib/Eris/Embed.js
Original file line number Diff line number Diff line change
@@ -13,8 +13,12 @@ class Embed {
}

color(color) {
this.color = color;

if(typeof color === 'string'){
this.color = parseInt(color.replace(/^#/, ''), 16);
}else{
//backwards compat
this.color = color;
}
return this;
}

10 changes: 10 additions & 0 deletions lib/Message/deleteAfter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = Eris => {
Eris.Message.prototype.deleteAfter = function(timer,reason){
return new Promise(async resolve => {
setTimeout(f=>{
return resolve(this.delete(reason));
},timer);

});
}
};
12 changes: 12 additions & 0 deletions lib/Message/reply.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = Eris => {
Eris.Message.prototype.reply = function(content, file, ping=false) {
if(typeof content === 'string'){
return this.channel.createMessage({content,messageReferenceID:this.id},file);
}else if (typeof content === 'object'){
if (typeof file === 'boolean') ping = file;
content.messageReference ??= { messageID: this.id };
content.allowedMentions ??= { repliedUser: ping || false };
return this.channel.createMessage(content , typeof file === 'object' ? file : null );
}
}
}
5 changes: 5 additions & 0 deletions lib/User/displayAvatarURL.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = (Eris) => {
Object.defineProperty(Eris.User.prototype,'displayAvatarURL',{
get: function() {return this.avatarURL || this.defaultAvatarURL}
});
};
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eris-additions",
"version": "1.4.1",
"version": "1.5.0",
"description": "extend prototypes for eris",
"main": "index.js",
"engines": {
@@ -28,6 +28,6 @@
},
"homepage": "https://github.com/minemidnight/eris-additions#readme",
"dependencies": {
"eris": "^0.12.0"
"eris": "^0.15.0"
}
}
}