added skip
This commit is contained in:
@@ -5,6 +5,7 @@ import ping from "./ping"
|
|||||||
import play from "./play"
|
import play from "./play"
|
||||||
import queue from "./queue"
|
import queue from "./queue"
|
||||||
import resume from "./resume"
|
import resume from "./resume"
|
||||||
|
import skip from "./skip"
|
||||||
import stop from "./stop"
|
import stop from "./stop"
|
||||||
|
|
||||||
export const commands: { [key: string]: Command } = {
|
export const commands: { [key: string]: Command } = {
|
||||||
@@ -16,5 +17,6 @@ export const commands: { [key: string]: Command } = {
|
|||||||
resume,
|
resume,
|
||||||
stop,
|
stop,
|
||||||
pause,
|
pause,
|
||||||
|
skip,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
25
src/commands/skip.ts
Normal file
25
src/commands/skip.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { CacheType, ChatInputCommandInteraction, SlashCommandBuilder } from 'discord.js';
|
||||||
|
import { skip_song } from '../playback';
|
||||||
|
|
||||||
|
const name = "skip"
|
||||||
|
|
||||||
|
function register() {
|
||||||
|
return new SlashCommandBuilder()
|
||||||
|
.setName(name)
|
||||||
|
.setDescription('skip song')
|
||||||
|
}
|
||||||
|
|
||||||
|
async function execute(interaction: ChatInputCommandInteraction<CacheType>) {
|
||||||
|
try {
|
||||||
|
skip_song()
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
await interaction.reply('Coś poszło nie tak :/');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name,
|
||||||
|
register,
|
||||||
|
execute
|
||||||
|
}
|
||||||
@@ -42,6 +42,18 @@ export async function updatePlayer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function skip_song() {
|
||||||
|
if (player.state.status === AudioPlayerStatus.Playing) {
|
||||||
|
const nextSong = queue.songList.shift()
|
||||||
|
if (!nextSong) {
|
||||||
|
queue.current = null
|
||||||
|
return
|
||||||
|
};
|
||||||
|
queue.current = nextSong;
|
||||||
|
playSong(player, nextSong);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function pause_playback(player: AudioPlayer) {
|
export function pause_playback(player: AudioPlayer) {
|
||||||
player.pause()
|
player.pause()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user