Skip to content

Commit

Permalink
Implement attachment flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nihlus committed Jul 14, 2023
1 parent 00dac00 commit 2eff142
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// AttachmentFlags.cs
//
// Author:
// Jarl Gullberg <[email protected]>
//
// Copyright (c) Jarl Gullberg
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

using System;
using JetBrains.Annotations;

namespace Remora.Discord.API.Abstractions.Objects;

/// <summary>
/// Enumerates various flags applied to an attachment.
/// </summary>
[PublicAPI]
[Flags]
public enum AttachmentFlags
{
/// <summary>
/// The attachment has been edited using the remix feature.
/// </summary>
IsRemix = 1 << 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ public interface IAttachment : IPartialAttachment
/// </summary>
new Optional<byte[]> Waveform { get; }

/// <summary>
/// Gets the flags applied to the attachment.
/// </summary>
new Optional<AttachmentFlags> Flags { get; }

/// <inheritdoc/>
Optional<Snowflake> IPartialAttachment.ID => this.ID;

Expand Down Expand Up @@ -129,4 +134,7 @@ public interface IAttachment : IPartialAttachment

/// <inheritdoc/>
Optional<byte[]> IPartialAttachment.Waveform => this.Waveform;

/// <inheritdoc/>
Optional<AttachmentFlags> IPartialAttachment.Flags => this.Flags;
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,7 @@ public interface IPartialAttachment

/// <inheritdoc cref="IAttachment.Waveform"/>
Optional<byte[]> Waveform { get; }

/// <inheritdoc cref="IAttachment.Flags"/>
Optional<AttachmentFlags> Flags { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ public record Attachment
Optional<int?> Width,
Optional<bool> IsEphemeral,
Optional<TimeSpan> Duration,
Optional<byte[]> Waveform
Optional<byte[]> Waveform,
Optional<AttachmentFlags> Flags
) : IAttachment;
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ public record PartialAttachment
Optional<int?> Width = default,
Optional<bool> IsEphemeral = default,
Optional<TimeSpan> Duration = default,
Optional<byte[]> Waveform = default
Optional<byte[]> Waveform = default,
Optional<AttachmentFlags> Flags = default
) : IPartialAttachment;
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"width": 1,
"ephemeral": true,
"duration_secs": 10,
"waveform": "bm9uZQ=="
"waveform": "bm9uZQ==",
"flags": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
"proxy_url": "https://www.example.org",
"height": null,
"width": null,
"ephemeral": true
}
"ephemeral": true,
"duration_secs": 10,
"waveform": "bm9uZQ==",
"flags": 0
}

0 comments on commit 2eff142

Please sign in to comment.