Exemple #1
0
        public static async void PruneNonmembers(SocketGuildUser moderator, ITextChannel channel, IReadOnlyCollection <IGuildUser> users)
        {
            int usersPruned = 0;

            foreach (IGuildUser user in users)
            {
                if (user.RoleIds.Count <= 1)
                {
                    Processing.LogConsoleText($"Nonmember found: {user.Username}", channel.Guild.Id);
                    await user.KickAsync("Inactivity");

                    usersPruned++;
                }
            }

            var embed = Embeds.PruneNonmembers(usersPruned);
            await channel.SendMessageAsync("", embed : embed).ConfigureAwait(false);

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

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