Skip to content
This repository was archived by the owner on Apr 30, 2024. It is now read-only.
Merged
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
16 changes: 16 additions & 0 deletions src/API/Discord.API/Models/Enums/Messages/ComponentType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Quarrel © 2022

using System;
using System.Collections.Generic;
using System.Text;

namespace Discord.API.Models.Enums.Messages
{
public enum ComponentType
{
ActionRow = 1,
Button = 2,
SelectMenu = 3,
TextInput = 4
}
}
17 changes: 17 additions & 0 deletions src/API/Discord.API/Models/Enums/Messages/InterationType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Quarrel © 2022

using System;
using System.Collections.Generic;
using System.Text;

namespace Discord.API.Models.Enums.Messages
{
public enum InterationType
{
PING = 1,
APPLICATION_COMMAND = 2,
MESSAGE_COMPONENT = 3,
APPLICATION_COMMAND_AUTOCOMPLETE = 4,
MODAL_SUBMIT = 5,
}
}
57 changes: 57 additions & 0 deletions src/API/Discord.API/Models/Enums/Messages/MessageFlags.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Quarrel © 2022

using System;
using System.Collections.Generic;
using System.Text;

namespace Discord.API.Models.Enums.Messages
{
public enum MessageFlags
{
/// <summary>
/// This message has been published to subscribed channels (via Channel Following)
/// </summary>
CROSSPOSTED = 0,

/// <summary>
/// This message originated from a message in another channel (via Channel Following)
/// </summary>
IS_CROSSPOST = 1,

/// <summary>
/// Do not include any embeds when serializing this message
/// </summary>
SUPPRESS_EMBEDS = 1 << 2,

/// <summary>
/// The source message for this crosspost has been deleted (via Channel Following)
/// </summary>
SOURCE_MESSAGE_DELETED = 1 << 3,

/// <summary>
/// This message came from the urgent message system
/// </summary>
URGENT = 1 << 4,

/// <summary>
/// This message has an associated thread, with the same id as the message
/// </summary>
HAS_THREAD = 1 << 5,

/// <summary>
/// This message is only visible to the user who invoked the Interaction
/// </summary>
EPHEMERAL = 1 << 6,

/// <summary>
/// This message is an Interaction Response and the bot is "thinking"
/// </summary>
LOADING = 1 << 7,

/// <summary>
/// This message failed to mention some roles and add their members to the thread
/// </summary>
FAILED_TO_MENTION_SOME_ROLES_IN_THREAD = 1 << 8,
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ namespace Discord.API.Models.Enums.Stickers
/// </summary>
public enum StickerFormatType
{
/// <summary>
/// Not specified.
/// </summary>
None = 0,

/// <summary>
/// PNG file.
/// </summary>
Expand Down
77 changes: 77 additions & 0 deletions src/API/Discord.API/Models/Json/Applications/JsonApplication.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Quarrel © 2022

using Discord.API.Models.Json.Users;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization;

namespace Discord.API.Models.Json.Applications
{
internal class JsonApplication
{
[JsonPropertyName("id"), JsonNumberHandling(Constants.ReadWriteAsString)]
public ulong Id { get; set; }

[JsonPropertyName("name")]
public string Name { get; set; }

[JsonPropertyName("icon")]
public string? Icon { get; set; }

[JsonPropertyName("description")]
public string Description { get; set; }

[JsonPropertyName("rpc_origins")]
public List<string>? RpcOrigins { get; set; }

[JsonPropertyName("bot_public")]
public bool BotPublic { get; set; }

[JsonPropertyName("bot_require_code_grant")]
public bool BotRequireCodeGrant { get; set; }

[JsonPropertyName("terms_of_service_url")]
public string? TermsOfServiceUrl { get; set; }

[JsonPropertyName("privacy_policy_url")]
public string? PrivacyPolicyUrl { get; set; }

[JsonPropertyName("owner")]
public JsonUser? Owner { get; set; }

[JsonPropertyName("verify_key")]
public string VerifyKey { get; set; }

/*
[JsonPropertyName("team")]
public JsonTeam? Team { get; set; }
*/

[JsonPropertyName("guild_id"), JsonNumberHandling(Constants.ReadWriteAsString)]
public ulong? GuildId { get; set; }

[JsonPropertyName("primary_sku_id"), JsonNumberHandling(Constants.ReadWriteAsString)]
public ulong? PrimarySkuId { get; set; }

[JsonPropertyName("slug")]
public string? Slug { get; set; }

[JsonPropertyName("cover_image")]
public string? CoverImage { get; set; }

[JsonPropertyName("flags")]
public int? Flags { get; set; }

[JsonPropertyName("tags")]
public List<string>? Tags { get; set; }

/*
[JsonPropertyName("install_params")]
public JsonInstallParams? InstallParams { get; set; }
*/

[JsonPropertyName("custom_install_url")]
public string? CustomInstallUrl { get; set; }
}
}
16 changes: 16 additions & 0 deletions src/API/Discord.API/Models/Json/Messages/JsonComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Quarrel © 2022

using Discord.API.Models.Enums.Messages;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization;

namespace Discord.API.Models.Json.Messages
{
internal class JsonComponent
{
[JsonPropertyName("type")]
public ComponentType Type { get; set; }
}
}
25 changes: 25 additions & 0 deletions src/API/Discord.API/Models/Json/Messages/JsonMessage.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// Quarrel © 2022

using Discord.API.Models.Enums.Messages;
using Discord.API.Models.Json.Applications;
using Discord.API.Models.Json.Channels;
using Discord.API.Models.Json.Messages.Embeds;
using Discord.API.Models.Json.Reactions;
using Discord.API.Models.Json.Stickers;
using Discord.API.Models.Json.Users;
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;

// JSON models don't need to respect standard nullable rules.
Expand Down Expand Up @@ -77,10 +81,31 @@ internal class JsonMessage
[JsonPropertyName("activity")]
public JsonMessageActivity? Activity { get; set; }

[JsonPropertyName("application")]
public JsonApplication? Application { get; set; }

[JsonPropertyName("application_id"), JsonNumberHandling(Constants.ReadWriteAsString)]
public long? ApplicationId { get; set; }

[JsonPropertyName("message_reference")]
public JsonMessageReference? Reference { get; set; }

[JsonPropertyName("flags")]
public MessageFlags? Flags { get; set; }

[JsonPropertyName("referenced_message")]
public JsonMessage? ReferencedMessage { get; set; }

[JsonPropertyName("interaction")]
public JsonMessageInteraction? Interaction { get; set; }

[JsonPropertyName("thread")]
public JsonChannel? Thread { get; set; }

[JsonPropertyName("components")]
public List<JsonMessageComponent>? Components { get; set; }

[JsonPropertyName("sticker_items")]
public List<JsonMessageStickerItem>? StickerItems { get; set; }
}
}
19 changes: 19 additions & 0 deletions src/API/Discord.API/Models/Json/Messages/JsonMessageComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Quarrel © 2022

using Discord.API.Models.Enums.Messages;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization;

namespace Discord.API.Models.Json.Messages
{
internal class JsonMessageComponent
{
[JsonPropertyName("type")]
public ComponentType Type { get; set; }

[JsonPropertyName("components")]
public List<JsonComponent> Components { get; set; }
}
}
26 changes: 26 additions & 0 deletions src/API/Discord.API/Models/Json/Messages/JsonMessageInteraction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Quarrel © 2022

using Discord.API.Models.Enums.Messages;
using Discord.API.Models.Json.Users;
using System.Text.Json.Serialization;

namespace Discord.API.Models.Json.Messages
{
internal class JsonMessageInteraction
{
[JsonPropertyName("id"), JsonNumberHandling(Constants.ReadWriteAsString)]
public ulong Id { get; set; }

[JsonPropertyName("type")]
public InterationType Type { get; set; }

[JsonPropertyName("name")]
public string Name { get; set; }

[JsonPropertyName("user")]
public JsonUser User { get; set; }

[JsonPropertyName("member")]
public JsonGuildMember? Mmber { get; set; }
}
}
19 changes: 19 additions & 0 deletions src/API/Discord.API/Models/Json/Messages/JsonMessageStickerItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Quarrel © 2022

using Discord.API.Models.Enums.Stickers;
using System.Text.Json.Serialization;

namespace Discord.API.Models.Json.Messages
{
internal class JsonMessageStickerItem
{
[JsonPropertyName("id"), JsonNumberHandling(Constants.ReadWriteAsString)]
public ulong Id { get; set; }

[JsonPropertyName("name")]
public string Name { get; set; }

[JsonPropertyName("format_type")]
public StickerFormatType FormatType { get; set; }
}
}
40 changes: 40 additions & 0 deletions src/API/Discord.API/Models/Json/Messages/JsonMessageUpsert.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Quarrel © 2022

using System.Text.Json.Serialization;

// JSON models don't need to respect standard nullable rules.
#pragma warning disable CS8618

namespace Discord.API.Models.Json.Messages
{
/// <summary>
/// A model for creating a message.
/// </summary>
internal class JsonMessageUpsert
{
public JsonMessageUpsert(string content, bool tts, string nonce)
{
Content = content;
TTS = tts;
Nonce = nonce;
}

/// <summary>
/// Gets or sets the content of the message.
/// </summary>
[JsonPropertyName("content")]
public string Content { get; set; }

/// <summary>
/// Gets or sets a value indicating whether or not the message is to be read TTS.
/// </summary>
[JsonPropertyName("tts")]
public bool TTS { get; set; }

/// <summary>
/// Gets or sets a value indicating this uniqueness of this message in order to prevent duplicates.
/// </summary>
[JsonPropertyName("nonce")]
public string Nonce { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/API/Discord.API/Rest/IChannelService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ internal interface IChannelService
{
[Get("/v9/channels/{channelId}/messages?limit={limit}")]
Task<JsonMessage[]> GetChannelMessages([AliasAs("channelId")] ulong channelId, [AliasAs("limit")] int limit = 50);

[Post("/v9/channels/{channelId}/messages")]
Task<JsonMessage> CreateMessage([AliasAs("channelId")] ulong channelId, [Body] JsonMessageUpsert message);
}
}
Loading