Пример #1
0
        private async Task OnUserVoiceStateUpdated(SocketUser user,
                                                   SocketVoiceState state_1,
                                                   SocketVoiceState state_2)
        {
            if (user.IsBot)
            {
                return;
            }

            var channel = _actions.GetChannelFromConfig(Constants.VOICE_CHANNEL);

            if (state_1.VoiceChannel == null && state_2.VoiceChannel != null)
            {
                var log = new LogMessage(LogSeverity.Verbose, "Bot",
                                         $"{user.Username} joined voice channel {state_2.VoiceChannel.Name}. " +
                                         $"Users in channel: {state_2.VoiceChannel.Users.Count(u => !u.IsBot)}.");
                await _logger.LogAsync(log);

                await _actions.SetChannelViewPermissionAsync(user, channel, false);

                await _actions.SendDirectMessageAsync(user,
                                                      $"You now have access to {channel.Mention}. " +
                                                      "You can use it to discuss puzzles with the other users in the voice chat " +
                                                      "and it will be wiped when everyone leaves the voice chat.");
            }
            else if (state_1.VoiceChannel != null && state_2.VoiceChannel == null)
            {
                var log = new LogMessage(LogSeverity.Verbose, "Bot",
                                         $"{user.Username} left voice channel {state_1.VoiceChannel.Name}. " +
                                         $"Users in channel: {state_1.VoiceChannel.Users.Count(u => !u.IsBot)}.");
                await _logger.LogAsync(log);

                await _actions.SetChannelViewPermissionAsync(user, channel, true);

                if (state_1.VoiceChannel.Users.Count(u => !u.IsBot) == 0)
                {
                    await _actions.PurgeChannel(channel);
                }
            }
        }
Пример #2
0
        public async Task Purge(ITextChannel channel)
        {
            await _actions.PurgeChannel(channel);

            await ReplyAsync($"Channel {channel.Mention} purged.");
        }