Support voice text channel

This commit is contained in:
2022-06-29 18:59:06 +07:00
parent 7d4b3add14
commit 6110dd876e
4 changed files with 17 additions and 9 deletions
+4 -2
View File
@@ -12,7 +12,9 @@ import {
TextChannel,
VoiceBasedChannel,
PermissionsBitField,
ButtonStyle
ButtonStyle,
BaseGuildTextChannel,
BaseGuildVoiceChannel
} from 'discord.js';
import { I18n } from 'i18n';
@@ -130,7 +132,7 @@ export async function joinVoiceChannelProcedure(
if (!member || !channel || !guild) return;
if (channel instanceof DMChannel) return;
if (!(channel instanceof TextChannel)) return;
if (!(channel instanceof BaseGuildTextChannel || channel instanceof BaseGuildVoiceChannel)) return;
const memberVoiceChannel = member.voice.channel; //isMessage ? member.voice.channel : DiscordProvider.client.guilds.cache.get(guild.id)!.members.cache.get((data as Interaction).user.id)?.voice.channel;
if (!memberVoiceChannel) return;
+1 -1
View File
@@ -261,7 +261,7 @@ class Discord {
// Handling mentions
this.client.on('messageCreate', async (message: Message) => {
// TODO: Handle DMs commands soon
if (!(message.channel instanceof TextChannel)) return;
if (!(message.channel instanceof BaseGuildTextChannel || message.channel instanceof BaseGuildVoiceChannel)) return;
if (message.author.bot) return;
if (typeof message.guild?.id === 'undefined') return;
+4 -3
View File
@@ -5,7 +5,8 @@ import {
StageChannel,
Guild,
PermissionsBitField,
BaseGuildVoiceChannel
BaseGuildVoiceChannel,
BaseGuildTextChannel
} from 'discord.js';
import {
AudioPlayer,
@@ -83,7 +84,7 @@ export enum DiscordMusicPlayerLoopMode {
export class DiscordMusicPlayerInstance {
public queue: Queue;
public player: AudioPlayer;
public textChannel?: TextChannel;
public textChannel?: BaseGuildTextChannel | BaseGuildVoiceChannel;
public voiceChannel: VoiceChannel | StageChannel;
public voiceConnection?: VoiceConnection;
public previousTrack?: ValidTracks;
@@ -151,7 +152,7 @@ export class DiscordMusicPlayerInstance {
return true;
}
public joinVoiceChannel(voiceChannel: VoiceChannel | StageChannel, textChannel?: TextChannel) {
public joinVoiceChannel(voiceChannel: VoiceChannel | StageChannel, textChannel?: BaseGuildTextChannel | BaseGuildVoiceChannel) {
const permissions = voiceChannel.permissionsFor(DiscordProvider.client.user!);
if (!permissions || !voiceChannel.joinable || !permissions.has(PermissionsBitField.Flags.Connect))
+8 -3
View File
@@ -12,7 +12,9 @@ import {
ColorResolvable,
Interaction,
InteractionReplyOptions,
BaseInteraction
BaseInteraction,
BaseGuildVoiceChannel,
VoiceChannel
} from 'discord.js';
import App from '..';
@@ -130,14 +132,17 @@ export function makeProcessingEmbed(data: EmbedDataPresets) {
}
export async function sendMessage(
channel: TextChannel | DMChannel | BaseGuildTextChannel | GuildTextBasedChannel | PartialDMChannel,
channel: TextChannel | DMChannel | BaseGuildTextChannel | GuildTextBasedChannel | PartialDMChannel | BaseGuildTextChannel | BaseGuildVoiceChannel,
user: User | undefined,
options: string | MessagePayload | MessageOptions
) {
let message;
try {
message = await channel.send(options);
if(channel instanceof BaseGuildVoiceChannel)
message = await (channel as VoiceChannel).send(options);
else
message = await channel.send(options);
} catch (error) {
if (typeof user === 'undefined') {
return Logger.error(