Show / Hide Table of Contents

    Class Utilities

    Various Discord-related utilities.

    Inheritance
    Object
    Utilities
    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
    String str

    String to check.

    Char[] characters

    Characters to check for.

    Returns
    Type Description
    Boolean

    Whether the string contained these characters.

    GetDateTimeOffset(Int64, Boolean)

    Helper method to create a from Unix time seconds for targets that do not support this natively.

    Declaration
    public static DateTimeOffset GetDateTimeOffset(long unixTime, bool shouldThrow = true)
    Parameters
    Type Name Description
    Int64 unixTime

    Unix time seconds to convert.

    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 from Unix time milliseconds for targets that do not support this natively.

    Declaration
    public static DateTimeOffset GetDateTimeOffsetFromMilliseconds(long unixTime, bool shouldThrow = true)
    Parameters
    Type Name Description
    Int64 unixTime

    Unix time milliseconds to convert.

    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
    UInt64 guildId

    The guild id the shard is on.

    Int32 shardCount

    The total amount of shards.

    Returns
    Type Description
    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
    UInt64 snowflake

    Snowflake to compute a timestamp from.

    Returns
    Type Description
    DateTimeOffset

    Computed timestamp.

    GetUnixTime(DateTimeOffset)

    Helper method to calculate Unix time seconds from a for targets that do not support this natively.

    Declaration
    public static long GetUnixTime(DateTimeOffset dto)
    Parameters
    Type Name Description
    DateTimeOffset dto

    to calculate Unix time for.

    Returns
    Type Description
    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
    String

    Human-readable permissions.

    Back to top © 2016-2022 DSharpPlus Contributors