Skip to content

Commit

Permalink
Fixed instantiating DatabaseAdapter multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
markokajzer committed Mar 20, 2018
1 parent 91dc80b commit 822fbdc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/commands/CommandCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ import AvatarCommand from './soundbot/AvatarCommand';
export default class CommandCollection extends Collection<string, ICommand> {
private readonly soundCommand: SoundCommand;

constructor(queue = new SoundQueue(), db = new DatabaseAdapter()) {
constructor(db = new DatabaseAdapter(), queue = new SoundQueue(db)) {
super();
this.soundCommand = new SoundCommand(queue);
this.initializeCommands(queue, db);
this.initializeCommands(db, queue);
}

public registerUserCommands(user: ClientUser) {
Expand All @@ -51,7 +51,7 @@ export default class CommandCollection extends Collection<string, ICommand> {
this.soundCommand.run(message, params);
}

private initializeCommands(queue: SoundQueue, db: DatabaseAdapter) {
private initializeCommands(db: DatabaseAdapter, queue: SoundQueue) {
[
new AddCommand(),
new RenameCommand(db),
Expand Down
2 changes: 1 addition & 1 deletion src/queue/SoundQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class SoundQueue {
private readonly queue: Array<QueueItem>;
private current: QueueItem | null;

constructor(db = new DatabaseAdapter()) {
constructor(db: DatabaseAdapter) {
this.db = db;
this.queue = [];
this.current = null;
Expand Down

0 comments on commit 822fbdc

Please sign in to comment.