Search Results for

    Show / Hide Table of Contents

    Class Utilities

    Various Discord-related utilities.

    Inheritance
    System.Object
    Utilities
    Namespace: DisCatSharp
    Assembly: DisCatSharp.dll
    Syntax
    public static class Utilities

    Methods

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    GetDateTimeOffset(Int64, Boolean)

    Helper method to create a System.DateTimeOffset 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
    System.Int64 unixTime

    Unix time seconds to convert.

    System.Boolean shouldThrow

    Whether the method should throw on failure. Defaults to true.

    Returns
    Type Description
    System.DateTimeOffset

    Calculated System.DateTimeOffset.

    | Improve this Doc View Source

    GetDateTimeOffsetFromMilliseconds(Int64, Boolean)

    Helper method to create a System.DateTimeOffset 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
    System.Int64 unixTime

    Unix time milliseconds to convert.

    System.Boolean shouldThrow

    Whether the method should throw on failure. Defaults to true.

    Returns
    Type Description
    System.DateTimeOffset

    Calculated System.DateTimeOffset.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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
    System.DateTimeOffset

    Computed timestamp.

    | Improve this Doc View Source

    GetUnixTime(DateTimeOffset)

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

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

    System.DateTimeOffset to calculate Unix time for.

    Returns
    Type Description
    System.Int64

    Calculated Unix time.

    | Improve this Doc View Source

    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.

    • Improve this Doc
    • View Source
    In This Article
    Back to top © 2021-2022 Aiko IT Systems