mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 13:03:31 +01:00
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:
@@ -41,16 +41,18 @@ class RESTMethods{
|
|||||||
SendMessage(channel, content, tts, nonce) {
|
SendMessage(channel, content, tts, nonce) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
||||||
|
var _this = this;
|
||||||
|
|
||||||
if (channel instanceof User || channel instanceof GuildMember) {
|
if (channel instanceof User || channel instanceof GuildMember) {
|
||||||
this.CreateDM(channel).then(chan => {
|
this.CreateDM(channel).then(chan => {
|
||||||
channel = chan;
|
channel = chan;
|
||||||
req();
|
req();
|
||||||
})
|
})
|
||||||
.catch(reject);
|
.catch(reject);
|
||||||
|
} else {
|
||||||
|
req();
|
||||||
}
|
}
|
||||||
|
|
||||||
var _this = this;
|
|
||||||
|
|
||||||
function req() {
|
function req() {
|
||||||
_this.rest.makeRequest('post', Constants.Endpoints.CHANNEL_MESSAGES(channel.id), true, {
|
_this.rest.makeRequest('post', Constants.Endpoints.CHANNEL_MESSAGES(channel.id), true, {
|
||||||
content, tts, nonce,
|
content, tts, nonce,
|
||||||
|
|||||||
@@ -60,11 +60,7 @@ class PresenceUpdateHandler extends AbstractHandler {
|
|||||||
data.user.discriminator === user.discriminator &&
|
data.user.discriminator === user.discriminator &&
|
||||||
data.user.avatar === user.avatar &&
|
data.user.avatar === user.avatar &&
|
||||||
data.user.status === user.status &&
|
data.user.status === user.status &&
|
||||||
!(
|
JSON.stringify(data.user.game) === JSON.stringify(user.game)
|
||||||
(data.user.game && !user.game) ||
|
|
||||||
(!data.user.game && user.game) ||
|
|
||||||
(data.user.game && user.game && data.user.game.name !== user.game.name)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!same) {
|
if (!same) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class EvaluatedPermissions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!explicit) {
|
if (!explicit) {
|
||||||
if ((this.permissions & Constants.PermissionFlags.MANAGE_ROLES) > 0) {
|
if ((this.permissions & Constants.PermissionFlags.ADMINISTRATOR) > 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class Role {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!explicit) {
|
if (!explicit) {
|
||||||
if ((this.permissions & Constants.PermissionFlags.MANAGE_ROLES) > 0) {
|
if ((this.permissions & Constants.PermissionFlags.ADMINISTRATOR) > 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ const PermissionFlags = exports.PermissionFlags = {
|
|||||||
CREATE_INSTANT_INVITE: 1 << 0,
|
CREATE_INSTANT_INVITE: 1 << 0,
|
||||||
KICK_MEMBERS: 1 << 1,
|
KICK_MEMBERS: 1 << 1,
|
||||||
BAN_MEMBERS: 1 << 2,
|
BAN_MEMBERS: 1 << 2,
|
||||||
MANAGE_ROLES: 1 << 3,
|
ADMINISTRATOR: 1 << 3,
|
||||||
MANAGE_CHANNELS: 1 << 4,
|
MANAGE_CHANNELS: 1 << 4,
|
||||||
MANAGE_GUILD: 1 << 5,
|
MANAGE_GUILD: 1 << 5,
|
||||||
|
|
||||||
@@ -165,6 +165,10 @@ const PermissionFlags = exports.PermissionFlags = {
|
|||||||
DEAFEN_MEMBERS: 1 << 23,
|
DEAFEN_MEMBERS: 1 << 23,
|
||||||
MOVE_MEMBERS: 1 << 24,
|
MOVE_MEMBERS: 1 << 24,
|
||||||
USE_VAD: 1 << 25,
|
USE_VAD: 1 << 25,
|
||||||
|
|
||||||
|
CHANGE_NICKNAME: 1 << 26,
|
||||||
|
MANAGE_NICKNAMES: 1 << 27,
|
||||||
|
MANAGE_ROLES_OR_PERMISSIONS: 1 << 28,
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ALL_PERMISSIONS = 0;
|
let _ALL_PERMISSIONS = 0;
|
||||||
|
|||||||
@@ -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') {
|
if (message.content === 'delchann') {
|
||||||
message.channel.delete().then(chan => console.log('selfDelChann', chan.name));
|
message.channel.delete().then(chan => console.log('selfDelChann', chan.name));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user