Esempio n. 1
0
        public void Invoke(CommandHandler handler, CommandEventArgs args)
        {
            if (DClient.UserManager[args.User.Id] != null)
            {
                args.Channel.SendEmbedMessage("You already linked your account!").ConfigureAwait(false);
                return;
            }

            var dmChannel = DClient.GetDmChanelAsync(args.User.Id).ConfigureAwait(false).GetAwaiter().GetResult();

            if (_verificationUsers.TryGetValue(args.User.Id, out string verCode))
            {
                if (dmChannel == null)
                {
                    args.Channel.SendEmbedMessage("Verification code already created").ConfigureAwait(false);
                    return;
                }

                dmChannel.SendEmbedMessage($"Verification code already created: {verCode}").ConfigureAwait(false);
                return;
            }

            if (dmChannel == null)
            {
                args.Channel.SendEmbedMessage("Unable to open direct message channel").ConfigureAwait(false);
                return;
            }

            verCode = GenerateCode(Utility.Random(6, 4));
            _verificationCodes.TryAdd(verCode, args.User.Id);
            _verificationUsers.TryAdd(args.User.Id, verCode);

            dmChannel.SendEmbedMessage($"Verification code created, login onto any of your characters (in UO) and type the following (Code is Case-Sensitive): [linkaccount {verCode}").ConfigureAwait(false);

            if (args.Guild != null)
            {
                args.Message.DeleteAsync().ConfigureAwait(false);
            }
        }