style: run format:apply

This commit is contained in:
2026-01-13 17:53:31 -03:00
parent 83569a27e7
commit 2ec7212cd3
5 changed files with 97 additions and 83 deletions
+27 -14
View File
@@ -1,10 +1,19 @@
import { ChatInputCommandInteraction, GuildMember, SlashCommandBuilder } from "discord.js"; import {
import { Command } from "../../commands"; ChatInputCommandInteraction,
import { CreateVoiceConnectionOptions, getVoiceConnection, joinVoiceChannel, JoinVoiceChannelOptions } from "@discordjs/voice"; GuildMember,
SlashCommandBuilder
} from 'discord.js';
import { Command } from '../../commands';
import {
CreateVoiceConnectionOptions,
getVoiceConnection,
joinVoiceChannel,
JoinVoiceChannelOptions
} from '@discordjs/voice';
const builder = new SlashCommandBuilder() const builder = new SlashCommandBuilder()
.setName("join") .setName('join')
.setDescription("Makes the bot join your current voice channel"); .setDescription('Makes the bot join your current voice channel');
const cmd: Command = { const cmd: Command = {
name: builder.name, name: builder.name,
@@ -12,23 +21,27 @@ const cmd: Command = {
execute: async (interaction: ChatInputCommandInteraction): Promise<void> => { execute: async (interaction: ChatInputCommandInteraction): Promise<void> => {
const member = interaction.member as GuildMember; const member = interaction.member as GuildMember;
if (!member || !interaction.guild) { if (!member || !interaction.guild) {
interaction.reply("This command only works on guilds"); interaction.reply('This command only works on guilds');
return; return;
} }
if (!member.voice.channelId) { if (!member.voice.channelId) {
interaction.reply("You are not currently on a voice channel"); interaction.reply('You are not currently on a voice channel');
return; return;
} }
const me = interaction.guild.members.me as GuildMember; const me = interaction.guild.members.me as GuildMember;
if (getVoiceConnection(interaction.guild.id) && me.voice.channelId === member.voice.channelId) { if (
interaction.reply("Already connected"); getVoiceConnection(interaction.guild.id) &&
me.voice.channelId === member.voice.channelId
) {
interaction.reply('Already connected');
return; return;
} }
const voiceOptions: JoinVoiceChannelOptions & CreateVoiceConnectionOptions = { const voiceOptions: JoinVoiceChannelOptions & CreateVoiceConnectionOptions =
{
channelId: member.voice.channelId, channelId: member.voice.channelId,
guildId: interaction.guild.id, guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator adapterCreator: interaction.guild.voiceAdapterCreator
@@ -36,12 +49,12 @@ const cmd: Command = {
const connection = await joinVoiceChannel(voiceOptions); const connection = await joinVoiceChannel(voiceOptions);
if (!connection) { if (!connection) {
interaction.reply("Unable to join"); interaction.reply('Unable to join');
return return;
} }
interaction.reply("Joined"); interaction.reply('Joined');
}
} }
};
export default cmd; export default cmd;
+13 -9
View File
@@ -1,10 +1,14 @@
import { ChatInputCommandInteraction, GuildMember, SlashCommandBuilder } from "discord.js"; import {
import { Command } from "../../commands"; ChatInputCommandInteraction,
import { getVoiceConnection } from "@discordjs/voice"; GuildMember,
SlashCommandBuilder
} from 'discord.js';
import { Command } from '../../commands';
import { getVoiceConnection } from '@discordjs/voice';
const builder = new SlashCommandBuilder() const builder = new SlashCommandBuilder()
.setName("leave") .setName('leave')
.setDescription("Makes the bot leave its current voice channel"); .setDescription('Makes the bot leave its current voice channel');
const cmd: Command = { const cmd: Command = {
name: builder.name, name: builder.name,
@@ -12,21 +16,21 @@ const cmd: Command = {
execute: async (interaction: ChatInputCommandInteraction): Promise<void> => { execute: async (interaction: ChatInputCommandInteraction): Promise<void> => {
const member = interaction.member as GuildMember; const member = interaction.member as GuildMember;
if (!member || interaction.guild === null) { if (!member || interaction.guild === null) {
interaction.reply("This command only works on guilds"); interaction.reply('This command only works on guilds');
return; return;
} }
const connection = getVoiceConnection(interaction.guildId as string); const connection = getVoiceConnection(interaction.guildId as string);
if (!connection) { if (!connection) {
interaction.reply('currently not connected to a voice channel') interaction.reply('currently not connected to a voice channel');
return; return;
} }
connection.disconnect(); connection.disconnect();
connection.destroy(); connection.destroy();
interaction.reply("Disconnected"); interaction.reply('Disconnected');
}
} }
};
export default cmd; export default cmd;
+7 -10
View File
@@ -1,6 +1,6 @@
import { VoiceState } from "discord.js"; import { VoiceState } from 'discord.js';
import { Command } from "../../commands"; import { Command } from '../../commands';
import { getVoiceConnection } from "@discordjs/voice"; import { getVoiceConnection } from '@discordjs/voice';
const cmd: Command = { const cmd: Command = {
voiceStateListener: async function (oldState: VoiceState): Promise<void> { voiceStateListener: async function (oldState: VoiceState): Promise<void> {
@@ -11,18 +11,15 @@ const cmd: Command = {
if (!voiceConnection) return; if (!voiceConnection) return;
const me = guild.members.me; const me = guild.members.me;
if (!me) if (!me) return;
return;
if (!me.voice.channel) if (!me.voice.channel) return;
return;
if (me.voice.channel.members.size > 1) if (me.voice.channel.members.size > 1) return;
return;
voiceConnection.disconnect(); voiceConnection.disconnect();
voiceConnection.destroy(); voiceConnection.destroy();
} }
} };
export default cmd; export default cmd;