Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions wow2.Bot/BotService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public static async Task ReadyAsync()
Client.JoinedGuild += JoinedGuildAsync;
Client.LeftGuild += LeftGuildAsync;
Client.ButtonExecuted += ButtonExecutedAsync;
Client.SelectMenuExecuted += SelectMenuExecuted;
}
}

Expand Down Expand Up @@ -264,6 +265,12 @@ public static Task ButtonExecutedAsync(SocketMessageComponent component)
return Task.CompletedTask;
}

public static Task SelectMenuExecuted(SocketMessageComponent component)
{
_ = InteractiveMessage.ActOnSelectMenuAsync(component);
return Task.CompletedTask;
}

public static async Task MessageRecievedAsync(SocketMessage socketMessage)
{
if (socketMessage.Author.Id == Client.CurrentUser.Id)
Expand Down
24 changes: 24 additions & 0 deletions wow2.Bot/Verbose/Messages/ActionSelectMenu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Discord.WebSocket;

namespace wow2.Bot.Verbose.Messages
{
public class ActionSelectMenu
{
public string Placeholder { get; set; }

public List<ActionSelectMenuOption> Options { get; set; }

public int MinValues { get; set; } = 1;

public int MaxValues { get; set; } = 1;

public bool Disabled { get; set; }

public int Row { get; set; }

public Func<SocketMessageComponent, Task> Action { get; set; }
}
}
17 changes: 17 additions & 0 deletions wow2.Bot/Verbose/Messages/ActionSelectMenuOption.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Discord;

namespace wow2.Bot.Verbose.Messages
{
public class ActionSelectMenuOption
{
public string Label { get; set; }

public string Value => Label;

public string Description { get; set; }

public IEmote Emote { get; set; }

public bool Default { get; set; }
}
}
29 changes: 29 additions & 0 deletions wow2.Bot/Verbose/Messages/InteractiveMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,21 @@ public static async Task<bool> ActOnButtonAsync(SocketMessageComponent component
return false;
}

public static async Task<bool> ActOnSelectMenuAsync(SocketMessageComponent component)
{
var interactiveMessage = FromMessageId(DataManager.AllGuildData[component.Channel.GetGuild().Id], component.Message.Id);
if (interactiveMessage == null)
return false;

return false;
}

public List<ActionButton> ExtraActionButtons { get; set; } = new();

protected virtual ActionButton[] ActionButtons => Array.Empty<ActionButton>();

protected virtual ActionSelectMenu[] ActionSelectMenu => Array.Empty<ActionSelectMenu>();

/// <summary>Gets all the <see cref="ActionButton" /> objects that will be sent with the message.</summary>
public ActionButton[] GetActionButtons() => ActionButtons.Concat(ExtraActionButtons).ToArray();

Expand Down Expand Up @@ -111,6 +122,24 @@ private ComponentBuilder GetComponentBuilder(bool forceDisableActions = false)
row: button.Row);
}

foreach (var select in ActionSelectMenu)
{
components.WithSelectMenu(
label: "This is a label!",
customId: GetHashCode().ToString(),
options: select.Options.ConvertAll(o => new SelectMenuOptionBuilder(
label: o.Label,
value: o.Value,
description: o.Description,
emote: o.Emote,
@default: o.Default)),
placeholder: select.Placeholder,
minValues: select.MinValues,
maxValues: select.MaxValues,
disabled: select.Disabled,
row: select.Row);
}

return components;
}
}
Expand Down