mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
fix(Message): #system non-zero message types are not guaranteed to be system (#5108)
* fix(Message): #system not all nonzero message types are system * feat(Message): introduce system message types * refactor(Constants): change SystemMessageTypes to be exclusionary * fix(Constants): only need to check if type exists Co-authored-by: Jan <66554238+Vaporox@users.noreply.github.com> * fix(Constants): lint * fix(Typings): add SystemMessageTypees to Constants Co-authored-by: Jan <66554238+Vaporox@users.noreply.github.com>
This commit is contained in:
@@ -10,7 +10,7 @@ const ReactionCollector = require('./ReactionCollector');
|
||||
const { Error, TypeError } = require('../errors');
|
||||
const ReactionManager = require('../managers/ReactionManager');
|
||||
const Collection = require('../util/Collection');
|
||||
const { MessageTypes } = require('../util/Constants');
|
||||
const { MessageTypes, SystemMessageTypes } = require('../util/Constants');
|
||||
const MessageFlags = require('../util/MessageFlags');
|
||||
const Permissions = require('../util/Permissions');
|
||||
const SnowflakeUtil = require('../util/Snowflake');
|
||||
@@ -62,7 +62,7 @@ class Message extends Base {
|
||||
* Whether or not this message was sent by Discord, not actually a user (e.g. pin notifications)
|
||||
* @type {?boolean}
|
||||
*/
|
||||
this.system = data.type !== 0;
|
||||
this.system = SystemMessageTypes.includes(this.type);
|
||||
} else if (typeof this.type !== 'string') {
|
||||
this.system = null;
|
||||
this.type = null;
|
||||
|
||||
@@ -429,6 +429,14 @@ exports.MessageTypes = [
|
||||
'REPLY',
|
||||
];
|
||||
|
||||
/**
|
||||
* The types of messages that are `System`. The available types are `MessageTypes` excluding:
|
||||
* * DEFAULT
|
||||
* * REPLY
|
||||
* @typedef {string} SystemMessageType
|
||||
*/
|
||||
exports.SystemMessageTypes = exports.MessageTypes.filter(type => type && type !== 'DEFAULT' && type !== 'REPLY');
|
||||
|
||||
/**
|
||||
* <info>Bots cannot set a `CUSTOM_STATUS`, it is only for custom statuses received from users</info>
|
||||
* The type of an activity of a users presence, e.g. `PLAYING`. Here are the available types:
|
||||
|
||||
Reference in New Issue
Block a user