mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-14 03:09:59 +00:00
Add option to let user search directly from play
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Message, CommandInteraction, Interaction, VoiceChannel, MessageActionRow, Permissions, DMChannel, TextChannel } from "discord.js";
|
||||
import { Message, CommandInteraction, Interaction, VoiceChannel, MessageActionRow, Permissions, MessageButton, TextChannel } from "discord.js";
|
||||
import { makeErrorEmbed, makeSuccessEmbed, makeProcessingEmbed, sendMessage, sendMessageOrInteractionResponse, makeInfoEmbed } from "../../utils/DiscordMessage";
|
||||
import DiscordProvider from "../../providers/Discord";
|
||||
import Environment from "../../providers/Environment";
|
||||
@@ -181,7 +181,30 @@ export default class Play {
|
||||
instance.addTrackToQueue(result[0]);
|
||||
|
||||
if(result.length > 1) {
|
||||
// TODO: Let user choose the video
|
||||
|
||||
// If the first result title is exact match with the query or first title contains half the space of the query, it's probably a sentence
|
||||
// then we don't need to show the search results
|
||||
if(result[0].title === query || result[0].title && (Math.ceil((result[0].title.split(" ").length - 1) / 2) === Math.ceil((query.split(" ").length - 1) / 2))) return;
|
||||
|
||||
// The query length is too long to fit in json
|
||||
if(query.length > 100 - 51) return;
|
||||
|
||||
const row = new MessageActionRow()
|
||||
.addComponents(
|
||||
new MessageButton()
|
||||
.setEmoji('🔎')
|
||||
.setCustomId(JSON.stringify({
|
||||
module: 'MP_S',
|
||||
action: 'search',
|
||||
data: {
|
||||
q: query
|
||||
}
|
||||
}))
|
||||
.setLabel(' Not this? Search!')
|
||||
.setStyle('PRIMARY')
|
||||
)
|
||||
|
||||
return await sendMessageOrInteractionResponse(data, { embeds: [EMBEDS.ADDED_QUEUE(data, result[0])], components: [row] });
|
||||
}
|
||||
|
||||
return await sendMessageOrInteractionResponse(data, { embeds: [EMBEDS.ADDED_QUEUE(data, result[0])] });
|
||||
|
||||
Reference in New Issue
Block a user