Files
bot_Tamiseur/src/commands/salonpostam/papa.ts
Zachary Guénot ddd617317c
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 6m16s
Réécriture complète 4.0
2025-06-09 16:29:12 +02:00

35 lines
1.6 KiB
TypeScript
Executable File

import { SlashCommandBuilder } from "discord.js"
import type { ChatInputCommandInteraction, GuildMember } from "discord.js"
import { getVoiceConnection, joinVoiceChannel } from "@discordjs/voice"
import { t } from "@/utils/i18n"
export const data = new SlashCommandBuilder()
.setName("papa")
.setDescription("If daddy calls me, I join him")
.setDescriptionLocalizations({ fr: "Si papa m'appelle, je le rejoins" })
export async function execute(interaction: ChatInputCommandInteraction) {
if (interaction.user.id !== "223831938346123275") return interaction.reply({ content: t(interaction.locale, "salonpostam.papa.not_your_father") })
const guild = interaction.guild
if (!guild) return interaction.reply({ content: t(interaction.locale, "salonpostam.papa.no_dm") })
const member = interaction.member as GuildMember
const botChannel = guild.members.me?.voice.channel
const papaChannel = member.voice.channel
if (!papaChannel && botChannel) {
const voiceConnection = getVoiceConnection(guild.id)
if (voiceConnection) voiceConnection.destroy()
return interaction.reply({ content: t(interaction.locale, "salonpostam.papa.leaving_voice") })
} else if (papaChannel && (!botChannel || botChannel.id !== papaChannel.id)) {
joinVoiceChannel({
channelId: papaChannel.id,
guildId: papaChannel.guild.id,
adapterCreator: papaChannel.guild.voiceAdapterCreator,
})
return interaction.reply({ content: t(interaction.locale, "salonpostam.papa.joining_voice") })
} else return interaction.reply({ content: t(interaction.locale, "salonpostam.papa.already_connected") })
}