reworkes sign up messages

This commit is contained in:
Sarah Faey 2022-11-29 16:45:41 +01:00
parent 57d8df1463
commit 03624a5859
9 changed files with 136 additions and 126 deletions

View file

@ -9,7 +9,7 @@ namespace DiscordBot.Messages
{
var signUpSelect = new SelectMenuBuilder()
.WithPlaceholder("Select an option")
.WithCustomId($"{Constants.ComponentIds.SIGN_UP_EXTERNAL_DROP_DOWN}-{raidId}")
.WithCustomId($"{Constants.ComponentIds.ROLE_SELECT_EXTERNAL_DROP_DOWN}-{raidId}")
.WithMinValues(1)
.WithMaxValues(1);

View file

@ -69,7 +69,7 @@ namespace DiscordBot.Messages
return raid;
}
public Embed CreateRaidMessage(ApiRaid raid)
private Embed CreateRaidMessage(ApiRaid raid)
{
var embed = new EmbedBuilder()
{
@ -124,5 +124,27 @@ namespace DiscordBot.Messages
}
return rolesString;
}
public static ButtonParameters ParseButtonId(string customId)
{
ButtonParameters parameters = new ButtonParameters();
string[] ids = customId.Split('-');
if(ids.Length > 0)
{
parameters.ButtonType = ids[0];
}
if(ids.Length > 1)
{
int.TryParse(ids[1],out parameters.RaidId);
}
return parameters;
}
public class ButtonParameters
{
public int RaidId;
public string ButtonType = string.Empty;
}
}
}

View file

@ -5,11 +5,11 @@ namespace DiscordBot.Messages
{
public class RoleSelectionMessage
{
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, string buttonType, bool allRoles, ulong userIdToSignUp, ulong signedUpByUserId)
{
var signUpSelect = new SelectMenuBuilder()
.WithPlaceholder("Select an option")
.WithCustomId($"{Constants.ComponentIds.SIGN_UP_DROP_DOWN}-{raidId}-{buttonType}-{userIdToSignUp}")
.WithCustomId($"{Constants.ComponentIds.ROLE_SELECT_DROP_DOWN}-{raidId}-{buttonType}-{userIdToSignUp}-{signedUpByUserId}")
.WithMinValues(1)
.WithMaxValues(1);
@ -42,6 +42,10 @@ namespace DiscordBot.Messages
{
ulong.TryParse(ids[3],out parameters.UserIdToSignUp);
}
if(ids.Length > 4)
{
ulong.TryParse(ids[4],out parameters.SignedUpByUserId);
}
return parameters;
}
@ -49,7 +53,8 @@ namespace DiscordBot.Messages
{
public int RaidId;
public string ButtonType = string.Empty;
public ulong UserIdToSignUp;
public ulong UserIdToSignUp;
public ulong SignedUpByUserId;
}
}
}