Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

Commit

Permalink
fix: require added statuses to include at least a name
Browse files Browse the repository at this point in the history
  • Loading branch information
TMUniversal committed Aug 7, 2021
1 parent d648d7e commit 783f347
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,21 @@ export default class StatusUpdater <ClientType extends DJSClient = DJSClient> {
* Add a status to the possible statuses
* @param {ActivityOptions} status ActivityOptions
*/
public async addStatus (status: ActivityOptions): Promise<ActivityOptions[]> {
public addStatus (status: ActivityOptions): ActivityOptions[] {
if (!this.isReady) {
return await Promise.reject(new Error('StatusUpdater is not ready.'))
throw new Error('StatusUpdater is not ready.')
}

if (!status.name) {
throw new Error('status must include at least a name')
}

if (!this._statuses.includes(status)) {
this._statuses.push(status)
return await Promise.resolve(this.statuses)
return this.statuses
}
else {
return await Promise.reject(new Error('Already included.'))
throw new Error('Already included.')
}
}

Expand Down

0 comments on commit 783f347

Please sign in to comment.