Skip to content

Commit

Permalink
🗂️ added commandHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
Nich87 committed Dec 3, 2023
1 parent ef93b21 commit 9165a0d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 20 deletions.
31 changes: 11 additions & 20 deletions src/Events/onMessageCreate.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
import { changeVolumeCommand } from '../commands/changeVolume';
import { helpCommand } from '../commands/help';
import { loopCommand } from '../commands/loop';
import { nowplayingCommand } from '../commands/nowplaying';
import { pauseCommand } from '../commands/pause';
import { playCommand } from '../commands/play';
import { queueCommand } from '../commands/queue';
import { resumeCommand } from '../commands/resume';
import { skipCommand } from '../commands/skip';
import { stopCommand } from '../commands/stop';
import { commands } from '../commands';
import { Message, EmbedBuilder } from 'discord.js';

const prefix = 'ts!';
Expand All @@ -20,34 +11,34 @@ export async function onMessageCreate(message: Message) {

switch (commandName) {
case 'play':
playCommand(message);
commands.play(message);
break;
case 'stop':
stopCommand(message);
commands.stop(message);
break;
case 'pause':
pauseCommand(message);
commands.pause(message);
break;
case 'resume':
resumeCommand(message);
commands.resume(message);
break;
case 'loop':
loopCommand(message, args);
commands.loop(message, args);
break;
case 'skip':
skipCommand(message);
commands.skip(message);
break;
case 'queue':
queueCommand(message);
commands.queue(message);
break;
case 'help':
helpCommand(message);
commands.help(message);
break;
case 'volume':
changeVolumeCommand(message);
commands.changeVolume(message);
break;
case 'nowplaying':
nowplayingCommand(message);
commands.nowplaying(message);
break;
default:
message.reply({
Expand Down
23 changes: 23 additions & 0 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { changeVolumeCommand } from './changeVolume';
import { helpCommand } from './help';
import { loopCommand } from './loop';
import { nowplayingCommand } from './nowplaying';
import { pauseCommand } from './pause';
import { playCommand } from './play';
import { queueCommand } from './queue';
import { resumeCommand } from './resume';
import { skipCommand } from './skip';
import { stopCommand } from './stop';

export const commands = {
changeVolume: changeVolumeCommand,
help: helpCommand,
loop: loopCommand,
nowplaying: nowplayingCommand,
pause: pauseCommand,
play: playCommand,
queue: queueCommand,
resume: resumeCommand,
skip: skipCommand,
stop: stopCommand
};

0 comments on commit 9165a0d

Please sign in to comment.