-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a93d24
commit 9b74fdd
Showing
4 changed files
with
52 additions
and
69 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 was deleted.
Oops, something went wrong.
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,51 @@ | ||
import { SlashCommandBuilder, EmbedBuilder, Client } from 'discord.js'; | ||
import { SlashCommand } from '../../types'; | ||
import { readdirSync } from 'fs'; | ||
import { logger } from 'src/utils/logger'; | ||
import { join } from 'path'; | ||
import { playAudio, voiceChannelPresence } from 'src/utils/discord'; | ||
|
||
const audiosDir = join(__dirname, '../../resources/sounds/'); | ||
const audios: string[] = []; | ||
|
||
readdirSync(audiosDir).forEach((file) => { | ||
try { | ||
if (!file.endsWith('.mp3') || file.startsWith('_')) return; | ||
audios.push(file.replace('.mp3', '')); | ||
logger.info(`Successfully loaded audio ${file.replace('.mp3', '')}`); | ||
} catch (error) { | ||
logger.error(`Error loading audio ${file.replace('.mp3', '')}`); | ||
logger.error(error); | ||
} | ||
}); | ||
|
||
export const audio: SlashCommand = { | ||
command: new SlashCommandBuilder() | ||
.setName('audio') | ||
.setDescription('Reproduz um áudio') | ||
.addStringOption((option) => | ||
option | ||
.setName('audio') | ||
.setDescription('Áudio a ser reproduzido') | ||
.setRequired(true) | ||
.addChoices( | ||
...audios.map((audio) => { | ||
return { name: audio, value: audio }; | ||
}) | ||
) | ||
), | ||
|
||
execute: (interaction) => { | ||
const channel = voiceChannelPresence(interaction); | ||
const file = interaction.options.get('audio'); | ||
playAudio(interaction, channel, file.value as string); | ||
interaction.reply({ | ||
embeds: [ | ||
new EmbedBuilder().setDescription( | ||
`Reproduzindo ${file.value as string}` | ||
), | ||
], | ||
}); | ||
}, | ||
cooldown: 10, | ||
}; |
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