mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
refactor: remove unnecessary checks (#6777)
This commit is contained in:
@@ -7,16 +7,15 @@ const { Events, TextBasedChannelTypes } = require('../../util/Constants');
|
||||
class TypingStart extends Action {
|
||||
handle(data) {
|
||||
const channel = this.getChannel(data);
|
||||
if (!channel) {
|
||||
return;
|
||||
}
|
||||
if (!channel) return;
|
||||
|
||||
if (!TextBasedChannelTypes.includes(channel.type)) {
|
||||
this.client.emit(Events.WARN, `Discord sent a typing packet to a ${channel.type} channel ${channel.id}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const user = this.getUserFromMember(data);
|
||||
if (channel && user) {
|
||||
if (user) {
|
||||
/**
|
||||
* Emitted whenever a user starts typing in a channel.
|
||||
* @event Client#typingStart
|
||||
|
||||
@@ -4,11 +4,11 @@ const { Events } = require('../../../util/Constants');
|
||||
|
||||
module.exports = (client, { d: data }) => {
|
||||
const channel = client.channels.cache.get(data.channel_id);
|
||||
const time = new Date(data.last_pin_timestamp);
|
||||
const time = data.last_pin_timestamp ? new Date(data.last_pin_timestamp).getTime() : null;
|
||||
|
||||
if (channel && !Number.isNaN(time.getTime())) {
|
||||
if (channel) {
|
||||
// Discord sends null for last_pin_timestamp if the last pinned message was removed
|
||||
channel.lastPinTimestamp = time.getTime() ?? null;
|
||||
channel.lastPinTimestamp = time;
|
||||
|
||||
/**
|
||||
* Emitted whenever the pins of a channel are updated. Due to the nature of the WebSocket event,
|
||||
|
||||
@@ -57,8 +57,9 @@ class GuildStickerManager extends CachedManager {
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async create(file, name, tags, { description, reason } = {}) {
|
||||
file = { ...(await MessagePayload.resolveFile(file)), key: 'file' };
|
||||
if (!file) throw new TypeError('REQ_RESOURCE_TYPE');
|
||||
const resolvedFile = await MessagePayload.resolveFile(file);
|
||||
if (!resolvedFile) throw new TypeError('REQ_RESOURCE_TYPE');
|
||||
file = { ...resolvedFile, key: 'file' };
|
||||
|
||||
const data = { name, tags, description: description ?? '' };
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class Channel extends Base {
|
||||
constructor(client, data, immediatePatch = true) {
|
||||
super(client);
|
||||
|
||||
const type = ChannelTypes[data.type];
|
||||
const type = ChannelTypes[data?.type];
|
||||
/**
|
||||
* The type of the channel
|
||||
* @type {ChannelType}
|
||||
|
||||
@@ -45,7 +45,7 @@ class Message extends Base {
|
||||
*/
|
||||
this.deleted = false;
|
||||
|
||||
if (data) this._patch(data);
|
||||
this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
|
||||
Reference in New Issue
Block a user