Esempio n. 1
0
        public static async void Unlock(SocketGuildUser moderator, ITextChannel channel)
        {
            //Unlock the channel
            var guild = channel.Guild;

            //Don't mess with channel permissions if nonmembers can't speak there anyway
            if (IsPublicChannel((SocketGuildChannel)channel))
            {
                try
                {
                    await channel.RemovePermissionOverwriteAsync(guild.EveryoneRole, RequestOptions.Default);
                }
                catch
                {
                    Processing.LogConsoleText($"Failed to unlock {guild.Name}#{channel.Name.ToString()}", guild.Id);
                }
            }

            //Announce the unlock
            var embed = Embeds.Unlock(channel);
            await channel.SendMessageAsync("", embed : embed).ConfigureAwait(false);

            //Log the lock in the bot-logs channel
            embed = Embeds.LogUnlock(moderator, channel);
            var botlog = await channel.Guild.GetTextChannelAsync(UserSettings.Channels.BotLogsId(channel.Guild.Id));

            if (botlog != null)
            {
                await botlog.SendMessageAsync("", embed : embed).ConfigureAwait(false);
            }
        }
Esempio n. 2
0
        public async Task VoiceStateChangeForText(SocketUser user, SocketVoiceState state1, SocketVoiceState state2)
        {
            if (state1.ToString() != state2.ToString())
            {
                ITextChannel leaveChannel = await GetAssocChannel((state1 as IVoiceState).VoiceChannel);

                ITextChannel joinChannel = await GetAssocChannel((state2 as IVoiceState).VoiceChannel);

                if (leaveChannel != null)
                {
                    await leaveChannel.RemovePermissionOverwriteAsync(user, channelAssoc);
                }
                if (joinChannel != null)
                {
                    await joinChannel.AddPermissionOverwriteAsync(user,
                                                                  new OverwritePermissions(viewChannel : PermValue.Allow, sendMessages : PermValue.Allow),
                                                                  channelAssoc);
                }
            }
        }