diff --git a/.eslintrc.json b/.eslintrc.json index 3bc3cd6..80c6ae3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -41,7 +41,7 @@ "singleQuote": true, "quoteProps": "as-needed", "trailingComma": "all", - "endOfLine": "auto", + "endOfLine": "lf", "arrowParens": "avoid" } ], @@ -153,7 +153,7 @@ "error", "$this" ], - "eol-last": "warn", + "eol-last": "error", "func-names": "error", "func-name-matching": "error", "func-style": [ @@ -203,7 +203,7 @@ ], "no-new-object": "error", "no-spaced-func": "error", - "no-trailing-spaces": "warn", + "no-trailing-spaces": "error", "no-unneeded-ternary": "error", "no-whitespace-before-property": "error", "nonblock-statement-body-position": "error", diff --git a/.prettierrc.json b/.prettierrc.json index a4a14c1..2a22378 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -2,6 +2,6 @@ "singleQuote": true, "printWidth": 120, "trailingComma": "all", - "endOfLine": "auto", + "endOfLine": "lf", "arrowParens": "avoid" } diff --git a/src/structures/ContainerComponent.js b/src/structures/ContainerComponent.js index fe9ee62..3f44e9c 100644 --- a/src/structures/ContainerComponent.js +++ b/src/structures/ContainerComponent.js @@ -1,51 +1,51 @@ -'use strict'; - -const BaseMessageComponent = require('./BaseMessageComponent'); -const { MessageComponentTypes } = require('../util/Constants'); - -class ContainerComponent extends BaseMessageComponent { - /** - * @typedef {MessageActionRow|TextDisplayComponent|SectionComponent|MediaGalleryComponent|SeparatorComponent|FileComponent} ContainerComponents - * @property {ContainerComponents[]} [components] Components of the type action row, text display, section, media gallery, separator, or file - * @property {Number} [accent_color] Color for the accent on the container as RGB from 0x000000 to 0xFFFFFF - * @property {Boolean} [spoiler] Whether the container should be a spoiler (or blurred out). Defaults to false. - */ - - /** - * @param {ContainerComponent | APIContainerComponent} [data={}] The data - */ - constructor(data = {}) { - super({ type: 'CONTAINER' }, data); - /** - * Components of the type action row, text display, section, media gallery, separator, or file - * @type {ContainerComponents[]} - */ - this.components = data.components?.map(c => BaseMessageComponent.create(c)) ?? []; - - /** - * Color for the accent on the container as RGB from 0x000000 to 0xFFFFFF - * @type {Number} - */ - this.accent_color = data.accent_color ?? null; - - /** - * Whether the container should be a spoiler (or blurred out). Defaults to false. - * @type {Boolean} - */ - this.spoiler = data.spoiler ?? false; - } - - /** - * @returns {APIContainerComponent} - */ - toJSON() { - return { - type: MessageComponentTypes[this.type], - components: this.components.map(c => c.toJSON()), - accent_color: this.accent_color, - spoiler: this.spoiler, - }; - } -} - -module.exports = ContainerComponent; \ No newline at end of file +'use strict'; + +const BaseMessageComponent = require('./BaseMessageComponent'); +const { MessageComponentTypes } = require('../util/Constants'); + +class ContainerComponent extends BaseMessageComponent { + /** + * @typedef {MessageActionRow|TextDisplayComponent|SectionComponent|MediaGalleryComponent|SeparatorComponent|FileComponent} ContainerComponents + * @property {ContainerComponents[]} [components] Components of the type action row, text display, section, media gallery, separator, or file + * @property {Number} [accent_color] Color for the accent on the container as RGB from 0x000000 to 0xFFFFFF + * @property {Boolean} [spoiler] Whether the container should be a spoiler (or blurred out). Defaults to false. + */ + + /** + * @param {ContainerComponent | APIContainerComponent} [data={}] The data + */ + constructor(data = {}) { + super({ type: 'CONTAINER' }, data); + /** + * Components of the type action row, text display, section, media gallery, separator, or file + * @type {ContainerComponents[]} + */ + this.components = data.components?.map(c => BaseMessageComponent.create(c)) ?? []; + + /** + * Color for the accent on the container as RGB from 0x000000 to 0xFFFFFF + * @type {Number} + */ + this.accent_color = data.accent_color ?? null; + + /** + * Whether the container should be a spoiler (or blurred out). Defaults to false. + * @type {Boolean} + */ + this.spoiler = data.spoiler ?? false; + } + + /** + * @returns {APIContainerComponent} + */ + toJSON() { + return { + type: MessageComponentTypes[this.type], + components: this.components.map(c => c.toJSON()), + accent_color: this.accent_color, + spoiler: this.spoiler, + }; + } +} + +module.exports = ContainerComponent; diff --git a/src/structures/FileComponent.js b/src/structures/FileComponent.js index 6c43139..0418a40 100644 --- a/src/structures/FileComponent.js +++ b/src/structures/FileComponent.js @@ -1,46 +1,44 @@ -'use strict'; - -const BaseMessageComponent = require('./BaseMessageComponent'); -const UnfurledMediaItem = require('./UnfurledMediaItem'); -const { MessageComponentTypes } = require('../util/Constants'); - - -class FileComponent extends BaseMessageComponent { - /** - * @property {UnfurledMediaItem} [file] This unfurled media item is unique in that it only supports attachment references using the attachment:// syntax - * @property {Boolean} [spoiler] Whether the container should be a spoiler (or blurred out). Defaults to false. - */ - - /** - * @param {FileComponent | APIFileComponent} [data={}] The data - */ - constructor(data = {}) { - super({ type: 'FILE' }, data); - - /** - * This unfurled media item is unique in that it only supports attachment references using the attachment:// syntax - * @type {UnfurledMediaItem} - */ - this.file = new UnfurledMediaItem(data.file); - - /** - * Whether the container should be a spoiler (or blurred out). Defaults to false. - * @type {Boolean} - */ - this.spoiler = data.spoiler ?? false; - } - - - /** - * @returns {APIFileComponent} - */ - toJSON() { - return { - type: MessageComponentTypes[this.type], - file: this.content, - spoiler: this.spoiler, - }; - } -} - -module.exports = FileComponent; \ No newline at end of file +'use strict'; + +const BaseMessageComponent = require('./BaseMessageComponent'); +const UnfurledMediaItem = require('./UnfurledMediaItem'); +const { MessageComponentTypes } = require('../util/Constants'); + +class FileComponent extends BaseMessageComponent { + /** + * @property {UnfurledMediaItem} [file] This unfurled media item is unique in that it only supports attachment references using the attachment:// syntax + * @property {Boolean} [spoiler] Whether the container should be a spoiler (or blurred out). Defaults to false. + */ + + /** + * @param {FileComponent | APIFileComponent} [data={}] The data + */ + constructor(data = {}) { + super({ type: 'FILE' }, data); + + /** + * This unfurled media item is unique in that it only supports attachment references using the attachment:// syntax + * @type {UnfurledMediaItem} + */ + this.file = new UnfurledMediaItem(data.file); + + /** + * Whether the container should be a spoiler (or blurred out). Defaults to false. + * @type {Boolean} + */ + this.spoiler = data.spoiler ?? false; + } + + /** + * @returns {APIFileComponent} + */ + toJSON() { + return { + type: MessageComponentTypes[this.type], + file: this.content, + spoiler: this.spoiler, + }; + } +} + +module.exports = FileComponent; diff --git a/src/structures/MediaGalleryComponent.js b/src/structures/MediaGalleryComponent.js index aaf8ed3..b7ea099 100644 --- a/src/structures/MediaGalleryComponent.js +++ b/src/structures/MediaGalleryComponent.js @@ -1,36 +1,36 @@ -'use strict'; - -const BaseMessageComponent = require('./BaseMessageComponent'); -const MediaGalleryItem = require('./MediaGalleryItem'); -const { MessageComponentTypes } = require('../util/Constants'); - -class MediaGalleryComponent extends BaseMessageComponent { - /** - * @property {MediaGalleryItem[]} [items] 1 to 10 media gallery items - */ - - /** - * @param {MediaGalleryComponent | APIMediaGalleryComponent} [data={}] The data - */ - constructor(data = {}) { - super({ type: 'MEDIA_GALLERY' }, data); - - /** - * 1 to 10 media gallery items - * @type {MediaGalleryItem[]} - */ - this.items = data.items?.map(item => new MediaGalleryItem(item)) ?? []; - } - - /** - * @returns {APIMediaGalleryComponent} - */ - toJSON() { - return { - type: MessageComponentTypes[this.type], - items: this.items.map(c => c.toJSON()), - }; - } -} - -module.exports = MediaGalleryComponent; \ No newline at end of file +'use strict'; + +const BaseMessageComponent = require('./BaseMessageComponent'); +const MediaGalleryItem = require('./MediaGalleryItem'); +const { MessageComponentTypes } = require('../util/Constants'); + +class MediaGalleryComponent extends BaseMessageComponent { + /** + * @property {MediaGalleryItem[]} [items] 1 to 10 media gallery items + */ + + /** + * @param {MediaGalleryComponent | APIMediaGalleryComponent} [data={}] The data + */ + constructor(data = {}) { + super({ type: 'MEDIA_GALLERY' }, data); + + /** + * 1 to 10 media gallery items + * @type {MediaGalleryItem[]} + */ + this.items = data.items?.map(item => new MediaGalleryItem(item)) ?? []; + } + + /** + * @returns {APIMediaGalleryComponent} + */ + toJSON() { + return { + type: MessageComponentTypes[this.type], + items: this.items.map(c => c.toJSON()), + }; + } +} + +module.exports = MediaGalleryComponent; diff --git a/src/structures/MediaGalleryItem.js b/src/structures/MediaGalleryItem.js index eb79ff8..4d145c8 100644 --- a/src/structures/MediaGalleryItem.js +++ b/src/structures/MediaGalleryItem.js @@ -1,47 +1,47 @@ -'use strict'; - -const UnfurledMediaItem = require('./UnfurledMediaItem'); - -class MediaGalleryItem { - /** - * @property {UnfurledMediaItem} [media] A url or attachment - * @property {String} [description] Alt text for the media, max 1024 characters - * @property {Boolean} [spoiler] Whether the media should be a spoiler (or blurred out). Defaults to false - */ - - /** - * @param {MediaGalleryItem | APIMediaGalleryItem} [data={}] The data - */ - constructor(data = {}) { - /** - * A url or attachment - * @type {UnfurledMediaItem} - */ - this.media = new UnfurledMediaItem(data.media); - - /** - * Alt text for the media, max 1024 characters - * @type {String} - */ - this.description = data.description ?? null; - - /** - * Whether the media should be a spoiler (or blurred out). Defaults to false - * @type {Boolean} - */ - this.spoiler = data.spoiler ?? false; - } - - /** - * @returns {APIMediaGalleryItem} - */ - toJSON() { - return { - media: this.media.toJSON(), - description: this.description, - spoiler: this.spoiler, - }; - } -} - -module.exports = MediaGalleryItem; \ No newline at end of file +'use strict'; + +const UnfurledMediaItem = require('./UnfurledMediaItem'); + +class MediaGalleryItem { + /** + * @property {UnfurledMediaItem} [media] A url or attachment + * @property {String} [description] Alt text for the media, max 1024 characters + * @property {Boolean} [spoiler] Whether the media should be a spoiler (or blurred out). Defaults to false + */ + + /** + * @param {MediaGalleryItem | APIMediaGalleryItem} [data={}] The data + */ + constructor(data = {}) { + /** + * A url or attachment + * @type {UnfurledMediaItem} + */ + this.media = new UnfurledMediaItem(data.media); + + /** + * Alt text for the media, max 1024 characters + * @type {String} + */ + this.description = data.description ?? null; + + /** + * Whether the media should be a spoiler (or blurred out). Defaults to false + * @type {Boolean} + */ + this.spoiler = data.spoiler ?? false; + } + + /** + * @returns {APIMediaGalleryItem} + */ + toJSON() { + return { + media: this.media.toJSON(), + description: this.description, + spoiler: this.spoiler, + }; + } +} + +module.exports = MediaGalleryItem;