mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 03:53:29 +01:00
Fixed PM Channel bug, 3.8.2
Clients no longer crashed when receiving PM channel messages.
This commit is contained in:
@@ -11,6 +11,7 @@ var PMChannel = (function () {
|
|||||||
this.user = client.getUser("id", data.recipient.id);
|
this.user = client.getUser("id", data.recipient.id);
|
||||||
this.id = data.id;
|
this.id = data.id;
|
||||||
this.messages = [];
|
this.messages = [];
|
||||||
|
this.client = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
_createClass(PMChannel, [{
|
_createClass(PMChannel, [{
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ var Channel = (function () {
|
|||||||
this.messages = [];
|
this.messages = [];
|
||||||
this.roles = [];
|
this.roles = [];
|
||||||
|
|
||||||
|
if (data.permission_overwrites) {
|
||||||
var _iteratorNormalCompletion = true;
|
var _iteratorNormalCompletion = true;
|
||||||
var _didIteratorError = false;
|
var _didIteratorError = false;
|
||||||
var _iteratorError = undefined;
|
var _iteratorError = undefined;
|
||||||
@@ -28,8 +29,6 @@ var Channel = (function () {
|
|||||||
|
|
||||||
this.roles.push(new ChannelPermissions(role, this));
|
this.roles.push(new ChannelPermissions(role, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
//this.isPrivate = isPrivate; //not sure about the implementation of this...
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
_didIteratorError = true;
|
_didIteratorError = true;
|
||||||
_iteratorError = err;
|
_iteratorError = err;
|
||||||
@@ -44,6 +43,7 @@ var Channel = (function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} //this.isPrivate = isPrivate; //not sure about the implementation of this...
|
||||||
}
|
}
|
||||||
|
|
||||||
_createClass(Channel, [{
|
_createClass(Channel, [{
|
||||||
|
|||||||
@@ -20,7 +20,13 @@ var Message = (function () {
|
|||||||
this.editedTimestamp = data.edited_timestamp;
|
this.editedTimestamp = data.edited_timestamp;
|
||||||
this.content = data.content.trim();
|
this.content = data.content.trim();
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
this.author = this.channel.server.getMember("id", author.id);
|
|
||||||
|
if (this.isPrivate) {
|
||||||
|
this.author = this.channel.client.getUser("id", author.id);
|
||||||
|
} else {
|
||||||
|
this.author = this.channel.server.getMember("id", author.id) || this.channel.client.getUser("id", author.id);
|
||||||
|
}
|
||||||
|
|
||||||
this.attachments = data.attachments;
|
this.attachments = data.attachments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "discord.js",
|
"name": "discord.js",
|
||||||
"version": "3.8.1",
|
"version": "3.8.2",
|
||||||
"description": "A way to interface with the Discord API",
|
"description": "A way to interface with the Discord API",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ class PMChannel {
|
|||||||
this.user = client.getUser("id", data.recipient.id);
|
this.user = client.getUser("id", data.recipient.id);
|
||||||
this.id = data.id;
|
this.id = data.id;
|
||||||
this.messages = [];
|
this.messages = [];
|
||||||
|
this.client = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
addMessage(data){
|
addMessage(data){
|
||||||
|
|||||||
@@ -11,10 +11,9 @@ class Channel {
|
|||||||
this.messages = [];
|
this.messages = [];
|
||||||
this.roles = [];
|
this.roles = [];
|
||||||
|
|
||||||
|
if(data.permission_overwrites)
|
||||||
for (var role of data.permission_overwrites) {
|
for (var role of data.permission_overwrites) {
|
||||||
|
|
||||||
this.roles.push( new ChannelPermissions(role, this) );
|
this.roles.push( new ChannelPermissions(role, this) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//this.isPrivate = isPrivate; //not sure about the implementation of this...
|
//this.isPrivate = isPrivate; //not sure about the implementation of this...
|
||||||
|
|||||||
@@ -12,7 +12,13 @@ class Message{
|
|||||||
this.editedTimestamp = data.edited_timestamp;
|
this.editedTimestamp = data.edited_timestamp;
|
||||||
this.content = data.content.trim();
|
this.content = data.content.trim();
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
this.author = this.channel.server.getMember("id", author.id);
|
|
||||||
|
if(this.isPrivate){
|
||||||
|
this.author = this.channel.client.getUser("id", author.id);
|
||||||
|
}else{
|
||||||
|
this.author = this.channel.server.getMember("id", author.id) || this.channel.client.getUser("id", author.id);
|
||||||
|
}
|
||||||
|
|
||||||
this.attachments = data.attachments;
|
this.attachments = data.attachments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,13 +22,9 @@ mybot.on("message", function (message) {
|
|||||||
user = message.sender;
|
user = message.sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("the ID is ", user.id);
|
console.log( mybot.getUser("username", "meew0") );
|
||||||
|
|
||||||
for(key in message.channel.permissionsOf(user)){
|
mybot.reply(message, JSON.stringify(message.mentions, null, 4));
|
||||||
console.log(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
mybot.reply(message, user + "'s evaluated permissions in this channel are " + message.channel.permissionsOf(user).sendTTSMessages);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user