Skip to content

Commit 3b13b7f

Browse files
committed
embeds
1 parent 3fd1433 commit 3b13b7f

19 files changed

Lines changed: 357 additions & 50 deletions

File tree

src/Disc.NET.Client.SDK/Client.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
using System.Net;
2-
using System.Text;
3-
using System.Text.Json;
4-
using Disc.NET.Client.SDK.Interfaces;
1+
using Disc.NET.Client.SDK.Interfaces;
52
using Disc.NET.Client.SDK.Messages;
63
using Disc.NET.Shared.Configurations;
74
using Disc.NET.Shared.Exceptions;
85
using Disc.NET.Shared.Serializer;
6+
using System;
7+
using System.Net;
8+
using System.Text;
9+
using System.Text.Json;
910

1011
namespace Disc.NET.Client.SDK;
1112

@@ -57,6 +58,15 @@ await PostAsync(commandJson, $"applications/{_appConfiguration.ApplicationId}/gu
5758
cancellation);
5859
}
5960

61+
public async Task InteractionRespondingAsync(string interactionId, string interactionToken, string responseJson,
62+
CancellationToken cancellation = default)
63+
{
64+
var url = $"https://discord.com/api/v10/interactions/{interactionId}/{interactionToken}/callback";
65+
await PostAsync(responseJson, url, cancellation);
66+
}
67+
68+
69+
6070
private async Task PostAsync(string json, string uri, CancellationToken cancellation = default)
6171
{
6272
var content = new StringContent(json, Encoding.UTF8, "application/json");

src/Disc.NET.Client.SDK/Interfaces/IClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ public interface IClient
1212
Task RegisterGlobalSlashCommandAsync(string commandJson, CancellationToken cancellation = default);
1313
Task RegisterGuildSlashCommandAsync(string commandJson, string guildId, CancellationToken cancellation = default);
1414

15+
Task InteractionRespondingAsync(string interactionId, string interactionToken, string responseJson, CancellationToken cancellation = default);
1516

1617
}
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
1+
using System.Text.Json.Serialization;
2+
using Disc.NET.Client.SDK.Messages.Embeds;
3+
using Disc.NET.Shared.Enums;
64

75
namespace Disc.NET.Client.SDK.Messages
86
{
@@ -11,5 +9,14 @@ public class ApiMessage
119
public string Content { get; set; } = string.Empty;
1210
public List<Embed> Embeds { get; set; } = [];
1311

12+
[JsonIgnore]
13+
public List<MessageFlag>? MessageFlags { get; set; }
14+
15+
public long Flags => MessageFlags?.Aggregate(0L, (current, flag) => current | (long)flag) ?? 0L;
16+
17+
18+
// Colocar os outros campos depois
19+
// https://discord.com/developers/docs/resources/message#message-object
1420
}
21+
1522
}

src/Disc.NET.Client.SDK/Messages/Embed.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace Disc.NET.Client.SDK.Messages.Embeds
2+
{
3+
public class Embed
4+
{
5+
public string? Title { get; set; }
6+
public string? Type { get; set; }
7+
public string? Description { get; set; }
8+
public string? Url { get; set; }
9+
public string? Timestamp { get; set; }
10+
public int? Color { get; set; }
11+
public EmbedFooter? Footer { get; set; }
12+
public EmbedImage? Image { get; set; }
13+
public EmbedImage? Thumbnail { get; set; }
14+
15+
public EmbedVideo? Video { get; set; }
16+
17+
public EmbedProvider? Provider { get; set; }
18+
public EmbedAuthor? Author { get; set; }
19+
public List<EmbedField>? Fields { get; set; }
20+
21+
}
22+
23+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace Disc.NET.Client.SDK.Messages.Embeds
2+
{
3+
public class EmbedAuthor
4+
{
5+
public string? Name { get; set; }
6+
public string? Url { get; set; }
7+
public string? IconUrl { get; set; }
8+
public string? ProxyIconUrl { get; set; }
9+
}
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Disc.NET.Client.SDK.Messages.Embeds
2+
{
3+
public class EmbedField
4+
{
5+
public string Name { get; set; } = string.Empty;
6+
public string Value { get; set; } = string.Empty;
7+
public bool Inline { get; set; } = false;
8+
}
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Disc.NET.Client.SDK.Messages.Embeds
2+
{
3+
public class EmbedFooter
4+
{
5+
public string Text { get; set; } = string.Empty;
6+
public string? IconUrl { get; set; }
7+
public string? ProxyIconUrl { get; set; }
8+
}
9+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Disc.NET.Client.SDK.Messages.Embeds
2+
{
3+
public class EmbedImage
4+
{
5+
public string Url { get; set; } = string.Empty;
6+
}
7+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Disc.NET.Client.SDK.Messages.Embeds
8+
{
9+
public class EmbedProvider
10+
{
11+
public string? Name { get; set; }
12+
public string? Url { get; set; }
13+
}
14+
}

0 commit comments

Comments
 (0)