-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from UncomplicatedCustomServer/dev-main
Release v1.0.0
- Loading branch information
Showing
48 changed files
with
847 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using SimpleDiscord.Components.DiscordComponents; | ||
using SimpleDiscord.Enums; | ||
using System; | ||
using System.Linq; | ||
|
||
namespace SimpleDiscord.Components.Builders | ||
{ | ||
public class ButtonBuilder | ||
{ | ||
internal readonly Button button = new((int)ButtonStyle.Primary, null, null, RandomString(35), null); | ||
|
||
public ButtonBuilder SetLabel(string label) | ||
{ | ||
button.Label = label; | ||
return this; | ||
} | ||
|
||
public ButtonBuilder SetStyle(ButtonStyle style) | ||
{ | ||
button.Style = (int)style; | ||
return this; | ||
} | ||
|
||
public ButtonBuilder SetEmoji(Emoji emoji) | ||
{ | ||
button.Emoji = emoji; | ||
return this; | ||
} | ||
|
||
public ButtonBuilder SetData(object data) | ||
{ | ||
button.Data = data; | ||
return this; | ||
} | ||
|
||
public ButtonBuilder SetCallback(Action<Interaction, object> callback) | ||
{ | ||
button.Callback = callback; | ||
return this; | ||
} | ||
|
||
public ButtonBuilder SetCustomId(string customId) | ||
{ | ||
button.CustomId = customId; | ||
return this; | ||
} | ||
|
||
public ButtonBuilder SetDisabled(bool disabled) | ||
{ | ||
button.Disabled = disabled; | ||
return this; | ||
} | ||
|
||
public static ButtonBuilder New() => new(); | ||
|
||
public static implicit operator Button(ButtonBuilder builder) => builder.button; | ||
|
||
private static string RandomString(int length = 10) | ||
{ | ||
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz.,;_#@=()$?"; | ||
return new string(Enumerable.Repeat(chars, length).Select(s => s[Discord.Random.Next(s.Length)]).ToArray()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 21 additions & 9 deletions
30
SimpleDiscord/Components/DiscordComponents/SocketActionRow.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,36 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using SimpleDiscord.Enums; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace SimpleDiscord.Components.DiscordComponents | ||
{ | ||
#nullable enable | ||
public class SocketActionRow : GenericComponent | ||
{ | ||
public override int Type => (int)ComponentType.ActionRow; | ||
public int? Id { get; } | ||
|
||
public object[] Components { get; } | ||
public override int Type { get; } | ||
|
||
[JsonConstructor] | ||
public SocketActionRow(object[] baseComponents) | ||
{ | ||
Components = baseComponents; | ||
} | ||
public List<object>? Components { get; } | ||
|
||
public SocketActionRow(SocketActionRow self) : this(self.Components) | ||
public SocketActionRow(SocketActionRow self) : this((int)ComponentType.ActionRow, self.Components, self.Id) | ||
{ } | ||
|
||
public SocketActionRow(ActionRow child) : this([.. child.Components]) | ||
public SocketActionRow(ActionRow child) : this((int)ComponentType.ActionRow, [.. child.Components], child.Id) | ||
{ } | ||
|
||
[JsonConstructor] | ||
public SocketActionRow(int type, List<object>? components, int? id = null) | ||
{ | ||
Id = id; | ||
Type = type; | ||
Components = []; | ||
if (components is not null) | ||
foreach (object component in components) | ||
if (component is JObject obj) | ||
Components.Add(obj); | ||
} | ||
} | ||
} |
Oops, something went wrong.