Exemple #1
0
        //Grant a user a role if they type the password in the verification channel
        public static async Task VerificationCheck(SocketMessage message)
        {
            var user  = (IGuildUser)message.Author;
            var guild = user.Guild;

            if (Setup.IsVerificationChannel((IGuildChannel)message.Channel))
            {
                if (message.Content.ToLower() == UserSettings.Verification.VerificationMessage(guild.Id).ToLower())
                {
                    await message.DeleteAsync();

                    ulong memberRoleId = UserSettings.Verification.MemberRoleID(guild.Id);
                    if (memberRoleId != 0)
                    {
                        var memberRole = user.Guild.GetRole(memberRoleId);
                        await user.AddRoleAsync(memberRole);

                        var embed  = Embeds.LogMemberAdd(user);
                        var user2  = (SocketGuildUser)user;
                        var botlog = (ITextChannel)user2.Guild.GetChannel(UserSettings.Channels.BotLogsId(user.Guild.Id));
                        await botlog.SendMessageAsync("", embed : embed).ConfigureAwait(false);
                    }
                    else
                    {
                        await message.Channel.SendMessageAsync("Attempted to give the new member a role, but it has to be configured first!");
                    }
                }
                else
                {
                    await message.DeleteAsync();
                }
            }
        }