mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 18:59:19 +00:00
Added clear queue feature
This commit is contained in:
+2
-1
@@ -119,7 +119,8 @@
|
|||||||
"now_playing": "Now playing",
|
"now_playing": "Now playing",
|
||||||
"upcoming_song": "Upcoming song",
|
"upcoming_song": "Upcoming song",
|
||||||
"looping_current": "(Looping current)",
|
"looping_current": "(Looping current)",
|
||||||
"song_x_in_queue": "There are {{COUNT}} song in the queue!"
|
"song_x_in_queue": "There are {{COUNT}} song in the queue!",
|
||||||
|
"cleared": "Queue cleared~ (。•ˇ‸ˇ•。)"
|
||||||
},
|
},
|
||||||
"musicplayer_search": {
|
"musicplayer_search": {
|
||||||
"title": "Search",
|
"title": "Search",
|
||||||
|
|||||||
+2
-1
@@ -119,7 +119,8 @@
|
|||||||
"now_playing": "再生中",
|
"now_playing": "再生中",
|
||||||
"upcoming_song": "次の曲",
|
"upcoming_song": "次の曲",
|
||||||
"looping_current": "(この曲の繰り返し)",
|
"looping_current": "(この曲の繰り返し)",
|
||||||
"song_x_in_queue": "{{COUNT}}曲も並んでいますよ。"
|
"song_x_in_queue": "{{COUNT}}曲も並んでいますよ。",
|
||||||
|
"cleared": "キューがクリアされました (。•ˇ‸ˇ•。)"
|
||||||
},
|
},
|
||||||
"musicplayer_search": {
|
"musicplayer_search": {
|
||||||
"title": "検索",
|
"title": "検索",
|
||||||
|
|||||||
+2
-1
@@ -119,7 +119,8 @@
|
|||||||
"now_playing": "กำลังเล่น",
|
"now_playing": "กำลังเล่น",
|
||||||
"upcoming_song": "เพลงต่อไป",
|
"upcoming_song": "เพลงต่อไป",
|
||||||
"looping_current": "(กำลังวนซ้ำเพลงนี้)",
|
"looping_current": "(กำลังวนซ้ำเพลงนี้)",
|
||||||
"song_x_in_queue": "ตอนนี้มี {{COUNT}} เพลงอยู่ในคิว!"
|
"song_x_in_queue": "ตอนนี้มี {{COUNT}} เพลงอยู่ในคิว!",
|
||||||
|
"cleared": "เคลียร์คิวเรียบร้อยละ~ (。•ˇ‸ˇ•。)"
|
||||||
},
|
},
|
||||||
"musicplayer_search": {
|
"musicplayer_search": {
|
||||||
"title": "ค้นหา",
|
"title": "ค้นหา",
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import DiscordMusicPlayer, {
|
|||||||
import Locale from '../../services/Locale';
|
import Locale from '../../services/Locale';
|
||||||
|
|
||||||
import DiscordModule, { HybridInteractionMessage } from '../../utils/DiscordModule';
|
import DiscordModule, { HybridInteractionMessage } from '../../utils/DiscordModule';
|
||||||
import { makeErrorEmbed, sendHybridInteractionMessageResponse, makeInfoEmbed } from '../../utils/DiscordMessage';
|
import { makeErrorEmbed, sendHybridInteractionMessageResponse, makeSuccessEmbed, makeInfoEmbed } from '../../utils/DiscordMessage';
|
||||||
|
|
||||||
const EMBEDS = {
|
const EMBEDS = {
|
||||||
QUEUE: (data: HybridInteractionMessage, locale: I18n, instance: DiscordMusicPlayerInstance) => {
|
QUEUE: (data: HybridInteractionMessage, locale: I18n, instance: DiscordMusicPlayerInstance) => {
|
||||||
@@ -67,6 +67,12 @@ const EMBEDS = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
QUEUE_CLEARED: (data: HybridInteractionMessage, locale: I18n) => {
|
||||||
|
return makeSuccessEmbed({
|
||||||
|
title: locale.__('musicplayer_queue.cleared'),
|
||||||
|
user: data.getUser()
|
||||||
|
});
|
||||||
|
},
|
||||||
NO_MUSIC_PLAYING: (data: HybridInteractionMessage, locale: I18n) => {
|
NO_MUSIC_PLAYING: (data: HybridInteractionMessage, locale: I18n) => {
|
||||||
return makeErrorEmbed({
|
return makeErrorEmbed({
|
||||||
title: locale.__('musicplayer.no_music_playing'),
|
title: locale.__('musicplayer.no_music_playing'),
|
||||||
@@ -89,10 +95,11 @@ export default class QueueCommand extends DiscordModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async run(data: HybridInteractionMessage, args: any) {
|
async run(data: HybridInteractionMessage, args: any) {
|
||||||
const guild = data.getGuild();
|
|
||||||
|
|
||||||
|
const guild = data.getGuild();
|
||||||
if (!guild) return;
|
if (!guild) return;
|
||||||
|
|
||||||
|
let query;
|
||||||
const locale = await Locale.getGuildLocale(guild.id);
|
const locale = await Locale.getGuildLocale(guild.id);
|
||||||
|
|
||||||
const instance = DiscordMusicPlayer.getGuildInstance(guild.id);
|
const instance = DiscordMusicPlayer.getGuildInstance(guild.id);
|
||||||
@@ -101,8 +108,20 @@ export default class QueueCommand extends DiscordModule {
|
|||||||
embeds: [EMBEDS.NO_MUSIC_PLAYING(data, locale)]
|
embeds: [EMBEDS.NO_MUSIC_PLAYING(data, locale)]
|
||||||
});
|
});
|
||||||
|
|
||||||
await sendHybridInteractionMessageResponse(data, { embeds: [EMBEDS.QUEUE(data, locale, instance)] });
|
if (data.isMessage()) {
|
||||||
|
if (args.length === 0)
|
||||||
|
return await sendHybridInteractionMessageResponse(data, { embeds: [EMBEDS.QUEUE(data, locale, instance)] });
|
||||||
|
|
||||||
return;
|
query = args.join(' ');
|
||||||
|
} else if (data.isApplicationCommand()) {
|
||||||
|
//query = data.getSlashCommand().options.get('query', true).value?.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!query) return;
|
||||||
|
if(query.toLowerCase() !== 'clear') return;
|
||||||
|
|
||||||
|
instance.clearQueue();
|
||||||
|
|
||||||
|
return await sendHybridInteractionMessageResponse(data, { embeds: [EMBEDS.QUEUE_CLEARED(data, locale)] });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -217,20 +217,6 @@ export class DiscordMusicPlayerInstance {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public isReady() {
|
|
||||||
if (!this.voiceConnection) return false;
|
|
||||||
return this.voiceConnection.state.status === VoiceConnectionStatus.Ready;
|
|
||||||
}
|
|
||||||
|
|
||||||
public isConnected() {
|
|
||||||
if (!this.voiceConnection) return false;
|
|
||||||
|
|
||||||
if (this.voiceConnection.state.status === VoiceConnectionStatus.Destroyed) return false;
|
|
||||||
if (this.voiceConnection.state.status === VoiceConnectionStatus.Disconnected) return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public joinVoiceChannel(voiceChannel: VoiceChannel | StageChannel, textChannel?: BaseGuildTextChannel | BaseGuildVoiceChannel) {
|
public joinVoiceChannel(voiceChannel: VoiceChannel | StageChannel, textChannel?: BaseGuildTextChannel | BaseGuildVoiceChannel) {
|
||||||
const permissions = voiceChannel.permissionsFor(DiscordProvider.client.user!);
|
const permissions = voiceChannel.permissionsFor(DiscordProvider.client.user!);
|
||||||
|
|
||||||
@@ -350,6 +336,13 @@ export class DiscordMusicPlayerInstance {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public clearQueue() {
|
||||||
|
if (!this.voiceConnection) throw new Error('No voice connection');
|
||||||
|
|
||||||
|
if(!this.queue.track || this.queue.track.length === 0) return;
|
||||||
|
this.queue.track = [this.queue.track[0]];
|
||||||
|
}
|
||||||
|
|
||||||
public setLoopMode(mode: DiscordMusicPlayerLoopMode) {
|
public setLoopMode(mode: DiscordMusicPlayerLoopMode) {
|
||||||
this.loopMode = mode;
|
this.loopMode = mode;
|
||||||
}
|
}
|
||||||
@@ -366,6 +359,20 @@ export class DiscordMusicPlayerInstance {
|
|||||||
return this.actualPlaybackURL;
|
return this.actualPlaybackURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public isReady() {
|
||||||
|
if (!this.voiceConnection) return false;
|
||||||
|
return this.voiceConnection.state.status === VoiceConnectionStatus.Ready;
|
||||||
|
}
|
||||||
|
|
||||||
|
public isConnected() {
|
||||||
|
if (!this.voiceConnection) return false;
|
||||||
|
|
||||||
|
if (this.voiceConnection.state.status === VoiceConnectionStatus.Destroyed) return false;
|
||||||
|
if (this.voiceConnection.state.status === VoiceConnectionStatus.Disconnected) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public isPaused() {
|
public isPaused() {
|
||||||
return this.paused;
|
return this.paused;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user