mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 18:59:19 +00:00
Handle manual disconnect
This commit is contained in:
@@ -3,7 +3,7 @@ import { getEmotes, makeSuccessEmbed, makeErrorEmbed, sendMessage, sendMessageOr
|
||||
import DiscordProvider from "../../providers/Discord";
|
||||
import Users from "../../services/Users"
|
||||
import Environment from "../../providers/Environment";
|
||||
import DiscordMusicPlayer, { PlayerPlayingEvent, ValidTracks, DiscordMusicPlayerInstance } from "../../providers/DiscordMusicPlayer";
|
||||
import DiscordMusicPlayer, { PlayerPlayingEvent, PlayerErrorEvent, VoiceDisconnectedEvent, ValidTracks, DiscordMusicPlayerInstance } from "../../providers/DiscordMusicPlayer";
|
||||
import Discord from "../../providers/Discord";
|
||||
|
||||
const EMBEDS = {
|
||||
@@ -14,6 +14,13 @@ const EMBEDS = {
|
||||
user: (data instanceof Interaction) ? data.user : data.author
|
||||
});
|
||||
},
|
||||
VOICECHANNEL_DISCONNECTED: (data: Message | Interaction) => {
|
||||
return makeSuccessEmbed({
|
||||
title: `Disconnected`,
|
||||
description: `I got disconnected from the voice channel`,
|
||||
user: (data instanceof Interaction) ? data.user : data.author
|
||||
});
|
||||
},
|
||||
VOICECHANNEL_INUSE: (data: Message | Interaction) => {
|
||||
|
||||
let haveForceMove = (data instanceof Message) ? (data as Message).member!.permissions.has([Permissions.FLAGS.MOVE_MEMBERS]) : ((data as Interaction).member! as GuildMember).permissions.has([Permissions.FLAGS.MOVE_MEMBERS]);
|
||||
@@ -40,6 +47,13 @@ const EMBEDS = {
|
||||
user: (data instanceof Interaction) ? data.user : data.author
|
||||
});
|
||||
},
|
||||
MUSIC_ERROR: (data: Message | Interaction, err: Error) => {
|
||||
return makeErrorEmbed({
|
||||
title: `Error`,
|
||||
description: `${err.message}`,
|
||||
user: (data instanceof Interaction) ? data.user : data.author
|
||||
});
|
||||
},
|
||||
NOW_PLAYING: (data: Message | Interaction, track: ValidTracks) => {
|
||||
const embed = makeInfoEmbed({
|
||||
title: ' Now playing',
|
||||
@@ -151,7 +165,19 @@ export async function joinVoiceChannelProcedure (data: Interaction | Message, in
|
||||
if (event.instance.textChannel) {
|
||||
await sendMessage(event.instance.textChannel, undefined, { embeds: [EMBEDS.NOW_PLAYING(data, event.instance.queue.track[0])], components: [row] });
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
instance.events.on('error', async (event: PlayerErrorEvent) => {
|
||||
if (event.instance.textChannel) {
|
||||
await sendMessage(event.instance.textChannel, undefined, { embeds: [EMBEDS.MUSIC_ERROR(data, event.error)] });
|
||||
}
|
||||
});
|
||||
|
||||
instance.events.on('disconnect', async (event: VoiceDisconnectedEvent) => {
|
||||
if (event.instance.textChannel) {
|
||||
await sendMessage(event.instance.textChannel, undefined, { embeds: [EMBEDS.VOICECHANNEL_DISCONNECTED(data)] });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default class Join {
|
||||
|
||||
Reference in New Issue
Block a user