Example #1
0
        private async Task AddVoiceAsync(
            CommandContext ctx,
            string name,
            int limit = 0
            )
        {
            try
            {
                await ctx.TriggerTypingAsync();

                if (!InValidChannel(ctx.Channel))
                {
                    await ctx.Message.CreateReactionAsync(DiscordEmoji.FromName(ctx.Client, ":-1:"));

                    return;
                }

                await _voiceManager.AddNewVoiceChannelAsync(ctx.Guild.GetChannel(_voiceConfig.ClickChannelId),
                                                            ctx.Member, name, limit);

                await ctx.Message.CreateReactionAsync(DiscordEmoji.FromName(ctx.Client, ":+1:"));
            }
            catch (Exception e)
            {
                _logger.LogWarning(e, "Couldn't add a voice channel");
            }
        }
Example #2
0
        public async Task <EventHandlerResult> Handle(VoiceStateUpdateEventArgs args)
        {
            if (args.After.Channel?.Id == _voiceConfig.ClickChannelId)
            {
                await _voiceManager.AddNewVoiceChannelAsync(args.Channel,
                                                            await args.Guild.GetMemberAsync(args.User.Id));
            }

            if (args.Before?.Channel != null)
            {
                if (args.Before.Channel.Id != _voiceConfig.ClickChannelId)
                {
                    await _voiceManager.DeleteUnusedVoiceChannelAsync(args.Before.Channel);
                }
            }

            return(EventHandlerResult.Continue);
        }
Example #3
0
        public async Task AddVoiceChannel(
            CommandContext ctx,
            [Description("Name of the channel.")] string name,
            [Description("Limit number of members who can join.")]
            int limit = 0
            )
        {
            await ctx.TriggerTypingAsync();

            if (!InValidChannel(ctx.Channel))
            {
                await ctx.Message.CreateReactionAsync(DiscordEmoji.FromName(ctx.Client, ":-1:"));

                return;
            }

            await _voiceManager.AddNewVoiceChannelAsync(ctx.Guild.GetChannel(_voiceConfig.ClickChannelId),
                                                        ctx.Member, name, limit);

            await ctx.Message.CreateReactionAsync(DiscordEmoji.FromName(ctx.Client, ":+1:"));
        }