added search
This commit is contained in:
@@ -2,6 +2,7 @@ import { CacheType, ChatInputCommandInteraction, SlashCommandBuilder } from 'dis
|
||||
import { connectToChannelByInteraction } from '../util/helpers';
|
||||
import { forceRequestSong } from '../playback';
|
||||
import { getPlayMsg } from '../messages';
|
||||
import { search } from '../util/downloader';
|
||||
|
||||
const name = "forceplay"
|
||||
|
||||
@@ -16,16 +17,27 @@ function register() {
|
||||
|
||||
async function execute(interaction: ChatInputCommandInteraction<CacheType>) {
|
||||
try {
|
||||
await interaction.deferReply()
|
||||
connectToChannelByInteraction(interaction)
|
||||
|
||||
const url = interaction.options.getString("url")!;
|
||||
const input = interaction.options.getString("url")!;
|
||||
let url: string;
|
||||
|
||||
if (input.startsWith("http")) {
|
||||
url = input
|
||||
} else {
|
||||
url = await search(input)
|
||||
await interaction.editReply(`searching for: ${input}`);
|
||||
console.log(input, url)
|
||||
}
|
||||
|
||||
await forceRequestSong(interaction, url)
|
||||
|
||||
const msg = getPlayMsg(url)
|
||||
await interaction.reply(msg);
|
||||
await interaction.editReply(msg);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
await interaction.reply('Coś poszło nie tak :/');
|
||||
await interaction.editReply('Coś poszło nie tak :/');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { CacheType, ChatInputCommandInteraction, SlashCommandBuilder } from 'dis
|
||||
import { connectToChannelByInteraction } from '../util/helpers';
|
||||
import { requestSong } from '../playback';
|
||||
import { getPlayMsg } from '../messages';
|
||||
import { search } from '../util/downloader';
|
||||
|
||||
const name = "play"
|
||||
|
||||
@@ -10,22 +11,33 @@ function register() {
|
||||
.setName(name)
|
||||
.setDescription('YT')
|
||||
.addStringOption((option) => option.setName("url")
|
||||
.setDescription("YT url")
|
||||
.setDescription("YT url/search")
|
||||
.setRequired(true))
|
||||
}
|
||||
|
||||
async function execute(interaction: ChatInputCommandInteraction<CacheType>) {
|
||||
try {
|
||||
await interaction.deferReply()
|
||||
connectToChannelByInteraction(interaction)
|
||||
|
||||
const url = interaction.options.getString("url")!;
|
||||
const input = interaction.options.getString("url")!;
|
||||
let url: string;
|
||||
|
||||
if (input.startsWith("http")) {
|
||||
url = input
|
||||
} else {
|
||||
url = await search(input)
|
||||
await interaction.editReply(`searching for: ${input}`);
|
||||
console.log(input, url)
|
||||
}
|
||||
|
||||
await requestSong(interaction, url)
|
||||
|
||||
const msg = getPlayMsg(url)
|
||||
await interaction.reply(msg);
|
||||
await interaction.editReply(msg);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
await interaction.reply('Coś poszło nie tak :/');
|
||||
await interaction.editReply('Coś poszło nie tak :/');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user