aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/config.ts27
-rw-r--r--src/commands/volume.ts42
2 files changed, 69 insertions, 0 deletions
diff --git a/src/commands/config.ts b/src/commands/config.ts
index 9441dab..a2bfe93 100644
--- a/src/commands/config.ts
+++ b/src/commands/config.ts
@@ -41,6 +41,15 @@ export default class implements Command {
.setDescription('whether to announce the next song in the queue automatically')
.setRequired(true)))
.addSubcommand(subcommand => subcommand
+ .setName('set-default-volume')
+ .setDescription('set default volume used when entering the voice channel')
+ .addIntegerOption(option => option
+ .setName('level')
+ .setDescription('volume percentage (0 is muted, 100 is max & default)')
+ .setMinValue(0)
+ .setMaxValue(100)
+ .setRequired(true)))
+ .addSubcommand(subcommand => subcommand
.setName('get')
.setDescription('show all settings'));
@@ -121,6 +130,23 @@ export default class implements Command {
break;
}
+ case 'set-default-volume': {
+ const value = interaction.options.getInteger('level')!;
+
+ await prisma.setting.update({
+ where: {
+ guildId: interaction.guild!.id,
+ },
+ data: {
+ defaultVolume: value,
+ },
+ });
+
+ await interaction.reply('👍 volume setting updated');
+
+ break;
+ }
+
case 'get': {
const embed = new EmbedBuilder().setTitle('Config');
@@ -133,6 +159,7 @@ export default class implements Command {
: `${config.secondsToWaitAfterQueueEmpties}s`,
'Leave if there are no listeners': config.leaveIfNoListeners ? 'yes' : 'no',
'Auto announce next song in queue': config.autoAnnounceNextSong ? 'yes' : 'no',
+ 'Default Volume': config.defaultVolume,
};
let description = '';
diff --git a/src/commands/volume.ts b/src/commands/volume.ts
new file mode 100644
index 0000000..4077c40
--- /dev/null
+++ b/src/commands/volume.ts
@@ -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('volume percentage (0 is muted, 100 is max & default)')
+ .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}%`);
+ }
+}