Skip to content

Commit

Permalink
🩹Change of confirmation position
Browse files Browse the repository at this point in the history
  • Loading branch information
MotiCAT committed Dec 4, 2023
1 parent 5b7be8b commit bf9cb97
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
21 changes: 16 additions & 5 deletions src/Events/onMessageCreate.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
import { commands } from '../commands';
import { embeds } from '../embeds';
import { Message, Awaitable } from 'discord.js';
import { Message, Awaitable, ChannelType } from 'discord.js';

const prefix = 'ts!';

export async function onMessageCreate(message: Message): Promise<Awaitable<void>> {
if (message.author.bot || !message.content.startsWith(prefix) || !message.guild) return;
const args = message.content.slice(prefix.length).trim().split(/ +/) as string[];
const commandName = args.shift()?.toLowerCase();
if (commandName === 'help' || commandName === 'h') return commands.help(message);
const channel = message.member?.voice.channel;
if (!channel) {
message.reply(embeds.voiceChannelJoin);
return;
}
if (channel.type !== ChannelType.GuildVoice) return;
if (!channel.joinable) {
message.reply(embeds.voiceChannnelJoined);
return;
}
if (!channel.speakable) {
message.reply(embeds.voiceChannnelPermission);
return;
}

switch (commandName) {
case 'play':
Expand Down Expand Up @@ -41,10 +56,6 @@ export async function onMessageCreate(message: Message): Promise<Awaitable<void>
case 'list':
commands.queue(message);
break;
case 'help':
case 'h':
commands.help(message);
break;
case 'volume':
case 'vol':
case 'v':
Expand Down
7 changes: 1 addition & 6 deletions src/commands/play.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { YTPlayer } from '../classes/player';
import { Queue, queueManager } from '../classes/queue';
import { embeds } from '../embeds';
import { Message, ChannelType, VoiceBasedChannel } from 'discord.js';
import { Message, VoiceBasedChannel } from 'discord.js';
import ytdl from 'ytdl-core';

export let player: YTPlayer | undefined;
Expand All @@ -21,13 +21,8 @@ export async function playCommand(message: Message) {
);
}
url = message.content.split(' ')[1];
const channel = message.member?.voice.channel;
if (!url) return message.reply(embeds.noUrl);
if (!ytdl.validateURL(url)) return message.reply(embeds.invaildUrl);
if (!channel) return message.reply(embeds.voiceChannelJoin);
if (channel.type !== ChannelType.GuildVoice) return;
if (!channel.joinable) return message.reply(embeds.voiceChannnelJoined);
if (!channel.speakable) return message.reply(embeds.voiceChannnelPermission);

if (!queue.length || !player.isPlaying) {
queue.addSong(url);
Expand Down

0 comments on commit bf9cb97

Please sign in to comment.