Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
feat(cmd): add an owneronly option
Browse files Browse the repository at this point in the history
  • Loading branch information
alexthemaster committed Jul 22, 2020
1 parent 018526a commit ad61caa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/lib/structures/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export class Command extends BasePiece<Command> {
public readonly canRunInDM: boolean;
/** The amount of time in seconds of the command's cooldown */
public readonly cooldown: number;
/** Whether or not this command can only be run by the owner */
public readonly ownerOnly: boolean;

public run(_message: Message, ..._arg: any[]): void {
throw new Error(`Run function not defined in ${__filename}`);
Expand All @@ -27,6 +29,7 @@ export class Command extends BasePiece<Command> {
this.nsfw = options?.nsfw ?? false;
this.canRunInDM = options?.canRunInDM ?? true;
this.cooldown = options?.cooldown ?? 0;
this.ownerOnly = options?.ownerOnly ?? false;
}
}

Expand All @@ -38,5 +41,7 @@ interface CommandOptions extends BasePieceOptions {
/** Whether or not this command can be called by a user when DM-ing the bot */
canRunInDM?: boolean;
/** The amount of time in seconds of a command's cooldown */
cooldown: number;
cooldown?: number;
/** Whether or not this command can only be run by the owner */
ownerOnly?: boolean;
}
4 changes: 2 additions & 2 deletions src/lib/structures/Event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export class Event extends BasePiece<Event> {
super(client, pool, options);
if (!options.event) throw new Error(`No event name provided in one of the event files.`)
this.event = options.event;
this.disabled = options.disabled || false;
this.once = options.once || false;
this.disabled = options.disabled ?? false;
this.once = options.once ?? false;
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/lib/structures/Monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export class Monitor extends BasePiece<Monitor> {

constructor(client: MoonlightClient, pool: BasePool<string, Monitor>, options: MonitorOptions) {
super(client, pool, options)
this.ignoreSelf = options.ignoreSelf || false;
this.ignoreBots = options.ignoreBots || false;
this.ignoreOthers = options.ignoreOthers || false;
this.ignoreSelf = options.ignoreSelf ?? false;
this.ignoreBots = options.ignoreBots ?? false;
this.ignoreOthers = options.ignoreOthers ?? false;
}
}

Expand Down

0 comments on commit ad61caa

Please sign in to comment.