-
-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
5 changed files
with
118 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import {ChatInputCommandInteraction} from 'discord.js'; | ||
import {TYPES} from '../types.js'; | ||
import {inject, injectable} from 'inversify'; | ||
import PlayerManager from '../managers/player.js'; | ||
import Command from '.'; | ||
import {SlashCommandBuilder} from '@discordjs/builders'; | ||
|
||
@injectable() | ||
export default class implements Command { | ||
public readonly slashCommand = new SlashCommandBuilder() | ||
.setName('volume') | ||
.setDescription('set current player volume level') | ||
.addIntegerOption(option => | ||
option.setName('level') | ||
.setDescription('percentage as number EG 0 is muted, 100 is default max (normal) volume') | ||
.setMinValue(0) | ||
.setMaxValue(100) | ||
.setRequired(true), | ||
); | ||
|
||
public requiresVC = true; | ||
|
||
private readonly playerManager: PlayerManager; | ||
|
||
constructor(@inject(TYPES.Managers.Player) playerManager: PlayerManager) { | ||
this.playerManager = playerManager; | ||
} | ||
|
||
public async execute(interaction: ChatInputCommandInteraction): Promise<void> { | ||
const player = this.playerManager.get(interaction.guild!.id); | ||
|
||
const currentSong = player.getCurrent(); | ||
|
||
if (!currentSong) { | ||
throw new Error('nothing is playing'); | ||
} | ||
|
||
const level = interaction.options.getInteger('level') ?? 100; | ||
player.setVolume(level); | ||
await interaction.reply(`Set volume to ${level}%`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters