forked from MotiCAT/TuneNekoSync
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request MotiCAT#14 from MotiCAT/dev
おめでとうございます!あなたは検索コマンドと細かいバグ修正を受け取りました!
- Loading branch information
Showing
33 changed files
with
201 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto eol=lf |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { embeds } from '../embeds'; | ||
import { Message } from 'discord.js'; | ||
|
||
export async function helpCommand(message: Message): Promise<void> { | ||
message.reply(embeds.help); | ||
export async function helpCommand(message: Message) { | ||
return message.reply(embeds.help); | ||
} |
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
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
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
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,28 @@ | ||
import { embeds } from '../embeds'; | ||
import { Message, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, ActionRowBuilder } from 'discord.js'; | ||
import ytsr from 'youtube-sr'; | ||
|
||
export async function searchCommand(message: Message) { | ||
const videos = await ytsr.search(message.content.split(' ').slice(1).join(' '), { | ||
type: 'video' | ||
}); | ||
|
||
if (!videos.length) return message.reply(embeds.noResult); | ||
|
||
const menu = new StringSelectMenuBuilder() | ||
.setCustomId('search') | ||
.setPlaceholder('Select a video') | ||
.addOptions( | ||
videos.map((video, index) => | ||
new StringSelectMenuOptionBuilder() | ||
.setLabel(`${index + 1}. ${video.title}`) | ||
.setValue(video.url) | ||
.setDescription(String(video.durationFormatted)) | ||
.setEmoji('🎵') | ||
) | ||
); | ||
|
||
const row = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(menu); | ||
|
||
message.reply({ content: 'Select a video', components: [row] }); | ||
} |
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
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
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,68 @@ | ||
import { YTPlayer } from '../classes/player'; | ||
import { Queue, queueManager } from '../classes/queue'; | ||
import { embeds } from '../embeds'; | ||
import { client } from '../index'; | ||
import { StringSelectMenuInteraction, ChannelType, VoiceBasedChannel, GuildMember } from 'discord.js'; | ||
import ytdl from 'ytdl-core'; | ||
|
||
let url: string; | ||
|
||
export async function searchPlayCommand(interaction: StringSelectMenuInteraction) { | ||
let player = client?.player; | ||
if (!queueManager.getQueue(interaction.guild?.id as string)) { | ||
queueManager.setQueue(interaction.guild?.id as string, new Queue()); | ||
} | ||
const queue = queueManager.getQueue(interaction.guild?.id as string) as Queue; | ||
if (!interaction.channel) return; | ||
if (!(interaction.member instanceof GuildMember)) return; | ||
if (!player) { | ||
client.player = new YTPlayer( | ||
interaction.guild?.id as string, | ||
interaction.member?.voice.channel as VoiceBasedChannel, | ||
interaction.channel?.id | ||
); | ||
player = client.player; | ||
} | ||
|
||
url = interaction.values[0]; | ||
const channel = interaction.member?.voice.channel; | ||
if (!url) return interaction.reply(embeds.noUrl); | ||
if (!ytdl.validateURL(url)) return interaction.reply(embeds.invaildUrl); | ||
if (!channel) return interaction.reply(embeds.voiceChannelJoin); | ||
if (channel.type !== ChannelType.GuildVoice) return; | ||
if (!channel.joinable) return interaction.reply(embeds.voiceChannnelJoined); | ||
if (!channel.speakable) return interaction.reply(embeds.voiceChannnelPermission); | ||
|
||
if (!queue.length || !player.isPlaying) { | ||
queue.addSong(url); | ||
const info = await ytdl.getInfo(url); | ||
interaction.reply( | ||
new embeds.embed() | ||
.setTitle('Success') | ||
.setDescription(`**[${info.videoDetails.title}](${info.videoDetails.video_url})を再生します。**`) | ||
.addFields({ | ||
name: info.videoDetails.title, | ||
value: `投稿者: [${info.videoDetails.author.name}](${info.videoDetails.author.channel_url})` | ||
}) | ||
.setImage(info.videoDetails.thumbnails[0].url.split('?')[0]) | ||
.setColor('Green') | ||
.build() | ||
); | ||
if (queue.length === 1) return player.play(); | ||
} else { | ||
queue.addSong(url); | ||
const info = await ytdl.getInfo(url); | ||
interaction.reply( | ||
new embeds.embed() | ||
.setTitle('Info') | ||
.setDescription(`**[${info.videoDetails.title}](${info.videoDetails.video_url})をキューに追加しました。**`) | ||
.addFields({ | ||
name: info.videoDetails.title, | ||
value: `投稿者: [${info.videoDetails.author.name}](${info.videoDetails.author.channel_url})` | ||
}) | ||
.setImage(info.videoDetails.thumbnails[0].url.split('?')[0]) | ||
.setColor('Yellow') | ||
.build() | ||
); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { embeds } from '../embeds'; | ||
import { ChatInputCommandInteraction } from 'discord.js'; | ||
|
||
export async function helpCommand(interaction: ChatInputCommandInteraction): Promise<void> { | ||
export async function helpCommand(interaction: ChatInputCommandInteraction) { | ||
interaction.reply(embeds.help); | ||
} |
Oops, something went wrong.