Refactoring and patches
This commit is contained in:
1 parent
7c438ed37b
commit
4368353a1e
32 files changed
+772
-544
No files matched your search
@@ -0,0 +1,49 @@
|
||||
import { design } from "../../config";
|
||||
|
||||
import { ColorResolvable, CommandInteraction, GuildMember, MessageEmbed, TextChannel } from "discord.js";
|
||||
import { MyClient } from "../../types/Client";
|
||||
|
||||
|
||||
|
||||
export async function run(client: MyClient, ctx: CommandInteraction, reply = true) {
|
||||
if (ctx.guild === null)
|
||||
return;
|
||||
|
||||
if (reply)
|
||||
await ctx.deferReply();
|
||||
|
||||
const player = client.players.genPlayer(ctx.guild, client.players, ctx.channel as TextChannel);
|
||||
|
||||
let embed = new MessageEmbed()
|
||||
.setColor(design.color as ColorResolvable)
|
||||
.setTitle("Mistake in connection.")
|
||||
|
||||
if (!player.connection) {
|
||||
const channel = (ctx.member as GuildMember).voice.channel;
|
||||
if (channel) {
|
||||
await player.connect(channel);
|
||||
|
||||
embed.setTitle(`Successfully connected to ${channel.name}.`)
|
||||
}
|
||||
else {
|
||||
client.players.delPlayer(ctx.guild.id);
|
||||
|
||||
embed.setTitle("Please connect to a voice channel.")
|
||||
}
|
||||
}
|
||||
else {
|
||||
embed.setTitle("Already connected to ${channel.name}..")
|
||||
}
|
||||
|
||||
if (reply)
|
||||
await ctx.editReply({ embeds: [embed] });
|
||||
else
|
||||
return player;
|
||||
}
|
||||
|
||||
const data = {
|
||||
name: "connect",
|
||||
description: "Connect to voice channel."
|
||||
}
|
||||
|
||||
export { data }
|
||||
Reference in new issue
Block a user