public async Task Notify()
        {
            var status = await _synthbotWebClient.GetDiscordUserStatus(Context.User.Id.ToString());

            await ReplyAsync("", false, EmbedFactory.Notifications.NotifyState(Context, status));

            var userResponse = await NextMessageAsync();

            if (userResponse != null)
            {
                DiscordUserStatus newStatus = default;
                if (userResponse.Content.ToLower() == "yes")
                {
                    newStatus = DiscordUserStatus.RegisteredWithNotify;
                }
                else if (userResponse.Content.ToLower() == "no")
                {
                    newStatus = DiscordUserStatus.RegisteredWithoutNotify;
                }

                if (newStatus != default)
                {
                    await _synthbotWebClient.SetDiscordUserStatus(Context.User.Id.ToString(), newStatus);
                }

                await ReplyAsync("", false, EmbedFactory.Notifications.NotifyUpdate(Context, newStatus, userResponse.Content));
            }
        }
예제 #2
0
        public async Task SetUserStatus(
            [Summary("Possible statuses: NoResponse, IgnoreForever, RemindMeLater, Registered, New")]
            DiscordUserStatus status)
        {
            var response = await _synthbotWebClient.SetDiscordUserStatus(Context.User.Id.ToString(), status);

            await ReplyAsync($"Success: {response}");
        }
예제 #3
0
            public static Embed NotifyState(SocketCommandContext context, DiscordUserStatus status)
            {
                var formattedStatus = status == DiscordUserStatus.RegisteredWithNotify
                                        ? $"Notifications are currently on for {context.User.Username}"
                                        : $"Notifications are currently off for {context.User.Username}";
                var currentStatus = new EmbedFieldBuilder()
                                    .WithName(formattedStatus)
                                    .WithValue("Would you like to change your notification status? (Reply with yes or no)")
                                    .WithIsInline(false);
                var embed = new EmbedBuilder()
                            .WithColor(Color.Green)
                            .WithAuthor(context.Client.CurrentUser)
                            .AddField(currentStatus);

                return(embed.Build());
            }
예제 #4
0
        public async Task <bool> SetDiscordUserStatus(string discordUserId, DiscordUserStatus status)
        {
            var request = new RestRequest("api/DiscordUser/SetStatus", Method.GET);

            request.AddParameter("discordUserId", discordUserId);
            request.AddParameter("status", status);

            var response = await ExecuteGetTaskAsync(request);

            if (response.IsSuccessful)
            {
                return(true);
            }

            return(false);
        }
예제 #5
0
            public static Embed NotifyUpdate(SocketCommandContext context, DiscordUserStatus status, string reply)
            {
                var embed = new EmbedBuilder()
                            .WithAuthorFromContext(context);

                switch (reply.ToLower())
                {
                case "yes":
                {
                    var updatedField = new EmbedFieldBuilder()
                                       .WithName($"Notification status for {context.User.Username} has been updated.")
                                       .WithValue("You are now receiving DM notifications from us.")
                                       .WithIsInline(false);
                    embed.AddField(updatedField);
                    embed.WithColor(Color.Green);
                    break;
                }

                case "no":
                {
                    var updatedField = new EmbedFieldBuilder()
                                       .WithName($"Notification status for {context.User.Username} has not been updated.")
                                       .WithValue("YYou will no longer receive DM notifications from us.")
                                       .WithIsInline(false);
                    embed.AddField(updatedField);
                    embed.WithColor(Color.Green);
                    break;
                }

                default:
                {
                    var updatedField = new EmbedFieldBuilder()
                                       .WithName($"Notification status for {context.User.Username} is unchanged.")
                                       .WithValue("Invalid response received.")
                                       .WithIsInline(false);
                    embed.AddField(updatedField);
                    embed.WithColor(Color.Red);
                    break;
                }
                }
                return(embed.Build());
            }
예제 #6
0
        internal DiscordUserPresence(Snowflake userId, DiscordApiData data)
        {
            UserId = userId;

            DiscordApiData gameData = data.Get("game");

            if (gameData != null)
            {
                if (gameData.IsNull)
                {
                    Game = null;
                }
                else
                {
                    Game = new DiscordGame(gameData);
                }
            }

            string statusStr = data.GetString("status");

            if (statusStr != null)
            {
                DiscordUserStatus?status = Utils.ParseUserStatus(statusStr);

                if (!status.HasValue)
                {
                    // If we don't have a value for the status yet,
                    // we at least know that they aren't offline.
                    Status = DiscordUserStatus.Online;

                    // However, this should issue a warning.
                    DiscoreLogger.Global.LogWarning($"[DiscordUserPresence] Failed to deserialize status for user {UserId}. " +
                                                    $"status = {statusStr}");
                }
                else
                {
                    Status = status.Value;
                }
            }
        }
예제 #7
0
        public async Task <IActionResult> SetStatus(string discordUserId, DiscordUserStatus status)
        {
            var discordUser = await _discordUserRepo.GetById(discordUserId);

            if (discordUser == null)
            {
                await _discordUserRepo.Upsert(new DiscordUser()
                {
                    DiscordUserId = discordUserId,
                    InvitedTs     = DateTime.UtcNow,
                    UserStatus    = status
                });

                return(Ok());
            }
            else
            {
                discordUser.UserStatus = status;
                await _discordUserRepo.Upsert(discordUser);

                return(Ok());
            }
        }
예제 #8
0
		public void ChangeStatus(string game, DiscordUserStatus? status)
		{

		}
예제 #9
0
		public void ChangeStatus(DiscordUserStatus status)
		{

		}
예제 #10
0
 /// <summary>
 /// Sets the status of the bot.
 /// </summary>
 public StatusOptions SetStatus(DiscordUserStatus status)
 {
     Status = status;
     return(this);
 }
 private async Task <SynthbotUser> GetSynthbotUserIfExists(string discordUserId, DiscordUserStatus status)
 {
     return(status != DiscordUserStatus.New || status != DiscordUserStatus.NoResponse
                         ? await _synthbotRestClient.GetUserFromDiscordIdAsync(discordUserId)
                         : null);
 }