Added signed up options for role reminder
Added option to opt out of reminders
This commit is contained in:
parent
64ce169094
commit
c88bf5b133
18 changed files with 911 additions and 99 deletions
|
@ -54,6 +54,16 @@ namespace DiscordBot.CommandHandlers
|
|||
await _httpService.SignOff(signOff);
|
||||
await component.RespondAsync("Signed Off", ephemeral: true);
|
||||
break;
|
||||
case Constants.ComponentIds.OPT_OUT_BUTTON:
|
||||
if(await _httpService.ReminderOptOut(component.User.Id))
|
||||
{
|
||||
await component.RespondAsync("You opted out of the raid reminders.");
|
||||
}
|
||||
else
|
||||
{
|
||||
await component.RespondAsync("Opting out failed, please try again later or change the setting on the website.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
public const string BACKUP_BUTTON = "backupButton";
|
||||
public const string FLEX_BUTTON = "flexButton";
|
||||
public const string SIGN_OFF_BUTTON = "signOffButton";
|
||||
public const string OPT_OUT_BUTTON = "optOutButton";
|
||||
|
||||
public const string ROLE_SELECT_DROP_DOWN = "roleSelectDropDown";
|
||||
public const string ROLE_SELECT_EXTERNAL_DROP_DOWN = "roleSelectExternalDropDown";
|
||||
|
|
|
@ -95,5 +95,12 @@ namespace DiscordBot.Controllers
|
|||
{
|
||||
await DiscordBot.CommandHandlers.HandlerFunctions.RenameUser(_client, user.userId, user.Name, user.Account, user.ServerIds);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("[action]/{userId}")]
|
||||
public async Task SendReminderOptOutMessage(ulong userId)
|
||||
{
|
||||
await ReminderSubscriptionMessage.sendMessage(_client, userId);
|
||||
}
|
||||
}
|
||||
}
|
32
DiscordBot/Messages/ReminderSubscriptionMessage.cs
Normal file
32
DiscordBot/Messages/ReminderSubscriptionMessage.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
|
||||
namespace DiscordBot.Messages
|
||||
{
|
||||
public class ReminderSubscriptionMessage
|
||||
{
|
||||
public static async Task sendMessage(DiscordSocketClient client, ulong userId)
|
||||
{
|
||||
var builder = new ComponentBuilder()
|
||||
.WithButton("Opt Out", $"{Constants.ComponentIds.OPT_OUT_BUTTON}", ButtonStyle.Danger);
|
||||
|
||||
string message = "Hi, I'm Raid-o-Tron. \n"
|
||||
+ "I will send you reminders for raids you have signed up for.\n"
|
||||
+ "The reminders will look like\n"
|
||||
+ "> Testraid: The raid starts in 30 minutes. \n"
|
||||
+ "You can opt out of the reminders here or change it any time at https://lieb.games \n"
|
||||
+ " ------------------------------------------- \n"
|
||||
+ "Hi, ich bin Raid-o-Tron. \n"
|
||||
+ "Ich werde dir Erinnerungen für Raid an denen du dich angemeldet hast schicken.\n"
|
||||
+ "Die Erinnerungen werden so aussehen:\n"
|
||||
+ "> Testraid: The raid starts in 30 minutes. \n"
|
||||
+ "Du kannst dich von den Erinnerungen hier abmelden oder deine Einstellungen jederzeit auf https://lieb.games ändern.";
|
||||
|
||||
var user = await client.GetUserAsync(userId);
|
||||
if(user != null)
|
||||
{
|
||||
await user.SendMessageAsync(message, components: builder.Build());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -242,5 +242,20 @@ namespace DiscordBot.Services
|
|||
}
|
||||
return new Tuple<bool, string>(true, string.Empty);
|
||||
}
|
||||
|
||||
public async Task<bool> ReminderOptOut(ulong userId)
|
||||
{
|
||||
var httpClient = _httpClientFactory.CreateClient(Constants.HTTP_CLIENT_NAME);
|
||||
|
||||
var httpResponseMessage = await httpClient.GetAsync($"DiscordBot/ReminderOptOut/{userId}");
|
||||
if (httpResponseMessage.IsSuccessStatusCode)
|
||||
{
|
||||
using var contentStream =
|
||||
await httpResponseMessage.Content.ReadAsStreamAsync();
|
||||
|
||||
return await JsonSerializer.DeserializeAsync<bool>(contentStream, _serializerOptions);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue