mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 17:43:30 +01:00
Added guild.kick(member) and member.kick()
This commit is contained in:
@@ -1,26 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
const requireAction = name => require(`./${name}`);
|
||||
|
||||
class ActionsManager {
|
||||
constructor(client) {
|
||||
this.client = client;
|
||||
|
||||
this.register('MessageCreate');
|
||||
this.register('MessageDelete');
|
||||
this.register('MessageUpdate');
|
||||
this.register('ChannelCreate');
|
||||
this.register('ChannelDelete');
|
||||
this.register('ChannelUpdate');
|
||||
this.register('GuildDelete');
|
||||
this.register('GuildUpdate');
|
||||
this.register('UserUpdate');
|
||||
}
|
||||
|
||||
register(name) {
|
||||
let Action = requireAction(name);
|
||||
this[name] = new Action(this.client);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ActionsManager;
|
||||
'use strict';
|
||||
|
||||
const requireAction = name => require(`./${name}`);
|
||||
|
||||
class ActionsManager {
|
||||
constructor(client) {
|
||||
this.client = client;
|
||||
|
||||
this.register('MessageCreate');
|
||||
this.register('MessageDelete');
|
||||
this.register('MessageUpdate');
|
||||
this.register('ChannelCreate');
|
||||
this.register('ChannelDelete');
|
||||
this.register('ChannelUpdate');
|
||||
this.register('GuildDelete');
|
||||
this.register('GuildUpdate');
|
||||
this.register('GuildMemberRemove');
|
||||
this.register('UserUpdate');
|
||||
}
|
||||
|
||||
register(name) {
|
||||
let Action = requireAction(name);
|
||||
this[name] = new Action(this.client);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ActionsManager;
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Constants = require('../../util/Constants');
|
||||
const Message = require('../../structures/Message');
|
||||
|
||||
class ChannelDeleteAction extends Action {
|
||||
|
||||
constructor(client) {
|
||||
super(client);
|
||||
this.timeouts = [];
|
||||
this.deleted = {};
|
||||
}
|
||||
|
||||
handle(data) {
|
||||
let client = this.client;
|
||||
let channel = client.store.get('channels', data.id);
|
||||
|
||||
if (channel) {
|
||||
|
||||
client.store.KillChannel(channel);
|
||||
this.deleted[channel.id] = channel;
|
||||
this.scheduleForDeletion(channel.id);
|
||||
|
||||
} else if (this.deleted[data.id]) {
|
||||
|
||||
channel = this.deleted[data.id];
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
channel,
|
||||
};
|
||||
}
|
||||
|
||||
scheduleForDeletion(id) {
|
||||
this.timeouts.push(
|
||||
setTimeout(() => delete this.deleted[id],
|
||||
this.client.options.rest_ws_bridge_timeout)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = ChannelDeleteAction;
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Constants = require('../../util/Constants');
|
||||
const Message = require('../../structures/Message');
|
||||
|
||||
class ChannelDeleteAction extends Action {
|
||||
|
||||
constructor(client) {
|
||||
super(client);
|
||||
this.timeouts = [];
|
||||
this.deleted = {};
|
||||
}
|
||||
|
||||
handle(data) {
|
||||
let client = this.client;
|
||||
let channel = client.store.get('channels', data.id);
|
||||
|
||||
if (channel) {
|
||||
|
||||
client.store.KillChannel(channel);
|
||||
this.deleted[channel.id] = channel;
|
||||
this.scheduleForDeletion(channel.id);
|
||||
|
||||
} else if (this.deleted[data.id]) {
|
||||
|
||||
channel = this.deleted[data.id];
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
channel,
|
||||
};
|
||||
}
|
||||
|
||||
scheduleForDeletion(id) {
|
||||
this.timeouts.push(
|
||||
setTimeout(() => delete this.deleted[id],
|
||||
this.client.options.rest_ws_bridge_timeout)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = ChannelDeleteAction;
|
||||
|
||||
50
src/client/actions/GuildMemberRemove.js
Normal file
50
src/client/actions/GuildMemberRemove.js
Normal file
@@ -0,0 +1,50 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Constants = require('../../util/Constants');
|
||||
const Message = require('../../structures/Message');
|
||||
|
||||
class GuildMemberRemoveAction extends Action {
|
||||
|
||||
constructor(client) {
|
||||
super(client);
|
||||
this.timeouts = [];
|
||||
this.deleted = {};
|
||||
}
|
||||
|
||||
handle(data) {
|
||||
let client = this.client;
|
||||
let guild = client.store.get('guilds', data.guild_id);
|
||||
if (guild) {
|
||||
let member = guild.store.get('members', data.user.id);
|
||||
if (member) {
|
||||
guild._removeMember(member);
|
||||
this.deleted[guild.id + data.user.id] = member;
|
||||
this.scheduleForDeletion(guild.id, data.user.id);
|
||||
}
|
||||
|
||||
if (!member) {
|
||||
member = this.deleted[guild.id + data.user.id];
|
||||
}
|
||||
|
||||
return {
|
||||
g: guild,
|
||||
m: member,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
g: guild,
|
||||
m: null,
|
||||
};
|
||||
}
|
||||
|
||||
scheduleForDeletion(guildID, userID) {
|
||||
this.timeouts.push(
|
||||
setTimeout(() => delete this.deleted[guildID + userID],
|
||||
this.client.options.rest_ws_bridge_timeout)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = GuildMemberRemoveAction;
|
||||
Reference in New Issue
Block a user