Fix Message Sending and Support New Features. The library now supports

all the game streaming and URL stuff and is fixed for roles #328

src/client/websocket/packets/handlers/PresenceUpdate.js
This commit is contained in:
hydrabolt
2016-05-07 15:33:00 +01:00
parent bc443df11d
commit fb49ad7d93
6 changed files with 17 additions and 10 deletions

View File

@@ -41,16 +41,18 @@ class RESTMethods{
SendMessage(channel, content, tts, nonce) {
return new Promise((resolve, reject) => {
var _this = this;
if (channel instanceof User || channel instanceof GuildMember) {
this.CreateDM(channel).then(chan => {
channel = chan;
req();
})
.catch(reject);
} else {
req();
}
var _this = this;
function req() {
_this.rest.makeRequest('post', Constants.Endpoints.CHANNEL_MESSAGES(channel.id), true, {
content, tts, nonce,

View File

@@ -60,11 +60,7 @@ class PresenceUpdateHandler extends AbstractHandler {
data.user.discriminator === user.discriminator &&
data.user.avatar === user.avatar &&
data.user.status === user.status &&
!(
(data.user.game && !user.game) ||
(!data.user.game && user.game) ||
(data.user.game && user.game && data.user.game.name !== user.game.name)
)
JSON.stringify(data.user.game) === JSON.stringify(user.game)
);
if (!same) {

View File

@@ -27,7 +27,7 @@ class EvaluatedPermissions {
}
if (!explicit) {
if ((this.permissions & Constants.PermissionFlags.MANAGE_ROLES) > 0) {
if ((this.permissions & Constants.PermissionFlags.ADMINISTRATOR) > 0) {
return true;
}
}

View File

@@ -40,7 +40,7 @@ class Role {
}
if (!explicit) {
if ((this.permissions & Constants.PermissionFlags.MANAGE_ROLES) > 0) {
if ((this.permissions & Constants.PermissionFlags.ADMINISTRATOR) > 0) {
return true;
}
}

View File

@@ -146,7 +146,7 @@ const PermissionFlags = exports.PermissionFlags = {
CREATE_INSTANT_INVITE: 1 << 0,
KICK_MEMBERS: 1 << 1,
BAN_MEMBERS: 1 << 2,
MANAGE_ROLES: 1 << 3,
ADMINISTRATOR: 1 << 3,
MANAGE_CHANNELS: 1 << 4,
MANAGE_GUILD: 1 << 5,
@@ -165,6 +165,10 @@ const PermissionFlags = exports.PermissionFlags = {
DEAFEN_MEMBERS: 1 << 23,
MOVE_MEMBERS: 1 << 24,
USE_VAD: 1 << 25,
CHANGE_NICKNAME: 1 << 26,
MANAGE_NICKNAMES: 1 << 27,
MANAGE_ROLES_OR_PERMISSIONS: 1 << 28,
};
let _ALL_PERMISSIONS = 0;

View File

@@ -77,6 +77,11 @@ client.on('message', message => {
}
}
if (message.content === 'myperms?') {
message.channel.sendMessage('Your permissions are:\n' +
JSON.stringify(message.channel.permissionsFor(message.author).serialize(), null, 4));
}
if (message.content === 'delchann') {
message.channel.delete().then(chan => console.log('selfDelChann', chan.name));
}