Downgrade to v13
[vi] cảm giác đau khổ
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const Partials = require('../../util/Partials');
|
||||
const { PartialTypes } = require('../../util/Constants');
|
||||
|
||||
/*
|
||||
|
||||
@@ -43,7 +43,7 @@ class GenericAction {
|
||||
},
|
||||
this.client.channels,
|
||||
id,
|
||||
Partials.Channel,
|
||||
PartialTypes.CHANNEL,
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class GenericAction {
|
||||
},
|
||||
channel.messages,
|
||||
id,
|
||||
Partials.Message,
|
||||
PartialTypes.MESSAGE,
|
||||
cache,
|
||||
)
|
||||
);
|
||||
@@ -76,17 +76,17 @@ class GenericAction {
|
||||
},
|
||||
message.reactions,
|
||||
id,
|
||||
Partials.Reaction,
|
||||
PartialTypes.REACTION,
|
||||
);
|
||||
}
|
||||
|
||||
getMember(data, guild) {
|
||||
return this.getPayload(data, guild.members, data.user.id, Partials.GuildMember);
|
||||
return this.getPayload(data, guild.members, data.user.id, PartialTypes.GUILD_MEMBER);
|
||||
}
|
||||
|
||||
getUser(data) {
|
||||
const id = data.user_id;
|
||||
return data.user ?? this.getPayload({ id }, this.client.users, id, Partials.User);
|
||||
return data.user ?? this.getPayload({ id }, this.client.users, id, PartialTypes.USER);
|
||||
}
|
||||
|
||||
getUserFromMember(data) {
|
||||
@@ -107,7 +107,7 @@ class GenericAction {
|
||||
{ id, guild_id: data.guild_id ?? guild.id },
|
||||
guild.scheduledEvents,
|
||||
id,
|
||||
Partials.GuildScheduledEvent,
|
||||
PartialTypes.GUILD_SCHEDULED_EVENT,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class ChannelCreateAction extends Action {
|
||||
handle(data) {
|
||||
@@ -14,7 +14,7 @@ class ChannelCreateAction extends Action {
|
||||
* @event Client#channelCreate
|
||||
* @param {GuildChannel} channel The channel that was created
|
||||
*/
|
||||
client.emit(Events.ChannelCreate, channel);
|
||||
client.emit(Events.CHANNEL_CREATE, channel);
|
||||
}
|
||||
return { channel };
|
||||
}
|
||||
|
||||
@@ -1,22 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { deletedChannels } = require('../../structures/Channel');
|
||||
const DMChannel = require('../../structures/DMChannel');
|
||||
const { deletedMessages } = require('../../structures/Message');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class ChannelDeleteAction extends Action {
|
||||
constructor(client) {
|
||||
super(client);
|
||||
this.deleted = new Map();
|
||||
}
|
||||
|
||||
handle(data) {
|
||||
const client = this.client;
|
||||
const channel = client.channels.cache.get(data.id);
|
||||
|
||||
if (channel) {
|
||||
client.channels._remove(channel.id);
|
||||
deletedChannels.add(channel);
|
||||
if (channel.messages && !(channel instanceof DMChannel)) {
|
||||
for (const message of channel.messages.cache.values()) {
|
||||
deletedMessages.add(message);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Emitted whenever a channel is deleted.
|
||||
* @event Client#channelDelete
|
||||
* @param {DMChannel|GuildChannel} channel The channel that was deleted
|
||||
*/
|
||||
client.emit(Events.ChannelDelete, channel);
|
||||
client.emit(Events.CHANNEL_DELETE, channel);
|
||||
}
|
||||
|
||||
return { channel };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const Action = require('./Action');
|
||||
const { Channel } = require('../../structures/Channel');
|
||||
const { ChannelTypes } = require('../../util/Constants');
|
||||
|
||||
class ChannelUpdateAction extends Action {
|
||||
handle(data) {
|
||||
@@ -11,7 +12,7 @@ class ChannelUpdateAction extends Action {
|
||||
if (channel) {
|
||||
const old = channel._update(data);
|
||||
|
||||
if (channel.type !== data.type) {
|
||||
if (ChannelTypes[channel.type] !== data.type) {
|
||||
const newChannel = Channel.create(this.client, data, channel.guild);
|
||||
for (const [id, message] of channel.messages.cache) newChannel.messages.cache.set(id, message);
|
||||
channel = newChannel;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class GuildBanAdd extends Action {
|
||||
handle(data) {
|
||||
@@ -13,7 +13,7 @@ class GuildBanAdd extends Action {
|
||||
* @event Client#guildBanAdd
|
||||
* @param {GuildBan} ban The ban that occurred
|
||||
*/
|
||||
if (guild) client.emit(Events.GuildBanAdd, guild.bans._add(data));
|
||||
if (guild) client.emit(Events.GUILD_BAN_ADD, guild.bans._add(data));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
const Action = require('./Action');
|
||||
const GuildBan = require('../../structures/GuildBan');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class GuildBanRemove extends Action {
|
||||
handle(data) {
|
||||
@@ -17,7 +17,7 @@ class GuildBanRemove extends Action {
|
||||
if (guild) {
|
||||
const ban = guild.bans.cache.get(data.user.id) ?? new GuildBan(client, data, guild);
|
||||
guild.bans.cache.delete(ban.user.id);
|
||||
client.emit(Events.GuildBanRemove, ban);
|
||||
client.emit(Events.GUILD_BAN_REMOVE, ban);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
const { setTimeout } = require('node:timers');
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { deletedGuilds } = require('../../structures/Guild');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class GuildDeleteAction extends Action {
|
||||
constructor(client) {
|
||||
super(client);
|
||||
this.deleted = new Map();
|
||||
}
|
||||
|
||||
handle(data) {
|
||||
const client = this.client;
|
||||
|
||||
@@ -18,11 +25,13 @@ class GuildDeleteAction extends Action {
|
||||
* @event Client#guildUnavailable
|
||||
* @param {Guild} guild The guild that has become unavailable
|
||||
*/
|
||||
client.emit(Events.GuildUnavailable, guild);
|
||||
client.emit(Events.GUILD_UNAVAILABLE, guild);
|
||||
|
||||
// Stops the GuildDelete packet thinking a guild was actually deleted,
|
||||
// handles emitting of event itself
|
||||
return;
|
||||
return {
|
||||
guild: null,
|
||||
};
|
||||
}
|
||||
|
||||
for (const channel of guild.channels.cache.values()) this.client.channels._remove(channel.id);
|
||||
@@ -30,14 +39,26 @@ class GuildDeleteAction extends Action {
|
||||
|
||||
// Delete guild
|
||||
client.guilds.cache.delete(guild.id);
|
||||
deletedGuilds.add(guild);
|
||||
|
||||
/**
|
||||
* Emitted whenever a guild kicks the client or the guild is deleted/left.
|
||||
* @event Client#guildDelete
|
||||
* @param {Guild} guild The guild that was deleted
|
||||
*/
|
||||
client.emit(Events.GuildDelete, guild);
|
||||
client.emit(Events.GUILD_DELETE, guild);
|
||||
|
||||
this.deleted.set(guild.id, guild);
|
||||
this.scheduleForDeletion(guild.id);
|
||||
} else {
|
||||
guild = this.deleted.get(data.id) ?? null;
|
||||
}
|
||||
|
||||
return { guild };
|
||||
}
|
||||
|
||||
scheduleForDeletion(id) {
|
||||
setTimeout(() => this.deleted.delete(id), this.client.options.restWsBridgeTimeout).unref();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class GuildEmojiCreateAction extends Action {
|
||||
handle(guild, createdEmoji) {
|
||||
@@ -12,7 +12,7 @@ class GuildEmojiCreateAction extends Action {
|
||||
* @event Client#emojiCreate
|
||||
* @param {GuildEmoji} emoji The emoji that was created
|
||||
*/
|
||||
if (!already) this.client.emit(Events.GuildEmojiCreate, emoji);
|
||||
if (!already) this.client.emit(Events.GUILD_EMOJI_CREATE, emoji);
|
||||
return { emoji };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { deletedEmojis } = require('../../structures/Emoji');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class GuildEmojiDeleteAction extends Action {
|
||||
handle(emoji) {
|
||||
emoji.guild.emojis.cache.delete(emoji.id);
|
||||
deletedEmojis.add(emoji);
|
||||
/**
|
||||
* Emitted whenever a custom emoji is deleted in a guild.
|
||||
* @event Client#emojiDelete
|
||||
* @param {GuildEmoji} emoji The emoji that was deleted
|
||||
*/
|
||||
this.client.emit(Events.GuildEmojiDelete, emoji);
|
||||
this.client.emit(Events.GUILD_EMOJI_DELETE, emoji);
|
||||
return { emoji };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class GuildEmojiUpdateAction extends Action {
|
||||
handle(current, data) {
|
||||
@@ -12,7 +12,7 @@ class GuildEmojiUpdateAction extends Action {
|
||||
* @param {GuildEmoji} oldEmoji The old emoji
|
||||
* @param {GuildEmoji} newEmoji The new emoji
|
||||
*/
|
||||
this.client.emit(Events.GuildEmojiUpdate, old, current);
|
||||
this.client.emit(Events.GUILD_EMOJI_UPDATE, old, current);
|
||||
return { emoji: current };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class GuildIntegrationsUpdate extends Action {
|
||||
handle(data) {
|
||||
@@ -12,7 +12,7 @@ class GuildIntegrationsUpdate extends Action {
|
||||
* @event Client#guildIntegrationsUpdate
|
||||
* @param {Guild} guild The guild whose integrations were updated
|
||||
*/
|
||||
if (guild) client.emit(Events.GuildIntegrationsUpdate, guild);
|
||||
if (guild) client.emit(Events.GUILD_INTEGRATIONS_UPDATE, guild);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const Status = require('../../util/Status');
|
||||
const { deletedGuildMembers } = require('../../structures/GuildMember');
|
||||
const { Events, Status } = require('../../util/Constants');
|
||||
|
||||
class GuildMemberRemoveAction extends Action {
|
||||
handle(data, shard) {
|
||||
@@ -13,13 +13,14 @@ class GuildMemberRemoveAction extends Action {
|
||||
member = this.getMember({ user: data.user }, guild);
|
||||
guild.memberCount--;
|
||||
if (member) {
|
||||
deletedGuildMembers.add(member);
|
||||
guild.members.cache.delete(member.id);
|
||||
/**
|
||||
* Emitted whenever a member leaves a guild, or is kicked.
|
||||
* @event Client#guildMemberRemove
|
||||
* @param {GuildMember} member The member that has left/been kicked from the guild
|
||||
*/
|
||||
if (shard.status === Status.Ready) client.emit(Events.GuildMemberRemove, member);
|
||||
if (shard.status === Status.READY) client.emit(Events.GUILD_MEMBER_REMOVE, member);
|
||||
}
|
||||
guild.voiceStates.cache.delete(data.user.id);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const Status = require('../../util/Status');
|
||||
const { Status, Events } = require('../../util/Constants');
|
||||
|
||||
class GuildMemberUpdateAction extends Action {
|
||||
handle(data, shard) {
|
||||
@@ -27,7 +26,7 @@ class GuildMemberUpdateAction extends Action {
|
||||
* @param {GuildMember} oldMember The member before the update
|
||||
* @param {GuildMember} newMember The member after the update
|
||||
*/
|
||||
if (shard.status === Status.Ready && !member.equals(old)) client.emit(Events.GuildMemberUpdate, old, member);
|
||||
if (shard.status === Status.READY && !member.equals(old)) client.emit(Events.GUILD_MEMBER_UPDATE, old, member);
|
||||
} else {
|
||||
const newMember = guild.members._add(data);
|
||||
/**
|
||||
@@ -35,7 +34,7 @@ class GuildMemberUpdateAction extends Action {
|
||||
* @event Client#guildMemberAvailable
|
||||
* @param {GuildMember} member The member that became available
|
||||
*/
|
||||
this.client.emit(Events.GuildMemberAvailable, newMember);
|
||||
this.client.emit(Events.GUILD_MEMBER_AVAILABLE, newMember);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class GuildRoleCreate extends Action {
|
||||
handle(data) {
|
||||
@@ -16,7 +16,7 @@ class GuildRoleCreate extends Action {
|
||||
* @event Client#roleCreate
|
||||
* @param {Role} role The role that was created
|
||||
*/
|
||||
if (!already) client.emit(Events.GuildRoleCreate, role);
|
||||
if (!already) client.emit(Events.GUILD_ROLE_CREATE, role);
|
||||
}
|
||||
return { role };
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { deletedRoles } = require('../../structures/Role');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class GuildRoleDeleteAction extends Action {
|
||||
handle(data) {
|
||||
@@ -13,12 +14,13 @@ class GuildRoleDeleteAction extends Action {
|
||||
role = guild.roles.cache.get(data.role_id);
|
||||
if (role) {
|
||||
guild.roles.cache.delete(data.role_id);
|
||||
deletedRoles.add(role);
|
||||
/**
|
||||
* Emitted whenever a guild role is deleted.
|
||||
* @event Client#roleDelete
|
||||
* @param {Role} role The role that was deleted
|
||||
*/
|
||||
client.emit(Events.GuildRoleDelete, role);
|
||||
client.emit(Events.GUILD_ROLE_DELETE, role);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class GuildRoleUpdateAction extends Action {
|
||||
handle(data) {
|
||||
@@ -20,7 +20,7 @@ class GuildRoleUpdateAction extends Action {
|
||||
* @param {Role} oldRole The role before the update
|
||||
* @param {Role} newRole The role after the update
|
||||
*/
|
||||
client.emit(Events.GuildRoleUpdate, old, role);
|
||||
client.emit(Events.GUILD_ROLE_UPDATE, old, role);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class GuildScheduledEventCreateAction extends Action {
|
||||
handle(data) {
|
||||
@@ -15,7 +15,7 @@ class GuildScheduledEventCreateAction extends Action {
|
||||
* @event Client#guildScheduledEventCreate
|
||||
* @param {GuildScheduledEvent} guildScheduledEvent The created guild scheduled event
|
||||
*/
|
||||
client.emit(Events.GuildScheduledEventCreate, guildScheduledEvent);
|
||||
client.emit(Events.GUILD_SCHEDULED_EVENT_CREATE, guildScheduledEvent);
|
||||
|
||||
return { guildScheduledEvent };
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class GuildScheduledEventDeleteAction extends Action {
|
||||
handle(data) {
|
||||
@@ -18,7 +18,7 @@ class GuildScheduledEventDeleteAction extends Action {
|
||||
* @event Client#guildScheduledEventDelete
|
||||
* @param {GuildScheduledEvent} guildScheduledEvent The deleted guild scheduled event
|
||||
*/
|
||||
client.emit(Events.GuildScheduledEventDelete, guildScheduledEvent);
|
||||
client.emit(Events.GUILD_SCHEDULED_EVENT_DELETE, guildScheduledEvent);
|
||||
|
||||
return { guildScheduledEvent };
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class GuildScheduledEventUpdateAction extends Action {
|
||||
handle(data) {
|
||||
@@ -18,7 +18,7 @@ class GuildScheduledEventUpdateAction extends Action {
|
||||
* @param {?GuildScheduledEvent} oldGuildScheduledEvent The guild scheduled event object before the update
|
||||
* @param {GuildScheduledEvent} newGuildScheduledEvent The guild scheduled event object after the update
|
||||
*/
|
||||
client.emit(Events.GuildScheduledEventUpdate, oldGuildScheduledEvent, newGuildScheduledEvent);
|
||||
client.emit(Events.GUILD_SCHEDULED_EVENT_UPDATE, oldGuildScheduledEvent, newGuildScheduledEvent);
|
||||
|
||||
return { oldGuildScheduledEvent, newGuildScheduledEvent };
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class GuildScheduledEventUserAddAction extends Action {
|
||||
handle(data) {
|
||||
@@ -19,7 +19,7 @@ class GuildScheduledEventUserAddAction extends Action {
|
||||
* @param {GuildScheduledEvent} guildScheduledEvent The guild scheduled event
|
||||
* @param {User} user The user who subscribed
|
||||
*/
|
||||
client.emit(Events.GuildScheduledEventUserAdd, guildScheduledEvent, user);
|
||||
client.emit(Events.GUILD_SCHEDULED_EVENT_USER_ADD, guildScheduledEvent, user);
|
||||
|
||||
return { guildScheduledEvent, user };
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class GuildScheduledEventUserRemoveAction extends Action {
|
||||
handle(data) {
|
||||
@@ -19,7 +19,7 @@ class GuildScheduledEventUserRemoveAction extends Action {
|
||||
* @param {GuildScheduledEvent} guildScheduledEvent The guild scheduled event
|
||||
* @param {User} user The user who unsubscribed
|
||||
*/
|
||||
client.emit(Events.GuildScheduledEventUserRemove, guildScheduledEvent, user);
|
||||
client.emit(Events.GUILD_SCHEDULED_EVENT_USER_REMOVE, guildScheduledEvent, user);
|
||||
|
||||
return { guildScheduledEvent, user };
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class GuildStickerCreateAction extends Action {
|
||||
handle(guild, createdSticker) {
|
||||
@@ -12,7 +12,7 @@ class GuildStickerCreateAction extends Action {
|
||||
* @event Client#stickerCreate
|
||||
* @param {Sticker} sticker The sticker that was created
|
||||
*/
|
||||
if (!already) this.client.emit(Events.GuildStickerCreate, sticker);
|
||||
if (!already) this.client.emit(Events.GUILD_STICKER_CREATE, sticker);
|
||||
return { sticker };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { deletedStickers } = require('../../structures/Sticker');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class GuildStickerDeleteAction extends Action {
|
||||
handle(sticker) {
|
||||
sticker.guild.stickers.cache.delete(sticker.id);
|
||||
deletedStickers.add(sticker);
|
||||
/**
|
||||
* Emitted whenever a custom sticker is deleted in a guild.
|
||||
* @event Client#stickerDelete
|
||||
* @param {Sticker} sticker The sticker that was deleted
|
||||
*/
|
||||
this.client.emit(Events.GuildStickerDelete, sticker);
|
||||
this.client.emit(Events.GUILD_STICKER_DELETE, sticker);
|
||||
return { sticker };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class GuildStickerUpdateAction extends Action {
|
||||
handle(current, data) {
|
||||
@@ -12,7 +12,7 @@ class GuildStickerUpdateAction extends Action {
|
||||
* @param {Sticker} oldSticker The old sticker
|
||||
* @param {Sticker} newSticker The new sticker
|
||||
*/
|
||||
this.client.emit(Events.GuildStickerUpdate, old, current);
|
||||
this.client.emit(Events.GUILD_STICKER_UPDATE, old, current);
|
||||
return { sticker: current };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class GuildUpdateAction extends Action {
|
||||
handle(data) {
|
||||
@@ -16,7 +16,7 @@ class GuildUpdateAction extends Action {
|
||||
* @param {Guild} oldGuild The guild before the update
|
||||
* @param {Guild} newGuild The guild after the update
|
||||
*/
|
||||
client.emit(Events.GuildUpdate, old, guild);
|
||||
client.emit(Events.GUILD_UPDATE, old, guild);
|
||||
return {
|
||||
old,
|
||||
updated: guild,
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
const { InteractionType, ComponentType, ApplicationCommandType } = require('discord-api-types/v9');
|
||||
const process = require('node:process');
|
||||
const Action = require('./Action');
|
||||
const AutocompleteInteraction = require('../../structures/AutocompleteInteraction');
|
||||
const ButtonInteraction = require('../../structures/ButtonInteraction');
|
||||
const ChatInputCommandInteraction = require('../../structures/ChatInputCommandInteraction');
|
||||
const MessageContextMenuCommandInteraction = require('../../structures/MessageContextMenuCommandInteraction');
|
||||
const CommandInteraction = require('../../structures/CommandInteraction');
|
||||
const MessageContextMenuInteraction = require('../../structures/MessageContextMenuInteraction');
|
||||
const SelectMenuInteraction = require('../../structures/SelectMenuInteraction');
|
||||
const UserContextMenuCommandInteraction = require('../../structures/UserContextMenuCommandInteraction');
|
||||
const Events = require('../../util/Events');
|
||||
const UserContextMenuInteraction = require('../../structures/UserContextMenuInteraction');
|
||||
const { Events, InteractionTypes, MessageComponentTypes, ApplicationCommandTypes } = require('../../util/Constants');
|
||||
|
||||
let deprecationEmitted = false;
|
||||
|
||||
class InteractionCreateAction extends Action {
|
||||
handle(data) {
|
||||
@@ -17,59 +19,70 @@ class InteractionCreateAction extends Action {
|
||||
// Resolve and cache partial channels for Interaction#channel getter
|
||||
this.getChannel(data);
|
||||
|
||||
let InteractionClass;
|
||||
let InteractionType;
|
||||
switch (data.type) {
|
||||
case InteractionType.ApplicationCommand:
|
||||
case InteractionTypes.APPLICATION_COMMAND:
|
||||
switch (data.data.type) {
|
||||
case ApplicationCommandType.ChatInput:
|
||||
InteractionClass = ChatInputCommandInteraction;
|
||||
case ApplicationCommandTypes.CHAT_INPUT:
|
||||
InteractionType = CommandInteraction;
|
||||
break;
|
||||
case ApplicationCommandType.User:
|
||||
InteractionClass = UserContextMenuCommandInteraction;
|
||||
case ApplicationCommandTypes.USER:
|
||||
InteractionType = UserContextMenuInteraction;
|
||||
break;
|
||||
case ApplicationCommandType.Message:
|
||||
InteractionClass = MessageContextMenuCommandInteraction;
|
||||
case ApplicationCommandTypes.MESSAGE:
|
||||
InteractionType = MessageContextMenuInteraction;
|
||||
break;
|
||||
default:
|
||||
client.emit(
|
||||
Events.Debug,
|
||||
Events.DEBUG,
|
||||
`[INTERACTION] Received application command interaction with unknown type: ${data.data.type}`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case InteractionType.MessageComponent:
|
||||
case InteractionTypes.MESSAGE_COMPONENT:
|
||||
switch (data.data.component_type) {
|
||||
case ComponentType.Button:
|
||||
InteractionClass = ButtonInteraction;
|
||||
case MessageComponentTypes.BUTTON:
|
||||
InteractionType = ButtonInteraction;
|
||||
break;
|
||||
case ComponentType.SelectMenu:
|
||||
InteractionClass = SelectMenuInteraction;
|
||||
case MessageComponentTypes.SELECT_MENU:
|
||||
InteractionType = SelectMenuInteraction;
|
||||
break;
|
||||
default:
|
||||
client.emit(
|
||||
Events.Debug,
|
||||
Events.DEBUG,
|
||||
`[INTERACTION] Received component interaction with unknown type: ${data.data.component_type}`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case InteractionType.ApplicationCommandAutocomplete:
|
||||
InteractionClass = AutocompleteInteraction;
|
||||
case InteractionTypes.APPLICATION_COMMAND_AUTOCOMPLETE:
|
||||
InteractionType = AutocompleteInteraction;
|
||||
break;
|
||||
default:
|
||||
client.emit(Events.Debug, `[INTERACTION] Received interaction with unknown type: ${data.type}`);
|
||||
client.emit(Events.DEBUG, `[INTERACTION] Received interaction with unknown type: ${data.type}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const interaction = new InteractionClass(client, data);
|
||||
const interaction = new InteractionType(client, data);
|
||||
|
||||
/**
|
||||
* Emitted when an interaction is created.
|
||||
* @event Client#interactionCreate
|
||||
* @param {Interaction} interaction The interaction which was created
|
||||
*/
|
||||
client.emit(Events.InteractionCreate, interaction);
|
||||
client.emit(Events.INTERACTION_CREATE, interaction);
|
||||
|
||||
/**
|
||||
* Emitted when an interaction is created.
|
||||
* @event Client#interaction
|
||||
* @param {Interaction} interaction The interaction which was created
|
||||
* @deprecated Use {@link Client#event:interactionCreate} instead
|
||||
*/
|
||||
if (client.emit('interaction', interaction) && !deprecationEmitted) {
|
||||
deprecationEmitted = true;
|
||||
process.emitWarning('The interaction event is deprecated. Use interactionCreate instead', 'DeprecationWarning');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class InviteCreateAction extends Action {
|
||||
handle(data) {
|
||||
@@ -20,7 +20,7 @@ class InviteCreateAction extends Action {
|
||||
* @event Client#inviteCreate
|
||||
* @param {Invite} invite The invite that was created
|
||||
*/
|
||||
client.emit(Events.InviteCreate, invite);
|
||||
client.emit(Events.INVITE_CREATE, invite);
|
||||
return { invite };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
const Action = require('./Action');
|
||||
const Invite = require('../../structures/Invite');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class InviteDeleteAction extends Action {
|
||||
handle(data) {
|
||||
@@ -22,7 +22,7 @@ class InviteDeleteAction extends Action {
|
||||
* @event Client#inviteDelete
|
||||
* @param {Invite} invite The invite that was deleted
|
||||
*/
|
||||
client.emit(Events.InviteDelete, invite);
|
||||
client.emit(Events.INVITE_DELETE, invite);
|
||||
return { invite };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
const process = require('node:process');
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
let deprecationEmitted = false;
|
||||
|
||||
class MessageCreateAction extends Action {
|
||||
handle(data) {
|
||||
const client = this.client;
|
||||
const channel = this.getChannel(data);
|
||||
if (channel) {
|
||||
if (!channel.isTextBased()) return {};
|
||||
if (!channel.isText()) return {};
|
||||
|
||||
const existing = channel.messages.cache.get(data.id);
|
||||
if (existing) return { message: existing };
|
||||
@@ -20,7 +23,18 @@ class MessageCreateAction extends Action {
|
||||
* @event Client#messageCreate
|
||||
* @param {Message} message The created message
|
||||
*/
|
||||
client.emit(Events.MessageCreate, message);
|
||||
client.emit(Events.MESSAGE_CREATE, message);
|
||||
|
||||
/**
|
||||
* Emitted whenever a message is created.
|
||||
* @event Client#message
|
||||
* @param {Message} message The created message
|
||||
* @deprecated Use {@link Client#event:messageCreate} instead
|
||||
*/
|
||||
if (client.emit('message', message) && !deprecationEmitted) {
|
||||
deprecationEmitted = true;
|
||||
process.emitWarning('The message event is deprecated. Use messageCreate instead', 'DeprecationWarning');
|
||||
}
|
||||
|
||||
return { message };
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { deletedMessages } = require('../../structures/Message');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class MessageDeleteAction extends Action {
|
||||
handle(data) {
|
||||
@@ -9,17 +10,18 @@ class MessageDeleteAction extends Action {
|
||||
const channel = this.getChannel(data);
|
||||
let message;
|
||||
if (channel) {
|
||||
if (!channel.isTextBased()) return {};
|
||||
if (!channel.isText()) return {};
|
||||
|
||||
message = this.getMessage(data, channel);
|
||||
if (message) {
|
||||
channel.messages.cache.delete(message.id);
|
||||
deletedMessages.add(message);
|
||||
/**
|
||||
* Emitted whenever a message is deleted.
|
||||
* @event Client#messageDelete
|
||||
* @param {Message} message The deleted message
|
||||
*/
|
||||
client.emit(Events.MessageDelete, message);
|
||||
client.emit(Events.MESSAGE_DELETE, message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { deletedMessages } = require('../../structures/Message');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class MessageDeleteBulkAction extends Action {
|
||||
handle(data) {
|
||||
@@ -10,7 +11,7 @@ class MessageDeleteBulkAction extends Action {
|
||||
const channel = client.channels.cache.get(data.channel_id);
|
||||
|
||||
if (channel) {
|
||||
if (!channel.isTextBased()) return {};
|
||||
if (!channel.isText()) return {};
|
||||
|
||||
const ids = data.ids;
|
||||
const messages = new Collection();
|
||||
@@ -24,6 +25,7 @@ class MessageDeleteBulkAction extends Action {
|
||||
false,
|
||||
);
|
||||
if (message) {
|
||||
deletedMessages.add(message);
|
||||
messages.set(message.id, message);
|
||||
channel.messages.cache.delete(id);
|
||||
}
|
||||
@@ -34,7 +36,7 @@ class MessageDeleteBulkAction extends Action {
|
||||
* @event Client#messageDeleteBulk
|
||||
* @param {Collection<Snowflake, Message>} messages The deleted messages, mapped by their id
|
||||
*/
|
||||
if (messages.size > 0) client.emit(Events.MessageBulkDelete, messages);
|
||||
if (messages.size > 0) client.emit(Events.MESSAGE_BULK_DELETE, messages);
|
||||
return { messages };
|
||||
}
|
||||
return {};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const Partials = require('../../util/Partials');
|
||||
const { Events } = require('../../util/Constants');
|
||||
const { PartialTypes } = require('../../util/Constants');
|
||||
|
||||
/*
|
||||
{ user_id: 'id',
|
||||
@@ -23,14 +23,14 @@ class MessageReactionAdd extends Action {
|
||||
|
||||
// Verify channel
|
||||
const channel = this.getChannel(data);
|
||||
if (!channel?.isTextBased()) return false;
|
||||
if (!channel || !channel.isText()) return false;
|
||||
|
||||
// Verify message
|
||||
const message = this.getMessage(data, channel);
|
||||
if (!message) return false;
|
||||
|
||||
// Verify reaction
|
||||
const includePartial = this.client.options.partials.includes(Partials.Reaction);
|
||||
const includePartial = this.client.options.partials.includes(PartialTypes.REACTION);
|
||||
if (message.partial && !includePartial) return false;
|
||||
const reaction = message.reactions._add({
|
||||
emoji: data.emoji,
|
||||
@@ -46,7 +46,7 @@ class MessageReactionAdd extends Action {
|
||||
* @param {MessageReaction} messageReaction The reaction object
|
||||
* @param {User} user The user that applied the guild or reaction emoji
|
||||
*/
|
||||
this.client.emit(Events.MessageReactionAdd, reaction, user);
|
||||
this.client.emit(Events.MESSAGE_REACTION_ADD, reaction, user);
|
||||
|
||||
return { message, reaction, user };
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
/*
|
||||
{ user_id: 'id',
|
||||
@@ -20,7 +20,7 @@ class MessageReactionRemove extends Action {
|
||||
|
||||
// Verify channel
|
||||
const channel = this.getChannel(data);
|
||||
if (!channel?.isTextBased()) return false;
|
||||
if (!channel || !channel.isText()) return false;
|
||||
|
||||
// Verify message
|
||||
const message = this.getMessage(data, channel);
|
||||
@@ -36,7 +36,7 @@ class MessageReactionRemove extends Action {
|
||||
* @param {MessageReaction} messageReaction The reaction object
|
||||
* @param {User} user The user whose emoji or reaction emoji was removed
|
||||
*/
|
||||
this.client.emit(Events.MessageReactionRemove, reaction, user);
|
||||
this.client.emit(Events.MESSAGE_REACTION_REMOVE, reaction, user);
|
||||
|
||||
return { message, reaction, user };
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class MessageReactionRemoveAll extends Action {
|
||||
handle(data) {
|
||||
// Verify channel
|
||||
const channel = this.getChannel(data);
|
||||
if (!channel?.isTextBased()) return false;
|
||||
if (!channel || !channel.isText()) return false;
|
||||
|
||||
// Verify message
|
||||
const message = this.getMessage(data, channel);
|
||||
@@ -17,7 +17,7 @@ class MessageReactionRemoveAll extends Action {
|
||||
const removed = message.reactions.cache.clone();
|
||||
|
||||
message.reactions.cache.clear();
|
||||
this.client.emit(Events.MessageReactionRemoveAll, message, removed);
|
||||
this.client.emit(Events.MESSAGE_REACTION_REMOVE_ALL, message, removed);
|
||||
|
||||
return { message };
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class MessageReactionRemoveEmoji extends Action {
|
||||
handle(data) {
|
||||
const channel = this.getChannel(data);
|
||||
if (!channel?.isTextBased()) return false;
|
||||
if (!channel || !channel.isText()) return false;
|
||||
|
||||
const message = this.getMessage(data, channel);
|
||||
if (!message) return false;
|
||||
@@ -20,7 +20,7 @@ class MessageReactionRemoveEmoji extends Action {
|
||||
* @event Client#messageReactionRemoveEmoji
|
||||
* @param {MessageReaction} reaction The reaction that was removed
|
||||
*/
|
||||
this.client.emit(Events.MessageReactionRemoveEmoji, reaction);
|
||||
this.client.emit(Events.MESSAGE_REACTION_REMOVE_EMOJI, reaction);
|
||||
return { reaction };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ class MessageUpdateAction extends Action {
|
||||
handle(data) {
|
||||
const channel = this.getChannel(data);
|
||||
if (channel) {
|
||||
if (!channel.isTextBased()) return {};
|
||||
if (!channel.isText()) return {};
|
||||
|
||||
const { id, channel_id, guild_id, author, timestamp, type } = data;
|
||||
const message = this.getMessage({ id, channel_id, guild_id, author, timestamp, type }, channel);
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class PresenceUpdateAction extends Action {
|
||||
handle(data) {
|
||||
let user = this.client.users.cache.get(data.user.id);
|
||||
if (!user && data.user.username) user = this.client.users._add(data.user);
|
||||
if (!user && data.user?.username) user = this.client.users._add(data.user);
|
||||
if (!user) return;
|
||||
|
||||
if (data.user.username) {
|
||||
if (data.user?.username) {
|
||||
if (!user._equals(data.user)) this.client.actions.UserUpdate.handle(data.user);
|
||||
}
|
||||
|
||||
@@ -24,17 +24,17 @@ class PresenceUpdateAction extends Action {
|
||||
deaf: false,
|
||||
mute: false,
|
||||
});
|
||||
this.client.emit(Events.GuildMemberAvailable, member);
|
||||
this.client.emit(Events.GUILD_MEMBER_AVAILABLE, member);
|
||||
}
|
||||
const newPresence = guild.presences._add(Object.assign(data, { guild }));
|
||||
if (this.client.listenerCount(Events.PresenceUpdate) && !newPresence.equals(oldPresence)) {
|
||||
if (this.client.listenerCount(Events.PRESENCE_UPDATE) && !newPresence.equals(oldPresence)) {
|
||||
/**
|
||||
* Emitted whenever a guild member's presence (e.g. status, activity) is changed.
|
||||
* @event Client#presenceUpdate
|
||||
* @param {?Presence} oldPresence The presence before the update, if one at all
|
||||
* @param {Presence} newPresence The presence after the update
|
||||
*/
|
||||
this.client.emit(Events.PresenceUpdate, oldPresence, newPresence);
|
||||
this.client.emit(Events.PRESENCE_UPDATE, oldPresence, newPresence);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class StageInstanceCreateAction extends Action {
|
||||
handle(data) {
|
||||
@@ -16,7 +16,7 @@ class StageInstanceCreateAction extends Action {
|
||||
* @event Client#stageInstanceCreate
|
||||
* @param {StageInstance} stageInstance The created stage instance
|
||||
*/
|
||||
client.emit(Events.StageInstanceCreate, stageInstance);
|
||||
client.emit(Events.STAGE_INSTANCE_CREATE, stageInstance);
|
||||
|
||||
return { stageInstance };
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { deletedStageInstances } = require('../../structures/StageInstance');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class StageInstanceDeleteAction extends Action {
|
||||
handle(data) {
|
||||
@@ -12,13 +13,14 @@ class StageInstanceDeleteAction extends Action {
|
||||
const stageInstance = channel.guild.stageInstances._add(data);
|
||||
if (stageInstance) {
|
||||
channel.guild.stageInstances.cache.delete(stageInstance.id);
|
||||
deletedStageInstances.add(stageInstance);
|
||||
|
||||
/**
|
||||
* Emitted whenever a stage instance is deleted.
|
||||
* @event Client#stageInstanceDelete
|
||||
* @param {StageInstance} stageInstance The deleted stage instance
|
||||
*/
|
||||
client.emit(Events.StageInstanceDelete, stageInstance);
|
||||
client.emit(Events.STAGE_INSTANCE_DELETE, stageInstance);
|
||||
|
||||
return { stageInstance };
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class StageInstanceUpdateAction extends Action {
|
||||
handle(data) {
|
||||
@@ -18,7 +18,7 @@ class StageInstanceUpdateAction extends Action {
|
||||
* @param {?StageInstance} oldStageInstance The stage instance before the update
|
||||
* @param {StageInstance} newStageInstance The stage instance after the update
|
||||
*/
|
||||
client.emit(Events.StageInstanceUpdate, oldStageInstance, newStageInstance);
|
||||
client.emit(Events.STAGE_INSTANCE_UPDATE, oldStageInstance, newStageInstance);
|
||||
|
||||
return { oldStageInstance, newStageInstance };
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class ThreadCreateAction extends Action {
|
||||
handle(data) {
|
||||
@@ -13,9 +13,8 @@ class ThreadCreateAction extends Action {
|
||||
* Emitted whenever a thread is created or when the client user is added to a thread.
|
||||
* @event Client#threadCreate
|
||||
* @param {ThreadChannel} thread The thread that was created
|
||||
* @param {boolean} newlyCreated Whether the thread was newly created
|
||||
*/
|
||||
client.emit(Events.ThreadCreate, thread, data.newly_created ?? false);
|
||||
client.emit(Events.THREAD_CREATE, thread);
|
||||
}
|
||||
return { thread };
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { deletedChannels } = require('../../structures/Channel');
|
||||
const { deletedMessages } = require('../../structures/Message');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class ThreadDeleteAction extends Action {
|
||||
handle(data) {
|
||||
@@ -10,13 +12,17 @@ class ThreadDeleteAction extends Action {
|
||||
|
||||
if (thread) {
|
||||
client.channels._remove(thread.id);
|
||||
deletedChannels.add(thread);
|
||||
for (const message of thread.messages.cache.values()) {
|
||||
deletedMessages.add(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted whenever a thread is deleted.
|
||||
* @event Client#threadDelete
|
||||
* @param {ThreadChannel} thread The thread that was deleted
|
||||
*/
|
||||
client.emit(Events.ThreadDelete, thread);
|
||||
client.emit(Events.THREAD_DELETE, thread);
|
||||
}
|
||||
|
||||
return { thread };
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class ThreadListSyncAction extends Action {
|
||||
handle(data) {
|
||||
@@ -40,7 +40,7 @@ class ThreadListSyncAction extends Action {
|
||||
* @event Client#threadListSync
|
||||
* @param {Collection<Snowflake, ThreadChannel>} threads The threads that were synced
|
||||
*/
|
||||
client.emit(Events.ThreadListSync, syncedThreads);
|
||||
client.emit(Events.THREAD_LIST_SYNC, syncedThreads);
|
||||
|
||||
return {
|
||||
syncedThreads,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class ThreadMemberUpdateAction extends Action {
|
||||
handle(data) {
|
||||
@@ -21,7 +21,7 @@ class ThreadMemberUpdateAction extends Action {
|
||||
* @param {ThreadMember} oldMember The member before the update
|
||||
* @param {ThreadMember} newMember The member after the update
|
||||
*/
|
||||
client.emit(Events.ThreadMemberUpdate, old, member);
|
||||
client.emit(Events.THREAD_MEMBER_UPDATE, old, member);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class ThreadMembersUpdateAction extends Action {
|
||||
handle(data) {
|
||||
@@ -25,7 +25,7 @@ class ThreadMembersUpdateAction extends Action {
|
||||
* @param {Collection<Snowflake, ThreadMember>} oldMembers The members before the update
|
||||
* @param {Collection<Snowflake, ThreadMember>} newMembers The members after the update
|
||||
*/
|
||||
client.emit(Events.ThreadMembersUpdate, old, thread.members.cache);
|
||||
client.emit(Events.THREAD_MEMBERS_UPDATE, old, thread.members.cache);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
const Action = require('./Action');
|
||||
const Typing = require('../../structures/Typing');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class TypingStart extends Action {
|
||||
handle(data) {
|
||||
const channel = this.getChannel(data);
|
||||
if (!channel) return;
|
||||
|
||||
if (!channel.isTextBased()) {
|
||||
this.client.emit(Events.Warn, `Discord sent a typing packet to a ${channel.type} channel ${channel.id}`);
|
||||
if (!channel.isText()) {
|
||||
this.client.emit(Events.WARN, `Discord sent a typing packet to a ${channel.type} channel ${channel.id}`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class TypingStart extends Action {
|
||||
* @event Client#typingStart
|
||||
* @param {Typing} typing The typing state
|
||||
*/
|
||||
this.client.emit(Events.TypingStart, new Typing(channel, user, data));
|
||||
this.client.emit(Events.TYPING_START, new Typing(channel, user, data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class UserUpdateAction extends Action {
|
||||
handle(data) {
|
||||
@@ -18,7 +18,7 @@ class UserUpdateAction extends Action {
|
||||
* @param {User} oldUser The user before the update
|
||||
* @param {User} newUser The user after the update
|
||||
*/
|
||||
client.emit(Events.UserUpdate, oldUser, newUser);
|
||||
client.emit(Events.USER_UPDATE, oldUser, newUser);
|
||||
return {
|
||||
old: oldUser,
|
||||
updated: newUser,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
const Action = require('./Action');
|
||||
const VoiceState = require('../../structures/VoiceState');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class VoiceStateUpdate extends Action {
|
||||
handle(data) {
|
||||
@@ -35,7 +35,7 @@ class VoiceStateUpdate extends Action {
|
||||
* @param {VoiceState} oldState The voice state before the update
|
||||
* @param {VoiceState} newState The voice state after the update
|
||||
*/
|
||||
client.emit(Events.VoiceStateUpdate, oldState, newState);
|
||||
client.emit(Events.VOICE_STATE_UPDATE, oldState, newState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class WebhooksUpdate extends Action {
|
||||
handle(data) {
|
||||
@@ -12,7 +12,7 @@ class WebhooksUpdate extends Action {
|
||||
* @event Client#webhookUpdate
|
||||
* @param {TextChannel|NewsChannel} channel The channel that had a webhook update
|
||||
*/
|
||||
if (channel) client.emit(Events.WebhooksUpdate, channel);
|
||||
if (channel) client.emit(Events.WEBHOOKS_UPDATE, channel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user