Beispiel #1
0
        public static async void Lock(SocketGuildUser moderator, ITextChannel channel)
        {
            //Lock 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.AddPermissionOverwriteAsync(guild.EveryoneRole, new OverwritePermissions(readMessageHistory : PermValue.Allow, sendMessages : PermValue.Deny, addReactions : PermValue.Deny), RequestOptions.Default);
                }
                catch
                {
                    Processing.LogConsoleText($"Failed to lock {guild.Name}#{channel.Name.ToString()}", guild.Id);
                }
            }

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

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

            if (botlog != null)
            {
                await botlog.SendMessageAsync("", embed : embed).ConfigureAwait(false);
            }
        }