chore: consistency/prettier (#3852)

* chore: consistency/prettier

* chore: rebase

* chore: rebase

* chore: include typings

* fix: include typings file in prettier lint-staged
This commit is contained in:
Crawl
2020-02-29 14:35:57 +01:00
committed by GitHub
parent 6650d50a56
commit c065156a88
127 changed files with 5198 additions and 4513 deletions

View File

@@ -1,10 +1,11 @@
'use strict';
/* eslint-disable import/order */
const MessageCollector = require('../MessageCollector');
const APIMessage = require('../APIMessage');
const Snowflake = require('../../util/Snowflake');
const Collection = require('../../util/Collection');
const { RangeError, TypeError } = require('../../errors');
const APIMessage = require('../APIMessage');
/**
* Interface for classes that have text-channel-like features.
@@ -144,7 +145,8 @@ class TextBasedChannel {
}
const { data, files } = await apiMessage.resolveFiles();
return this.client.api.channels[this.id].messages.post({ data, files })
return this.client.api.channels[this.id].messages
.post({ data, files })
.then(d => this.client.actions.MessageCreate.handle(d).message);
}
@@ -299,23 +301,36 @@ class TextBasedChannel {
if (Array.isArray(messages) || messages instanceof Collection) {
let messageIDs = messages instanceof Collection ? messages.keyArray() : messages.map(m => m.id || m);
if (filterOld) {
messageIDs = messageIDs.filter(id =>
Date.now() - Snowflake.deconstruct(id).date.getTime() < 1209600000,
);
messageIDs = messageIDs.filter(id => Date.now() - Snowflake.deconstruct(id).date.getTime() < 1209600000);
}
if (messageIDs.length === 0) return new Collection();
if (messageIDs.length === 1) {
await this.client.api.channels(this.id).messages(messageIDs[0]).delete();
const message = this.client.actions.MessageDelete.getMessage({
message_id: messageIDs[0],
}, this);
await this.client.api
.channels(this.id)
.messages(messageIDs[0])
.delete();
const message = this.client.actions.MessageDelete.getMessage(
{
message_id: messageIDs[0],
},
this,
);
return message ? new Collection([[message.id, message]]) : new Collection();
}
await this.client.api.channels[this.id].messages['bulk-delete']
.post({ data: { messages: messageIDs } });
return messageIDs.reduce((col, id) => col.set(id, this.client.actions.MessageDeleteBulk.getMessage({
message_id: id,
}, this)), new Collection());
await this.client.api.channels[this.id].messages['bulk-delete'].post({ data: { messages: messageIDs } });
return messageIDs.reduce(
(col, id) =>
col.set(
id,
this.client.actions.MessageDeleteBulk.getMessage(
{
message_id: id,
},
this,
),
),
new Collection(),
);
}
if (!isNaN(messages)) {
const msgs = await this.messages.fetch({ limit: messages });
@@ -341,8 +356,11 @@ class TextBasedChannel {
}
for (const prop of props) {
if (ignore.includes(prop)) continue;
Object.defineProperty(structure.prototype, prop,
Object.getOwnPropertyDescriptor(TextBasedChannel.prototype, prop));
Object.defineProperty(
structure.prototype,
prop,
Object.getOwnPropertyDescriptor(TextBasedChannel.prototype, prop),
);
}
}
}