diff --git a/5a0b-bot.njsproj b/5a0b-bot.njsproj index 6b711e4..536e4b6 100644 --- a/5a0b-bot.njsproj +++ b/5a0b-bot.njsproj @@ -69,6 +69,9 @@ Code + + Code + diff --git a/src/commands/music/clear.ts b/src/commands/music/clear.ts index f52229b..6a2b454 100644 --- a/src/commands/music/clear.ts +++ b/src/commands/music/clear.ts @@ -5,7 +5,6 @@ import { MyClient } from "../../types/Client"; - export async function run(client: MyClient, ctx: CommandInteraction) { await ctx.deferReply(); if (ctx.guild === null) diff --git a/src/commands/music/connect.ts b/src/commands/music/connect.ts index 6fe0988..f7004ae 100644 --- a/src/commands/music/connect.ts +++ b/src/commands/music/connect.ts @@ -1,6 +1,9 @@ import { design } from "../../config"; -import { ColorResolvable, CommandInteraction, GuildMember, MessageEmbed, TextChannel } from "discord.js"; +import { + ColorResolvable, CommandInteraction, GuildMember, + MessageEmbed, TextChannel +} from "discord.js"; import { MyClient } from "../../types/Client"; diff --git a/src/commands/music/pause.ts b/src/commands/music/pause.ts index 4f413dd..559c468 100644 --- a/src/commands/music/pause.ts +++ b/src/commands/music/pause.ts @@ -1,9 +1,7 @@ import { design } from "../../config"; -import { ButtonInteraction, ColorResolvable, CommandInteraction, Message, MessageActionRow, MessageButton, MessageEmbed } from "discord.js"; +import { ColorResolvable, CommandInteraction, MessageEmbed } from "discord.js"; import { MyClient } from "../../types/Client"; -import { generateQueue } from "../../types/Misc"; -import { EmojiIdentifierResolvable } from "discord.js"; @@ -22,8 +20,6 @@ export async function run(client: MyClient, ctx: CommandInteraction) { await ctx.reply({ embeds: [embed] }); } - - } const data = { diff --git a/src/commands/music/queue.ts b/src/commands/music/queue.ts index 051a458..1922a61 100644 --- a/src/commands/music/queue.ts +++ b/src/commands/music/queue.ts @@ -1,6 +1,11 @@ import { design } from "../../config"; -import { ButtonInteraction, CollectorFilter, ColorResolvable, CommandInteraction, Message, MessageActionRow, MessageButton, MessageComponentInteraction, MessageEmbed } from "discord.js"; +import { + ButtonInteraction, CollectorFilter, ColorResolvable, + CommandInteraction, Message, MessageActionRow, + MessageButton, MessageComponentInteraction, MessageEmbed +} from "discord.js"; + import { MyClient } from "../../types/Client"; import { generateQueue } from "../../types/Misc"; diff --git a/src/commands/music/stop.ts b/src/commands/music/stop.ts index aa679c8..bbd8700 100644 --- a/src/commands/music/stop.ts +++ b/src/commands/music/stop.ts @@ -20,8 +20,6 @@ export async function run(client: MyClient, ctx: CommandInteraction) { await ctx.reply({ embeds: [embed] }); } - - } const data = { diff --git a/src/events/voiceStateUpdate.ts b/src/events/voiceStateUpdate.ts new file mode 100644 index 0000000..674e5c8 --- /dev/null +++ b/src/events/voiceStateUpdate.ts @@ -0,0 +1,32 @@ +import { ColorResolvable, MessageEmbed, VoiceState } from "discord.js"; +import { design } from "../config"; +import { MyClient } from "../types/Client"; +import { sleep } from "../types/Misc"; + +export async function run(args: VoiceState[], client: MyClient): Promise { + const [oldState, newState] = args; + + const player = client.players.getPlayer(newState.guild.id); + + if (!player) + return; + + if (newState.id === client.user?.id && newState.deaf === false) { + newState.setDeaf(true); + + const embed = new MessageEmbed() + .setColor(design.color as ColorResolvable) + .setTitle("Please do not undeafen me.") + .setDescription("It's for your own privacy, trust me.") + await player.channel.send({ embeds: [embed] }); + } + + if (newState.channel?.members.size === 1 && newState.channel.members.first()) { + await sleep(30000); + if (newState.channel.members.first()?.id === client.user?.id) + player.destroy(); + } +} + + +export const name = "voiceStateUpdate"; \ No newline at end of file diff --git a/src/types/Client.ts b/src/types/Client.ts index 9072559..dd0036c 100644 --- a/src/types/Client.ts +++ b/src/types/Client.ts @@ -39,7 +39,5 @@ export class MyClient extends DiscordClient { }); }); } - } - } \ No newline at end of file