Add missing REST Webhook implemenation (#843)
* Add Webhook API models, REST implementation, and Socket bridges. * Remove token overrides from REST. Leaving that as a Webhook package only feature. * Add Webhook API models, REST implementation, and Socket bridges. * Remove token overrides from REST. Leaving that as a Webhook package only feature. * Webhook core implementation. * Webhook REST implementation. * Webhook client implementation. * Add channel bucket id.
This commit is contained in:
committed by
Christopher F
parent
a19ff188e9
commit
7b2ddd027c
25
src/Discord.Net.Rest/API/Common/Webhook.cs
Normal file
25
src/Discord.Net.Rest/API/Common/Webhook.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API
|
||||
{
|
||||
internal class Webhook
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public ulong Id { get; set; }
|
||||
[JsonProperty("channel_id")]
|
||||
public ulong ChannelId { get; set; }
|
||||
[JsonProperty("token")]
|
||||
public string Token { get; set; }
|
||||
|
||||
[JsonProperty("name")]
|
||||
public Optional<string> Name { get; set; }
|
||||
[JsonProperty("avatar")]
|
||||
public Optional<string> Avatar { get; set; }
|
||||
[JsonProperty("guild_id")]
|
||||
public Optional<ulong> GuildId { get; set; }
|
||||
|
||||
[JsonProperty("user")]
|
||||
public Optional<User> Creator { get; set; }
|
||||
}
|
||||
}
|
||||
14
src/Discord.Net.Rest/API/Rest/CreateWebhookParams.cs
Normal file
14
src/Discord.Net.Rest/API/Rest/CreateWebhookParams.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Rest
|
||||
{
|
||||
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
|
||||
internal class CreateWebhookParams
|
||||
{
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
[JsonProperty("avatar")]
|
||||
public Optional<Image?> Avatar { get; set; }
|
||||
}
|
||||
}
|
||||
16
src/Discord.Net.Rest/API/Rest/ModifyWebhookParams.cs
Normal file
16
src/Discord.Net.Rest/API/Rest/ModifyWebhookParams.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Rest
|
||||
{
|
||||
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
|
||||
internal class ModifyWebhookParams
|
||||
{
|
||||
[JsonProperty("name")]
|
||||
public Optional<string> Name { get; set; }
|
||||
[JsonProperty("avatar")]
|
||||
public Optional<Image?> Avatar { get; set; }
|
||||
[JsonProperty("channel_id")]
|
||||
public Optional<ulong> ChannelId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma warning disable CS1591
|
||||
using Discord.Net.Rest;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Discord.Net.Rest;
|
||||
|
||||
namespace Discord.API.Rest
|
||||
{
|
||||
@@ -15,6 +15,7 @@ namespace Discord.API.Rest
|
||||
public Optional<bool> IsTTS { get; set; }
|
||||
public Optional<string> Username { get; set; }
|
||||
public Optional<string> AvatarUrl { get; set; }
|
||||
public Optional<Embed[]> Embeds { get; set; }
|
||||
|
||||
public UploadWebhookFileParams(Stream file)
|
||||
{
|
||||
@@ -25,6 +26,7 @@ namespace Discord.API.Rest
|
||||
{
|
||||
var d = new Dictionary<string, object>();
|
||||
d["file"] = new MultipartFile(File, Filename.GetValueOrDefault("unknown.dat"));
|
||||
|
||||
if (Content.IsSpecified)
|
||||
d["content"] = Content.Value;
|
||||
if (IsTTS.IsSpecified)
|
||||
@@ -35,6 +37,8 @@ namespace Discord.API.Rest
|
||||
d["username"] = Username.Value;
|
||||
if (AvatarUrl.IsSpecified)
|
||||
d["avatar_url"] = AvatarUrl.Value;
|
||||
if (Embeds.IsSpecified)
|
||||
d["embeds"] = Embeds.Value;
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user