-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
13 changed files
with
290 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { CommandInteraction, SlashCommandBuilder, TextChannel } from 'discord.js'; | ||
import { client } from 'src/Bot'; | ||
import { fetchGuild } from 'src/database/queries/guilds/get'; | ||
|
||
import { currentCommand } from '../textCommands'; | ||
|
||
export const data = new SlashCommandBuilder().setName('current').setDescription('Get the current played song !'); | ||
|
||
export async function execute(interaction: CommandInteraction) { | ||
const guild = await fetchGuild(interaction.guildId!); | ||
|
||
const channel = client.channels.cache.get(interaction.channelId!); | ||
if (!(channel instanceof TextChannel)) return interaction.reply('Error: Text channel not found !'); | ||
|
||
const textChannel = channel as TextChannel; | ||
//@ts-expect-error : voiceChannel is not a property of interaction.member | ||
const voiceChannel = interaction.member.voice.channel; | ||
|
||
if (!guild) return interaction.reply('Error: Guild not found !'); | ||
if (!voiceChannel) return interaction.reply('Error: You must be in a voice channel !'); | ||
if (!textChannel) return interaction.reply('Error: Text channel not found !'); | ||
|
||
await currentCommand(guild.guildId, textChannel, voiceChannel); | ||
interaction.reply('Understood !'); | ||
interaction.deleteReply(); | ||
return; | ||
} |
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,19 @@ | ||
import * as current from './current'; | ||
import * as pause from './pause'; | ||
import * as play from './play'; | ||
import * as queue from './queue'; | ||
import * as redo from './redo'; | ||
import * as remove from './remove'; | ||
import * as resume from './resume'; | ||
import * as skip from './skip'; | ||
|
||
export const commands = { | ||
play, | ||
skip, | ||
remove, | ||
pause, | ||
resume, | ||
queue, | ||
current, | ||
redo, | ||
}; |
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,27 @@ | ||
import { CommandInteraction, SlashCommandBuilder, TextChannel } from 'discord.js'; | ||
import { client } from 'src/Bot'; | ||
import { fetchGuild } from 'src/database/queries/guilds/get'; | ||
|
||
import { pauseCommand } from '../textCommands'; | ||
|
||
export const data = new SlashCommandBuilder().setName('pause').setDescription('Pause the currently played song !'); | ||
|
||
export async function execute(interaction: CommandInteraction) { | ||
const guild = await fetchGuild(interaction.guildId!); | ||
|
||
const channel = client.channels.cache.get(interaction.channelId!); | ||
if (!(channel instanceof TextChannel)) return interaction.reply('Error: Text channel not found !'); | ||
|
||
const textChannel = channel as TextChannel; | ||
//@ts-expect-error : voiceChannel is not a property of interaction.member | ||
const voiceChannel = interaction.member.voice.channel; | ||
|
||
if (!guild) return interaction.reply('Error: Guild not found !'); | ||
if (!voiceChannel) return interaction.reply('Error: You must be in a voice channel !'); | ||
if (!textChannel) return interaction.reply('Error: Text channel not found !'); | ||
|
||
await pauseCommand(guild.guildId, textChannel, interaction.user, voiceChannel); | ||
interaction.reply('Understood !'); | ||
interaction.deleteReply(); | ||
return; | ||
} |
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,33 @@ | ||
import { CommandInteraction, SlashCommandBuilder, TextChannel } from 'discord.js'; | ||
import { client } from 'src/Bot'; | ||
import { fetchGuild } from 'src/database/queries/guilds/get'; | ||
|
||
import { playCommand } from '../textCommands'; | ||
|
||
export const data = new SlashCommandBuilder() | ||
.setName('play') | ||
.setDescription('Request a song !') | ||
.addStringOption((option) => option.setName('query').setDescription('The search or youtube url !').setRequired(true)); | ||
|
||
export async function execute(interaction: CommandInteraction) { | ||
const guild = await fetchGuild(interaction.guildId!); | ||
|
||
const channel = client.channels.cache.get(interaction.channelId!); | ||
if (!(channel instanceof TextChannel)) return interaction.reply('Error: Text channel not found !'); | ||
|
||
const textChannel = channel as TextChannel; | ||
//@ts-expect-error : voiceChannel is not a property of interaction.member | ||
const voiceChannel = interaction.member.voice.channel; | ||
//@ts-expect-error : getString is not a property of interaction.options | ||
const query = interaction.options.getString('query'); | ||
|
||
if (!guild) return interaction.reply('Error: Guild not found !'); | ||
if (!voiceChannel) return interaction.reply('Error: You must be in a voice channel !'); | ||
if (!textChannel) return interaction.reply('Error: Text channel not found !'); | ||
if (!query) return interaction.reply('Error: You must provide a query !'); | ||
|
||
await playCommand(['play', query], guild.guildId, textChannel, interaction.user, voiceChannel); | ||
interaction.reply('Song requested !'); | ||
interaction.deleteReply(); | ||
return; | ||
} |
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,27 @@ | ||
import { CommandInteraction, SlashCommandBuilder, TextChannel } from 'discord.js'; | ||
import { client } from 'src/Bot'; | ||
import { fetchGuild } from 'src/database/queries/guilds/get'; | ||
|
||
import { queueCommand } from '../textCommands'; | ||
|
||
export const data = new SlashCommandBuilder().setName('queue').setDescription('Get the queue !'); | ||
|
||
export async function execute(interaction: CommandInteraction) { | ||
const guild = await fetchGuild(interaction.guildId!); | ||
|
||
const channel = client.channels.cache.get(interaction.channelId!); | ||
if (!(channel instanceof TextChannel)) return interaction.reply('Error: Text channel not found !'); | ||
|
||
const textChannel = channel as TextChannel; | ||
//@ts-expect-error : voiceChannel is not a property of interaction.member | ||
const voiceChannel = interaction.member.voice.channel; | ||
|
||
if (!guild) return interaction.reply('Error: Guild not found !'); | ||
if (!voiceChannel) return interaction.reply('Error: You must be in a voice channel !'); | ||
if (!textChannel) return interaction.reply('Error: Text channel not found !'); | ||
|
||
await queueCommand(guild.guildId, textChannel, interaction.user, voiceChannel); | ||
interaction.reply('Understood !'); | ||
interaction.deleteReply(); | ||
return; | ||
} |
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,27 @@ | ||
import { CommandInteraction, SlashCommandBuilder, TextChannel } from 'discord.js'; | ||
import { client } from 'src/Bot'; | ||
import { fetchGuild } from 'src/database/queries/guilds/get'; | ||
|
||
import { redoCommand } from '../textCommands'; | ||
|
||
export const data = new SlashCommandBuilder().setName('redo').setDescription('Request the last song again !'); | ||
|
||
export async function execute(interaction: CommandInteraction) { | ||
const guild = await fetchGuild(interaction.guildId!); | ||
|
||
const channel = client.channels.cache.get(interaction.channelId!); | ||
if (!(channel instanceof TextChannel)) return interaction.reply('Error: Text channel not found !'); | ||
|
||
const textChannel = channel as TextChannel; | ||
//@ts-expect-error : voiceChannel is not a property of interaction.member | ||
const voiceChannel = interaction.member.voice.channel; | ||
|
||
if (!guild) return interaction.reply('Error: Guild not found !'); | ||
if (!voiceChannel) return interaction.reply('Error: You must be in a voice channel !'); | ||
if (!textChannel) return interaction.reply('Error: Text channel not found !'); | ||
|
||
await redoCommand(guild.guildId, textChannel, interaction.user, voiceChannel); | ||
interaction.reply('Understood !'); | ||
interaction.deleteReply(); | ||
return; | ||
} |
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,27 @@ | ||
import { CommandInteraction, SlashCommandBuilder, TextChannel } from 'discord.js'; | ||
import { client } from 'src/Bot'; | ||
import { fetchGuild } from 'src/database/queries/guilds/get'; | ||
|
||
import { removeCommand } from '../textCommands'; | ||
|
||
export const data = new SlashCommandBuilder().setName('remove').setDescription('Disconnect the bot !'); | ||
|
||
export async function execute(interaction: CommandInteraction) { | ||
const guild = await fetchGuild(interaction.guildId!); | ||
|
||
const channel = client.channels.cache.get(interaction.channelId!); | ||
if (!(channel instanceof TextChannel)) return interaction.reply('Error: Text channel not found !'); | ||
|
||
const textChannel = channel as TextChannel; | ||
//@ts-expect-error : voiceChannel is not a property of interaction.member | ||
const voiceChannel = interaction.member.voice.channel; | ||
|
||
if (!guild) return interaction.reply('Error: Guild not found !'); | ||
if (!voiceChannel) return interaction.reply('Error: You must be in a voice channel !'); | ||
if (!textChannel) return interaction.reply('Error: Text channel not found !'); | ||
|
||
await removeCommand(guild.guildId, textChannel, interaction.user, voiceChannel); | ||
interaction.reply('Understood !'); | ||
interaction.deleteReply(); | ||
return; | ||
} |
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,27 @@ | ||
import { CommandInteraction, SlashCommandBuilder, TextChannel } from 'discord.js'; | ||
import { client } from 'src/Bot'; | ||
import { fetchGuild } from 'src/database/queries/guilds/get'; | ||
|
||
import { resumeCommand } from '../textCommands'; | ||
|
||
export const data = new SlashCommandBuilder().setName('resume').setDescription('Resume the currently played song !'); | ||
|
||
export async function execute(interaction: CommandInteraction) { | ||
const guild = await fetchGuild(interaction.guildId!); | ||
|
||
const channel = client.channels.cache.get(interaction.channelId!); | ||
if (!(channel instanceof TextChannel)) return interaction.reply('Error: Text channel not found !'); | ||
|
||
const textChannel = channel as TextChannel; | ||
//@ts-expect-error : voiceChannel is not a property of interaction.member | ||
const voiceChannel = interaction.member.voice.channel; | ||
|
||
if (!guild) return interaction.reply('Error: Guild not found !'); | ||
if (!voiceChannel) return interaction.reply('Error: You must be in a voice channel !'); | ||
if (!textChannel) return interaction.reply('Error: Text channel not found !'); | ||
|
||
await resumeCommand(guild.guildId, textChannel, interaction.user, voiceChannel); | ||
interaction.reply('Understood !'); | ||
interaction.deleteReply(); | ||
return; | ||
} |
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,27 @@ | ||
import { CommandInteraction, SlashCommandBuilder, TextChannel } from 'discord.js'; | ||
import { client } from 'src/Bot'; | ||
import { fetchGuild } from 'src/database/queries/guilds/get'; | ||
|
||
import { skipCommand } from '../textCommands'; | ||
|
||
export const data = new SlashCommandBuilder().setName('skip').setDescription('Skip the currently played song !'); | ||
|
||
export async function execute(interaction: CommandInteraction) { | ||
const guild = await fetchGuild(interaction.guildId!); | ||
|
||
const channel = client.channels.cache.get(interaction.channelId!); | ||
if (!(channel instanceof TextChannel)) return interaction.reply('Error: Text channel not found !'); | ||
|
||
const textChannel = channel as TextChannel; | ||
//@ts-expect-error : voiceChannel is not a property of interaction.member | ||
const voiceChannel = interaction.member.voice.channel; | ||
|
||
if (!guild) return interaction.reply('Error: Guild not found !'); | ||
if (!voiceChannel) return interaction.reply('Error: You must be in a voice channel !'); | ||
if (!textChannel) return interaction.reply('Error: Text channel not found !'); | ||
|
||
await skipCommand(guild.guildId, textChannel, interaction.user, voiceChannel); | ||
interaction.reply('Understood !'); | ||
interaction.deleteReply(); | ||
return; | ||
} |
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,26 @@ | ||
import { REST, Routes } from 'discord.js'; | ||
|
||
import { commands } from './commands/slashCommands'; | ||
import { secrets } from './config/secrets'; | ||
|
||
type DeployCommandsProps = { | ||
guildId: string; | ||
}; | ||
|
||
const commandsData = Object.values(commands).map((command) => command.data); | ||
|
||
const rest = new REST({ version: '10' }).setToken(secrets.DISCORD_TOKEN); | ||
|
||
export async function deployCommands({ guildId }: DeployCommandsProps) { | ||
try { | ||
console.log('Started refreshing application (/) commands.'); | ||
|
||
await rest.put(Routes.applicationGuildCommands(secrets.DISCORD_CLIENT_ID.toString(), guildId), { | ||
body: commandsData, | ||
}); | ||
|
||
console.log('Successfully reloaded application (/) commands.'); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} |
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