mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
Cleanup Part 2: Electric Boogaloo (Reloaded) (#594)
* Cleanup Part 2: Electric Boogaloo (Reloaded) * Moar cleanup * Tweak NOT_A_PERMISSION error
This commit is contained in:
committed by
Amish Shah
parent
5a9c42061f
commit
0b908f5bce
@@ -11,7 +11,6 @@ that WebSocket events don't clash with REST methods.
|
||||
*/
|
||||
|
||||
class GenericAction {
|
||||
|
||||
constructor(client) {
|
||||
this.client = client;
|
||||
}
|
||||
@@ -19,7 +18,6 @@ class GenericAction {
|
||||
handle(data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = GenericAction;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class ActionsManager {
|
||||
|
||||
constructor(client) {
|
||||
this.client = client;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const Action = require('./Action');
|
||||
|
||||
class ChannelCreateAction extends Action {
|
||||
|
||||
handle(data) {
|
||||
const client = this.client;
|
||||
const channel = client.dataManager.newChannel(data);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const Action = require('./Action');
|
||||
|
||||
class ChannelDeleteAction extends Action {
|
||||
|
||||
constructor(client) {
|
||||
super(client);
|
||||
this.deleted = new Map();
|
||||
|
||||
@@ -3,7 +3,6 @@ const Constants = require('../../util/Constants');
|
||||
const cloneObject = require('../../util/CloneObject');
|
||||
|
||||
class ChannelUpdateAction extends Action {
|
||||
|
||||
handle(data) {
|
||||
const client = this.client;
|
||||
|
||||
@@ -26,11 +25,10 @@ class ChannelUpdateAction extends Action {
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted whenever a channel is updated - e.g. name change, topic change.
|
||||
*
|
||||
* @event Client#channelUpdate
|
||||
* @param {Channel} oldChannel the channel before the update
|
||||
* @param {Channel} newChannel the channel after the update
|
||||
*/
|
||||
* Emitted whenever a channel is updated - e.g. name change, topic change.
|
||||
* @event Client#channelUpdate
|
||||
* @param {Channel} oldChannel The channel before the update
|
||||
* @param {Channel} newChannel The channel after the update
|
||||
*/
|
||||
|
||||
module.exports = ChannelUpdateAction;
|
||||
|
||||
@@ -2,7 +2,6 @@ const Action = require('./Action');
|
||||
const Constants = require('../../util/Constants');
|
||||
|
||||
class GuildBanRemove extends Action {
|
||||
|
||||
handle(data) {
|
||||
const client = this.client;
|
||||
const guild = client.guilds.get(data.guild_id);
|
||||
|
||||
@@ -2,7 +2,6 @@ const Action = require('./Action');
|
||||
const Constants = require('../../util/Constants');
|
||||
|
||||
class GuildDeleteAction extends Action {
|
||||
|
||||
constructor(client) {
|
||||
super(client);
|
||||
this.deleted = new Map();
|
||||
@@ -45,9 +44,8 @@ class GuildDeleteAction extends Action {
|
||||
|
||||
/**
|
||||
* Emitted whenever a guild becomes unavailable, likely due to a server outage.
|
||||
*
|
||||
* @event Client#guildUnavailable
|
||||
* @param {Guild} guild the guild that has become unavailable.
|
||||
*/
|
||||
* @param {Guild} guild The guild that has become unavailable.
|
||||
*/
|
||||
|
||||
module.exports = GuildDeleteAction;
|
||||
|
||||
@@ -2,7 +2,6 @@ const Action = require('./Action');
|
||||
const Constants = require('../../util/Constants');
|
||||
|
||||
class GuildMemberRemoveAction extends Action {
|
||||
|
||||
constructor(client) {
|
||||
super(client);
|
||||
this.deleted = new Map();
|
||||
@@ -43,10 +42,9 @@ class GuildMemberRemoveAction extends Action {
|
||||
|
||||
/**
|
||||
* Emitted whenever a member leaves a guild, or is kicked.
|
||||
*
|
||||
* @event Client#guildMemberRemove
|
||||
* @param {Guild} guild the guild that the member has left.
|
||||
* @param {GuildMember} member the member that has left the guild.
|
||||
* @param {Guild} guild The guild that the member has left.
|
||||
* @param {GuildMember} member The member that has left the guild.
|
||||
*/
|
||||
|
||||
module.exports = GuildMemberRemoveAction;
|
||||
|
||||
@@ -3,7 +3,6 @@ const Constants = require('../../util/Constants');
|
||||
const Role = require('../../structures/Role');
|
||||
|
||||
class GuildRoleCreate extends Action {
|
||||
|
||||
handle(data) {
|
||||
const client = this.client;
|
||||
|
||||
@@ -25,11 +24,10 @@ class GuildRoleCreate extends Action {
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted whenever a guild role is created.
|
||||
*
|
||||
* @event Client#guildRoleCreate
|
||||
* @param {Guild} guild the guild that the role was created in.
|
||||
* @param {Role} role the role that was created.
|
||||
*/
|
||||
* Emitted whenever a guild role is created.
|
||||
* @event Client#guildRoleCreate
|
||||
* @param {Guild} guild The guild that the role was created in.
|
||||
* @param {Role} role The role that was created.
|
||||
*/
|
||||
|
||||
module.exports = GuildRoleCreate;
|
||||
|
||||
@@ -2,7 +2,6 @@ const Action = require('./Action');
|
||||
const Constants = require('../../util/Constants');
|
||||
|
||||
class GuildRoleDeleteAction extends Action {
|
||||
|
||||
constructor(client) {
|
||||
super(client);
|
||||
this.deleted = new Map();
|
||||
@@ -39,11 +38,10 @@ class GuildRoleDeleteAction extends Action {
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted whenever a guild role is deleted.
|
||||
*
|
||||
* @event Client#guildRoleDelete
|
||||
* @param {Guild} guild the guild that the role was deleted in.
|
||||
* @param {Role} role the role that was deleted.
|
||||
*/
|
||||
* Emitted whenever a guild role is deleted.
|
||||
* @event Client#guildRoleDelete
|
||||
* @param {Guild} guild The guild that the role was deleted in.
|
||||
* @param {Role} role The role that was deleted.
|
||||
*/
|
||||
|
||||
module.exports = GuildRoleDeleteAction;
|
||||
|
||||
@@ -3,7 +3,6 @@ const Constants = require('../../util/Constants');
|
||||
const cloneObject = require('../../util/CloneObject');
|
||||
|
||||
class GuildRoleUpdateAction extends Action {
|
||||
|
||||
handle(data) {
|
||||
const client = this.client;
|
||||
|
||||
@@ -33,12 +32,11 @@ class GuildRoleUpdateAction extends Action {
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted whenever a guild role is updated.
|
||||
*
|
||||
* @event Client#guildRoleUpdated
|
||||
* @param {Guild} guild the guild that the role was updated in.
|
||||
* @param {Role} oldRole the role before the update.
|
||||
* @param {Role} newRole the role after the update.
|
||||
*/
|
||||
* Emitted whenever a guild role is updated.
|
||||
* @event Client#guildRoleUpdated
|
||||
* @param {Guild} guild The guild that the role was updated in.
|
||||
* @param {Role} oldRole The role before the update.
|
||||
* @param {Role} newRole The role after the update.
|
||||
*/
|
||||
|
||||
module.exports = GuildRoleUpdateAction;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const Action = require('./Action');
|
||||
|
||||
class GuildSync extends Action {
|
||||
|
||||
handle(data) {
|
||||
const client = this.client;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ const Constants = require('../../util/Constants');
|
||||
const cloneObject = require('../../util/CloneObject');
|
||||
|
||||
class GuildUpdateAction extends Action {
|
||||
|
||||
handle(data) {
|
||||
const client = this.client;
|
||||
|
||||
@@ -26,11 +25,10 @@ class GuildUpdateAction extends Action {
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted whenever a guild is updated - e.g. name change.
|
||||
*
|
||||
* @event Client#guildUpdate
|
||||
* @param {Guild} oldGuild the guild before the update.
|
||||
* @param {Guild} newGuild the guild after the update.
|
||||
*/
|
||||
* Emitted whenever a guild is updated - e.g. name change.
|
||||
* @event Client#guildUpdate
|
||||
* @param {Guild} oldGuild The guild before the update.
|
||||
* @param {Guild} newGuild The guild after the update.
|
||||
*/
|
||||
|
||||
module.exports = GuildUpdateAction;
|
||||
|
||||
@@ -2,7 +2,6 @@ const Action = require('./Action');
|
||||
const Message = require('../../structures/Message');
|
||||
|
||||
class MessageCreateAction extends Action {
|
||||
|
||||
handle(data) {
|
||||
const client = this.client;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const Action = require('./Action');
|
||||
|
||||
class MessageDeleteAction extends Action {
|
||||
|
||||
constructor(client) {
|
||||
super(client);
|
||||
this.deleted = new Map();
|
||||
|
||||
@@ -3,7 +3,6 @@ const Collection = require('../../util/Collection');
|
||||
const Constants = require('../../util/Constants');
|
||||
|
||||
class MessageDeleteBulkAction extends Action {
|
||||
|
||||
handle(data) {
|
||||
const client = this.client;
|
||||
const channel = client.channels.get(data.channel_id);
|
||||
@@ -12,9 +11,7 @@ class MessageDeleteBulkAction extends Action {
|
||||
const messages = new Collection();
|
||||
for (const id of ids) {
|
||||
const message = channel.messages.get(id);
|
||||
if (message) {
|
||||
messages.set(message.id, message);
|
||||
}
|
||||
if (message) messages.set(message.id, message);
|
||||
}
|
||||
|
||||
if (messages.size > 0) client.emit(Constants.Events.MESSAGE_BULK_DELETE, messages);
|
||||
|
||||
@@ -3,7 +3,6 @@ const Constants = require('../../util/Constants');
|
||||
const cloneObject = require('../../util/CloneObject');
|
||||
|
||||
class MessageUpdateAction extends Action {
|
||||
|
||||
handle(data) {
|
||||
const client = this.client;
|
||||
|
||||
@@ -34,11 +33,10 @@ class MessageUpdateAction extends Action {
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted whenever a message is updated - e.g. embed or content change.
|
||||
*
|
||||
* @event Client#messageUpdate
|
||||
* @param {Message} oldMessage the message before the update.
|
||||
* @param {Message} newMessage the message after the update.
|
||||
*/
|
||||
* Emitted whenever a message is updated - e.g. embed or content change.
|
||||
* @event Client#messageUpdate
|
||||
* @param {Message} oldMessage The message before the update.
|
||||
* @param {Message} newMessage The message after the update.
|
||||
*/
|
||||
|
||||
module.exports = MessageUpdateAction;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const Action = require('./Action');
|
||||
|
||||
class UserGetAction extends Action {
|
||||
|
||||
handle(data) {
|
||||
const client = this.client;
|
||||
const user = client.dataManager.newUser(data);
|
||||
|
||||
@@ -3,7 +3,6 @@ const Constants = require('../../util/Constants');
|
||||
const cloneObject = require('../../util/CloneObject');
|
||||
|
||||
class UserUpdateAction extends Action {
|
||||
|
||||
handle(data) {
|
||||
const client = this.client;
|
||||
|
||||
@@ -32,11 +31,10 @@ class UserUpdateAction extends Action {
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted whenever a detail of the logged in User changes - e.g. username.
|
||||
*
|
||||
* @event Client#userUpdate
|
||||
* @param {ClientUser} oldClientUser the client user before the update.
|
||||
* @param {ClientUser} newClientUser the client user after the update.
|
||||
*/
|
||||
* Emitted whenever a detail of the logged in User changes - e.g. username.
|
||||
* @event Client#userUpdate
|
||||
* @param {ClientUser} oldClientUser The client user before the update.
|
||||
* @param {ClientUser} newClientUser The client user after the update.
|
||||
*/
|
||||
|
||||
module.exports = UserUpdateAction;
|
||||
|
||||
Reference in New Issue
Block a user