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)); } }
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}"); }
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()); }
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); }
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()); }
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; } } }
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()); } }
public void ChangeStatus(string game, DiscordUserStatus? status) { }
public void ChangeStatus(DiscordUserStatus status) { }
/// <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); }