Class Utilities
Various Discord-related utilities.
Inheritance
Namespace: DSharpPlus
Assembly: cs.temp.dll.dll
Syntax
public static class Utilities
Methods
Contains(String, Char[])
Checks whether this string contains given characters.
Declaration
public static bool Contains(this string str, params char[] characters)
Parameters
Type | Name | Description |
---|---|---|
System.String | str | String to check. |
System.Char[] | characters | Characters to check for. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the string contained these characters. |
GetDateTimeOffset(Int64, Boolean)
Helper method to create a
Declaration
public static DateTimeOffset GetDateTimeOffset(long unixTime, bool shouldThrow = true)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | unixTime | Unix time seconds to convert. |
System.Boolean | shouldThrow | Whether the method should throw on failure. Defaults to true. |
Returns
Type | Description |
---|---|
DateTimeOffset | Calculated |
GetDateTimeOffsetFromMilliseconds(Int64, Boolean)
Helper method to create a
Declaration
public static DateTimeOffset GetDateTimeOffsetFromMilliseconds(long unixTime, bool shouldThrow = true)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | unixTime | Unix time milliseconds to convert. |
System.Boolean | shouldThrow | Whether the method should throw on failure. Defaults to true. |
Returns
Type | Description |
---|---|
DateTimeOffset | Calculated |
GetShardId(UInt64, Int32)
Gets a shard id from a guild id and total shard count.
Declaration
public static int GetShardId(ulong guildId, int shardCount)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | guildId | The guild id the shard is on. |
System.Int32 | shardCount | The total amount of shards. |
Returns
Type | Description |
---|---|
System.Int32 | The shard id. |
GetSnowflakeTime(UInt64)
Computes a timestamp from a given snowflake.
Declaration
public static DateTimeOffset GetSnowflakeTime(this ulong snowflake)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | snowflake | Snowflake to compute a timestamp from. |
Returns
Type | Description |
---|---|
DateTimeOffset | Computed timestamp. |
GetUnixTime(DateTimeOffset)
Helper method to calculate Unix time seconsd from a
Declaration
public static long GetUnixTime(DateTimeOffset dto)
Parameters
Type | Name | Description |
---|---|---|
DateTimeOffset | dto |
Returns
Type | Description |
---|---|
System.Int64 | Calculated Unix time. |
ToPermissionString(Permissions)
Converts this Permissions into human-readable format.
Declaration
public static string ToPermissionString(this Permissions perm)
Parameters
Type | Name | Description |
---|---|---|
Permissions | perm | Permissions enumeration to convert. |
Returns
Type | Description |
---|---|
System.String | Human-readable permissions. |