| @@ -8,7 +8,7 @@ | |||||
| <TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net461;netstandard2.0;netstandard2.1</TargetFrameworks> | <TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net461;netstandard2.0;netstandard2.1</TargetFrameworks> | ||||
| <TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard2.0;netstandard2.1</TargetFrameworks> | <TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard2.0;netstandard2.1</TargetFrameworks> | ||||
| <PackageId>Discord.Net.Labs.Core</PackageId> | <PackageId>Discord.Net.Labs.Core</PackageId> | ||||
| <Version>2.4.2</Version> | |||||
| <Version>2.4.3</Version> | |||||
| <Product>Discord.Net.Labs.Core</Product> | <Product>Discord.Net.Labs.Core</Product> | ||||
| <RepositoryUrl>https://github.com/Discord-Net-Labs/Discord.Net-Labs</RepositoryUrl> | <RepositoryUrl>https://github.com/Discord-Net-Labs/Discord.Net-Labs</RepositoryUrl> | ||||
| <PackageIcon>Temporary.png</PackageIcon> | <PackageIcon>Temporary.png</PackageIcon> | ||||
| @@ -0,0 +1,56 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Text; | |||||
| using System.Threading.Tasks; | |||||
| namespace Discord.Entities.Messages | |||||
| { | |||||
| /// <summary> | |||||
| /// Represents a class used to make timestamps in messages. see <see href="https://discord.com/developers/docs/reference#message-formatting-timestamp-styles"/>. | |||||
| /// </summary> | |||||
| public class TimestampTag | |||||
| { | |||||
| /// <summary> | |||||
| /// Gets or sets the style of the timestamp tag. | |||||
| /// </summary> | |||||
| public TimestampTagStyles Style { get; set; } = TimestampTagStyles.ShortDateTime; | |||||
| /// <summary> | |||||
| /// Gets or sets the time for this timestamp tag. | |||||
| /// </summary> | |||||
| public DateTime Time { get; set; } | |||||
| /// <summary> | |||||
| /// Converts the current timestamp tag to the string representation supported by discord. | |||||
| /// <para> | |||||
| /// If the <see cref="TimestampTag.Time"/> is null then the default 0 will be used. | |||||
| /// </para> | |||||
| /// </summary> | |||||
| /// <returns>A string thats compatable in a discord message, ex: <code><t:1625944201:f></code></returns> | |||||
| public override string ToString() | |||||
| { | |||||
| if (Time == null) | |||||
| return $"<t:0:{(char)Style}>"; | |||||
| var offset = (DateTimeOffset)this.Time; | |||||
| return $"<t:{offset.ToUnixTimeSeconds()}:{(char)Style}>"; | |||||
| } | |||||
| /// <summary> | |||||
| /// Creates a new timestamp tag with the specified datetime object. | |||||
| /// </summary> | |||||
| /// <param name="time">The time of this timestamp tag.</param> | |||||
| /// <param name="style">The style for this timestamp tag.</param> | |||||
| /// <returns>The newly create timestamp tag.</returns> | |||||
| public static TimestampTag FromDateTime(DateTime time, TimestampTagStyles style = TimestampTagStyles.ShortDateTime) | |||||
| { | |||||
| return new TimestampTag() | |||||
| { | |||||
| Style = style, | |||||
| Time = time | |||||
| }; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,49 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Text; | |||||
| using System.Threading.Tasks; | |||||
| namespace Discord.Entities.Messages | |||||
| { | |||||
| /// <summary> | |||||
| /// Represents a set of styles to use with a <see cref="TimestampTag"/> | |||||
| /// </summary> | |||||
| public enum TimestampTagStyles | |||||
| { | |||||
| /// <summary> | |||||
| /// A short time string: 16:20 | |||||
| /// </summary> | |||||
| ShortTime = 116, | |||||
| /// <summary> | |||||
| /// A long time string: 16:20:30 | |||||
| /// </summary> | |||||
| LongTime = 84, | |||||
| /// <summary> | |||||
| /// A short date string: 20/04/2021 | |||||
| /// </summary> | |||||
| ShortDate = 100, | |||||
| /// <summary> | |||||
| /// A long date string: 20 April 2021 | |||||
| /// </summary> | |||||
| LongDate = 68, | |||||
| /// <summary> | |||||
| /// A short datetime string: 20 April 2021 16:20 | |||||
| /// </summary> | |||||
| ShortDateTime = 102, | |||||
| /// <summary> | |||||
| /// A long datetime string: Tuesday, 20 April 2021 16:20 | |||||
| /// </summary> | |||||
| LongDateTime = 70, | |||||
| /// <summary> | |||||
| /// The relative time to the user: 2 months ago | |||||
| /// </summary> | |||||
| Relative = 82 | |||||
| } | |||||
| } | |||||
| @@ -9,7 +9,7 @@ | |||||
| <TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard2.0;netstandard2.1</TargetFrameworks> | <TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard2.0;netstandard2.1</TargetFrameworks> | ||||
| <PackageIcon>Temporary.png</PackageIcon> | <PackageIcon>Temporary.png</PackageIcon> | ||||
| <PackageProjectUrl>https://github.com/Discord-Net-Labs/Discord.Net-Labs</PackageProjectUrl> | <PackageProjectUrl>https://github.com/Discord-Net-Labs/Discord.Net-Labs</PackageProjectUrl> | ||||
| <Version>2.4.3</Version> | |||||
| <Version>2.4.4</Version> | |||||
| <PackageId>Discord.Net.Labs.Rest</PackageId> | <PackageId>Discord.Net.Labs.Rest</PackageId> | ||||
| <RepositoryUrl>https://github.com/Discord-Net-Labs/Discord.Net-Labs</RepositoryUrl> | <RepositoryUrl>https://github.com/Discord-Net-Labs/Discord.Net-Labs</RepositoryUrl> | ||||
| <AssemblyVersion>2.3.4</AssemblyVersion> | <AssemblyVersion>2.3.4</AssemblyVersion> | ||||
| @@ -8,7 +8,7 @@ | |||||
| <TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net461;netstandard2.0;netstandard2.1</TargetFrameworks> | <TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net461;netstandard2.0;netstandard2.1</TargetFrameworks> | ||||
| <TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard2.0;netstandard2.1</TargetFrameworks> | <TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard2.0;netstandard2.1</TargetFrameworks> | ||||
| <AllowUnsafeBlocks>true</AllowUnsafeBlocks> | <AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||||
| <Version>2.4.4</Version> | |||||
| <Version>2.4.5</Version> | |||||
| <RepositoryUrl>https://github.com/Discord-Net-Labs/Discord.Net-Labs</RepositoryUrl> | <RepositoryUrl>https://github.com/Discord-Net-Labs/Discord.Net-Labs</RepositoryUrl> | ||||
| <PackageProjectUrl>https://github.com/Discord-Net-Labs/Discord.Net-Labs</PackageProjectUrl> | <PackageProjectUrl>https://github.com/Discord-Net-Labs/Discord.Net-Labs</PackageProjectUrl> | ||||
| <PackageIcon>Temporary.png</PackageIcon> | <PackageIcon>Temporary.png</PackageIcon> | ||||
| @@ -2,7 +2,7 @@ | |||||
| <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> | <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> | ||||
| <metadata> | <metadata> | ||||
| <id>Discord.Net.Labs</id> | <id>Discord.Net.Labs</id> | ||||
| <version>2.4.4$suffix$</version> | |||||
| <version>2.4.5$suffix$</version> | |||||
| <title>Discord.Net Labs</title> | <title>Discord.Net Labs</title> | ||||
| <authors>Discord.Net Contributors</authors> | <authors>Discord.Net Contributors</authors> | ||||
| <owners>quinchs</owners> | <owners>quinchs</owners> | ||||
| @@ -14,23 +14,23 @@ | |||||
| <iconUrl>https://avatars.githubusercontent.com/u/84047264</iconUrl> | <iconUrl>https://avatars.githubusercontent.com/u/84047264</iconUrl> | ||||
| <dependencies> | <dependencies> | ||||
| <group targetFramework="net461"> | <group targetFramework="net461"> | ||||
| <dependency id="Discord.Net.Labs.Core" version="2.4.2$suffix$" /> | |||||
| <dependency id="Discord.Net.Labs.Rest" version="2.4.3$suffix$" /> | |||||
| <dependency id="Discord.Net.Labs.WebSocket" version="2.4.4$suffix$" /> | |||||
| <dependency id="Discord.Net.Labs.Core" version="2.4.3$suffix$" /> | |||||
| <dependency id="Discord.Net.Labs.Rest" version="2.4.4$suffix$" /> | |||||
| <dependency id="Discord.Net.Labs.WebSocket" version="2.4.5$suffix$" /> | |||||
| <dependency id="Discord.Net.Labs.Commands" version="2.3.5$suffix$" /> | <dependency id="Discord.Net.Labs.Commands" version="2.3.5$suffix$" /> | ||||
| <dependency id="Discord.Net.Labs.Webhook" version="2.3.4$suffix$" /> | <dependency id="Discord.Net.Labs.Webhook" version="2.3.4$suffix$" /> | ||||
| </group> | </group> | ||||
| <group targetFramework="netstandard2.0"> | <group targetFramework="netstandard2.0"> | ||||
| <dependency id="Discord.Net.Labs.Core" version="2.4.2$suffix$" /> | |||||
| <dependency id="Discord.Net.Labs.Rest" version="2.4.3$suffix$" /> | |||||
| <dependency id="Discord.Net.Labs.WebSocket" version="2.4.4$suffix$" /> | |||||
| <dependency id="Discord.Net.Labs.Core" version="2.4.3$suffix$" /> | |||||
| <dependency id="Discord.Net.Labs.Rest" version="2.4.4$suffix$" /> | |||||
| <dependency id="Discord.Net.Labs.WebSocket" version="2.4.5$suffix$" /> | |||||
| <dependency id="Discord.Net.Labs.Commands" version="2.3.5$suffix$" /> | <dependency id="Discord.Net.Labs.Commands" version="2.3.5$suffix$" /> | ||||
| <dependency id="Discord.Net.Labs.Webhook" version="2.3.4$suffix$" /> | <dependency id="Discord.Net.Labs.Webhook" version="2.3.4$suffix$" /> | ||||
| </group> | </group> | ||||
| <group targetFramework="netstandard2.1"> | <group targetFramework="netstandard2.1"> | ||||
| <dependency id="Discord.Net.Labs.Core" version="2.4.2$suffix$" /> | |||||
| <dependency id="Discord.Net.Labs.Rest" version="2.4.3$suffix$" /> | |||||
| <dependency id="Discord.Net.Labs.WebSocket" version="2.4.4$suffix$" /> | |||||
| <dependency id="Discord.Net.Labs.Core" version="2.4.3$suffix$" /> | |||||
| <dependency id="Discord.Net.Labs.Rest" version="2.4.4$suffix$" /> | |||||
| <dependency id="Discord.Net.Labs.WebSocket" version="2.4.5$suffix$" /> | |||||
| <dependency id="Discord.Net.Labs.Commands" version="2.3.5$suffix$" /> | <dependency id="Discord.Net.Labs.Commands" version="2.3.5$suffix$" /> | ||||
| <dependency id="Discord.Net.Labs.Webhook" version="2.3.4$suffix$" /> | <dependency id="Discord.Net.Labs.Webhook" version="2.3.4$suffix$" /> | ||||
| </group> | </group> | ||||