refactor(Message): accept a single object instead of 3 arguments (#6244)

Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>
This commit is contained in:
Rodry
2021-07-31 12:22:19 +01:00
committed by GitHub
parent 198a5c490d
commit 434e330754
3 changed files with 21 additions and 19 deletions

View File

@@ -727,20 +727,27 @@ class Message extends Base {
return this.channel.send(data);
}
/**
* Options for starting a thread on a message.
* @typedef {Object} StartThreadOptions
* @property {string} name The name of the new thread
* @property {ThreadAutoArchiveDuration} autoArchiveDuration The amount of time (in minutes) after which the thread
* should automatically archive in case of no recent activity
* @property {string} [reason] Reason for creating the thread
*/
/**
* Create a new public thread from this message
* @see ThreadManager#create
* @param {string} name The name of the new Thread
* @param {ThreadAutoArchiveDuration} autoArchiveDuration How long before the thread is automatically archived
* @param {string} [reason] Reason for creating the thread
* @param {StartThreadOptions} [options] Options for starting a thread on this message
* @returns {Promise<ThreadChannel>}
*/
startThread(name, autoArchiveDuration, reason) {
startThread(options = {}) {
if (!['GUILD_TEXT', 'GUILD_NEWS'].includes(this.channel.type)) {
return Promise.reject(new Error('MESSAGE_THREAD_PARENT'));
}
if (this.hasThread) return Promise.reject(new Error('MESSAGE_EXISTING_THREAD'));
return this.channel.threads.create({ name, autoArchiveDuration, startMessage: this, reason });
return this.channel.threads.create({ ...options, startMessage: this });
}
/**