forked from Sarah/Lieb-Website
reworked discord messages
This commit is contained in:
parent
38127b6c44
commit
62bacb5ad7
12 changed files with 318 additions and 78 deletions
64
DiscordBot/Messages/AccountSelectionMessage.cs
Normal file
64
DiscordBot/Messages/AccountSelectionMessage.cs
Normal file
|
@ -0,0 +1,64 @@
|
|||
using Discord;
|
||||
using SharedClasses.SharedModels;
|
||||
|
||||
namespace DiscordBot.Messages
|
||||
{
|
||||
public class AccountSelectionMessage
|
||||
{
|
||||
public static MessageComponent buildMessage(List<ApiGuildWars2Account> accounts, int raidId, string buttonType, int roleId, ulong userIdToSignUp, ulong signedUpByUserId)
|
||||
{
|
||||
var signUpSelect = new SelectMenuBuilder()
|
||||
.WithPlaceholder("Select an account")
|
||||
.WithCustomId($"{Constants.ComponentIds.ACCOUNT_SELECT_DROP_DOWN}-{raidId}-{buttonType}-{roleId}-{userIdToSignUp}-{signedUpByUserId}")
|
||||
.WithMinValues(1)
|
||||
.WithMaxValues(1);
|
||||
|
||||
foreach(ApiGuildWars2Account account in accounts)
|
||||
{
|
||||
signUpSelect.AddOption(account.AccountName, account.GuildWars2AccountId.ToString());
|
||||
}
|
||||
|
||||
var builder = new ComponentBuilder()
|
||||
.WithSelectMenu(signUpSelect, 0);
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
|
||||
public static Parameters ParseId(string customId)
|
||||
{
|
||||
Parameters parameters = new Parameters();
|
||||
|
||||
string[] ids = customId.Split('-');
|
||||
if(ids.Length > 1)
|
||||
{
|
||||
int.TryParse(ids[1],out parameters.RaidId);
|
||||
}
|
||||
if(ids.Length > 2)
|
||||
{
|
||||
parameters.ButtonType = ids[2];
|
||||
}
|
||||
if(ids.Length > 3)
|
||||
{
|
||||
int.TryParse(ids[3],out parameters.RoleId);
|
||||
}
|
||||
if(ids.Length > 4)
|
||||
{
|
||||
ulong.TryParse(ids[4],out parameters.UserIdToSignUp);
|
||||
}
|
||||
if(ids.Length > 5)
|
||||
{
|
||||
ulong.TryParse(ids[5],out parameters.SignedUpByUserId);
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public class Parameters
|
||||
{
|
||||
public int RaidId;
|
||||
public string ButtonType = string.Empty;
|
||||
public int RoleId;
|
||||
public ulong UserIdToSignUp;
|
||||
public ulong SignedUpByUserId;
|
||||
}
|
||||
}
|
||||
}
|
40
DiscordBot/Messages/CreateAccountModal.cs
Normal file
40
DiscordBot/Messages/CreateAccountModal.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using Discord;
|
||||
|
||||
namespace DiscordBot.Messages
|
||||
{
|
||||
public class CreateAccountModal
|
||||
{
|
||||
public static Modal buildMessage(int raidId, string pressedButtonId, string defaultUserName)
|
||||
{
|
||||
var mb = new ModalBuilder()
|
||||
.WithTitle("Create Account")
|
||||
.WithCustomId($"{Constants.ComponentIds.CREATE_ACCOUNT_MODAL}-{raidId}-{pressedButtonId}")
|
||||
.AddTextInput("Name", Constants.ComponentIds.NAME_TEXT_BOX, placeholder: defaultUserName, required: true, value: defaultUserName)
|
||||
.AddTextInput("Guild Wars 2 Account", Constants.ComponentIds.ACCOUNT_TEXT_BOX, placeholder: "Account.1234", required: true);
|
||||
|
||||
return mb.Build();
|
||||
}
|
||||
|
||||
public static Parameters ParseId(string customId)
|
||||
{
|
||||
Parameters parameters = new Parameters();
|
||||
|
||||
string[] ids = customId.Split('-');
|
||||
if(ids.Length > 1)
|
||||
{
|
||||
int.TryParse(ids[1],out parameters.RaidId);
|
||||
}
|
||||
if(ids.Length > 2)
|
||||
{
|
||||
parameters.ButtonId = ids[2];
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public class Parameters
|
||||
{
|
||||
public int RaidId;
|
||||
public string ButtonId = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,24 +1,21 @@
|
|||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using SharedClasses.SharedModels;
|
||||
|
||||
namespace DiscordBot.Messages
|
||||
{
|
||||
public class SignUpMessage
|
||||
public class ExternalRoleSelectionMessage
|
||||
{
|
||||
public static MessageComponent buildMessage(List<ApiRole> roles, int raidId, string buttonType, bool allRoles, ulong userIdToSignUp = 0)
|
||||
public static MessageComponent buildMessage(List<ApiRole> roles, int raidId)
|
||||
{
|
||||
var signUpSelect = new SelectMenuBuilder()
|
||||
.WithPlaceholder("Select an option")
|
||||
.WithCustomId($"{Constants.ComponentIds.SIGN_UP_DROP_DOWN}-{raidId}-{buttonType}-{userIdToSignUp}")
|
||||
.WithCustomId($"{Constants.ComponentIds.SIGN_UP_EXTERNAL_DROP_DOWN}-{raidId}")
|
||||
.WithMinValues(1)
|
||||
.WithMaxValues(1);
|
||||
|
||||
foreach(ApiRole role in roles)
|
||||
{
|
||||
if(allRoles || role.IsSignUpAllowed)
|
||||
if(role.IsSignUpAllowed)
|
||||
signUpSelect.AddOption(role.Name, role.roleId.ToString(), role.Description);
|
||||
}
|
||||
|
||||
|
@ -27,5 +24,22 @@ namespace DiscordBot.Messages
|
|||
|
||||
return builder.Build();
|
||||
}
|
||||
|
||||
public static Parameters ParseId(string customId)
|
||||
{
|
||||
Parameters parameters = new Parameters();
|
||||
|
||||
string[] ids = customId.Split('-');
|
||||
if(ids.Length > 1)
|
||||
{
|
||||
int.TryParse(ids[1],out parameters.RaidId);
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public class Parameters
|
||||
{
|
||||
public int RaidId;
|
||||
}
|
||||
}
|
||||
}
|
43
DiscordBot/Messages/ExternalUserNameModal.cs
Normal file
43
DiscordBot/Messages/ExternalUserNameModal.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using SharedClasses.SharedModels;
|
||||
|
||||
namespace DiscordBot.Messages
|
||||
{
|
||||
public class ExternalUserNameModal
|
||||
{
|
||||
public static Modal buildMessage(int raidId, int roleId)
|
||||
{
|
||||
var mb = new ModalBuilder()
|
||||
.WithTitle("Create Account")
|
||||
.WithCustomId($"{Constants.ComponentIds.SIGN_UP_EXTERNAL_MODAL}-{raidId}-{roleId}")
|
||||
.AddTextInput("Name", Constants.ComponentIds.NAME_TEXT_BOX, placeholder: "Name", required: true);
|
||||
|
||||
return mb.Build();
|
||||
}
|
||||
|
||||
public static Parameters ParseId(string customId)
|
||||
{
|
||||
Parameters parameters = new Parameters();
|
||||
|
||||
string[] ids = customId.Split('-');
|
||||
if(ids.Length > 1)
|
||||
{
|
||||
int.TryParse(ids[1],out parameters.RaidId);
|
||||
}
|
||||
if(ids.Length > 2)
|
||||
{
|
||||
int.TryParse(ids[2],out parameters.RoleId);
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public class Parameters
|
||||
{
|
||||
public int RaidId;
|
||||
public int RoleId;
|
||||
}
|
||||
}
|
||||
}
|
55
DiscordBot/Messages/RoleSelectionMessage.cs
Normal file
55
DiscordBot/Messages/RoleSelectionMessage.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
using Discord;
|
||||
using SharedClasses.SharedModels;
|
||||
|
||||
namespace DiscordBot.Messages
|
||||
{
|
||||
public class RoleSelectionMessage
|
||||
{
|
||||
public static MessageComponent buildMessage(List<ApiRole> roles, int raidId, string buttonType, bool allRoles, ulong userIdToSignUp = 0)
|
||||
{
|
||||
var signUpSelect = new SelectMenuBuilder()
|
||||
.WithPlaceholder("Select an option")
|
||||
.WithCustomId($"{Constants.ComponentIds.SIGN_UP_DROP_DOWN}-{raidId}-{buttonType}-{userIdToSignUp}")
|
||||
.WithMinValues(1)
|
||||
.WithMaxValues(1);
|
||||
|
||||
foreach(ApiRole role in roles)
|
||||
{
|
||||
if(allRoles || role.IsSignUpAllowed)
|
||||
signUpSelect.AddOption(role.Name, role.roleId.ToString(), role.Description);
|
||||
}
|
||||
|
||||
var builder = new ComponentBuilder()
|
||||
.WithSelectMenu(signUpSelect, 0);
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
|
||||
public static Parameters ParseId(string customId)
|
||||
{
|
||||
Parameters parameters = new Parameters();
|
||||
|
||||
string[] ids = customId.Split('-');
|
||||
if(ids.Length > 1)
|
||||
{
|
||||
int.TryParse(ids[1],out parameters.RaidId);
|
||||
}
|
||||
if(ids.Length > 2)
|
||||
{
|
||||
parameters.ButtonType = ids[2];
|
||||
}
|
||||
if(ids.Length > 3)
|
||||
{
|
||||
ulong.TryParse(ids[3],out parameters.UserIdToSignUp);
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public class Parameters
|
||||
{
|
||||
public int RaidId;
|
||||
public string ButtonType = string.Empty;
|
||||
public ulong UserIdToSignUp;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue