Search Results for

    Show / Hide Table of Contents

    Interface IDiscordRestChannel

    Contains all the API calls mentioned in the channel object documentation. Docs: https://discord.com/developers/docs/resources/channel

    Namespace: Color_Chan.Discord.Core.Common.API.Rest
    Assembly: Color-Chan.Discord.Core.dll
    Syntax
    public interface IDiscordRestChannel

    Methods

    | Improve this Doc View Source

    BulkDeleteMessageAsync(UInt64, IReadOnlyList<UInt64>, String, CancellationToken)

    Bulks delete 2-100 messages.

    Declaration
    Task<Result> BulkDeleteMessageAsync(ulong channelId, IReadOnlyList<ulong> messageIds, string auditLogReason = null, CancellationToken ct = default(CancellationToken))
    Parameters
    Type Name Description
    System.UInt64 channelId

    The channel id.

    System.Collections.Generic.IReadOnlyList<System.UInt64> messageIds

    The message IDs of the message that will be deleted.

    System.String auditLogReason

    The reason for this action. This will be shown in the audit logs.

    System.Threading.CancellationToken ct

    The System.Threading.CancellationToken.

    Returns
    Type Description
    System.Threading.Tasks.Task<Result>

    A Result with the request results.

    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    Thrown when messageIds is not between 2 and 100.

    | Improve this Doc View Source

    CreateMessageAsync(UInt64, DiscordCreateChannelMessage, CancellationToken)

    Posts a message to a text channel.

    Declaration
    Task<Result<IDiscordMessage>> CreateMessageAsync(ulong channelId, DiscordCreateChannelMessage message, CancellationToken ct = default(CancellationToken))
    Parameters
    Type Name Description
    System.UInt64 channelId

    The ID of the text channel.

    DiscordCreateChannelMessage message

    The DiscordCreateChannelMessage containing the data that will be used to create a message.

    System.Threading.CancellationToken ct

    The System.Threading.CancellationToken.

    Returns
    Type Description
    System.Threading.Tasks.Task<Result<IDiscordMessage>>

    A Result<T> of IDiscordMessage with the request results.

    Remarks

    you must provide a value for at least one of content, embeds, or file.

    Limitations-

    • When operating on a guild channel, the current user must have the SEND_MESSAGES permission.
    • When sending a message with tts (text-to-speech) set to true, the current user must have the SEND_TTS_MESSAGES permission.
    • When creating a message as a reply to another message, the current user must have the READ_MESSAGE_HISTORY permission. And the message can not be a system message.
    • The maximum request size when sending a message is 8MB
    • For the embed object, you can set every field except type (it will be rich regardless of if you try to set it), provider, video, and any height, width, or proxy_url values for images.

    | Improve this Doc View Source

    CreateReactionAsync(UInt64, UInt64, String, CancellationToken)

    Add a reaction to a message.

    Declaration
    Task<Result> CreateReactionAsync(ulong channelId, ulong messageId, string emoji, CancellationToken ct = default(CancellationToken))
    Parameters
    Type Name Description
    System.UInt64 channelId

    The channel id.

    System.UInt64 messageId

    The message id of the message where the reaction will be added to.

    System.String emoji

    The emoji that will be added to a message, you must encode it in the format name:id with the emoji name and emoji id.

    System.Threading.CancellationToken ct

    The System.Threading.CancellationToken.

    Returns
    Type Description
    System.Threading.Tasks.Task<Result>

    A Result with the request results.

    | Improve this Doc View Source

    CrosspostMessageAsync(UInt64, UInt64, CancellationToken)

    Crosspost a message in a News Channel to following channels.

    Declaration
    Task<Result<IDiscordMessage>> CrosspostMessageAsync(ulong channelId, ulong messageId, CancellationToken ct = default(CancellationToken))
    Parameters
    Type Name Description
    System.UInt64 channelId

    The channel id.

    System.UInt64 messageId

    The message id.

    System.Threading.CancellationToken ct

    The System.Threading.CancellationToken.

    Returns
    Type Description
    System.Threading.Tasks.Task<Result<IDiscordMessage>>

    A Result<T> of IDiscordMessage with the request results.

    Remarks

    This endpoint requires the 'SEND_MESSAGES' permission, if the current user sent the message, or additionally the 'MANAGE_MESSAGES' permission, for all other messages, to be present for the current user.

    | Improve this Doc View Source

    DeleteAllReactionAsync(UInt64, UInt64, String, CancellationToken)

    Deletes all reactions for a given emoji.

    Declaration
    Task<Result> DeleteAllReactionAsync(ulong channelId, ulong messageId, string emoji, CancellationToken ct = default(CancellationToken))
    Parameters
    Type Name Description
    System.UInt64 channelId

    The channel id.

    System.UInt64 messageId

    The message id of the message where the reactions will be deleted from.

    System.String emoji

    The emoji that will be deleted from the message, you must encode it in the format name:id with the emoji name and emoji id.

    System.Threading.CancellationToken ct

    The System.Threading.CancellationToken.

    Returns
    Type Description
    System.Threading.Tasks.Task<Result>

    A Result with the request results.

    | Improve this Doc View Source

    DeleteMessageAsync(UInt64, UInt64, String, CancellationToken)

    Deletes a message.

    Declaration
    Task<Result> DeleteMessageAsync(ulong channelId, ulong messageId, string auditLogReason = null, CancellationToken ct = default(CancellationToken))
    Parameters
    Type Name Description
    System.UInt64 channelId

    The channel id.

    System.UInt64 messageId

    The message ID of the message that will be deleted.

    System.String auditLogReason

    The reason for this action. This will be shown in the audit logs.

    System.Threading.CancellationToken ct

    The System.Threading.CancellationToken.

    Returns
    Type Description
    System.Threading.Tasks.Task<Result>

    A Result with the request results.

    | Improve this Doc View Source

    DeleteOrCloseAsync(UInt64, CancellationToken)

    Deletes or closes a channel.

    Declaration
    Task<Result<IDiscordChannel>> DeleteOrCloseAsync(ulong channelId, CancellationToken ct = default(CancellationToken))
    Parameters
    Type Name Description
    System.UInt64 channelId

    The channel id.

    System.Threading.CancellationToken ct

    The System.Threading.CancellationToken.

    Returns
    Type Description
    System.Threading.Tasks.Task<Result<IDiscordChannel>>

    A Result<T> of IDiscordChannel with the request results.

    Remarks

    Requires the MANAGE_CHANNELS permission for the guild, or MANAGE_THREADS if the channel is a thread.

    Deleting a category does not delete its child channels; they will have their parent_id removed and a Channel Update Gateway event will fire for each of them.

    | Improve this Doc View Source

    DeleteOwnReactionAsync(UInt64, UInt64, String, CancellationToken)

    Delete your own reaction on a message.

    Declaration
    Task<Result> DeleteOwnReactionAsync(ulong channelId, ulong messageId, string emoji, CancellationToken ct = default(CancellationToken))
    Parameters
    Type Name Description
    System.UInt64 channelId

    The channel id.

    System.UInt64 messageId

    The message id of the message where the reaction will be deleted from.

    System.String emoji

    The emoji that will be deleted from the message, you must encode it in the format name:id with the emoji name and emoji id.

    System.Threading.CancellationToken ct

    The System.Threading.CancellationToken.

    Returns
    Type Description
    System.Threading.Tasks.Task<Result>

    A Result with the request results.

    | Improve this Doc View Source

    DeleteUserReactionAsync(UInt64, UInt64, String, UInt64, CancellationToken)

    Delete a users reaction on a message.

    Declaration
    Task<Result> DeleteUserReactionAsync(ulong channelId, ulong messageId, string emoji, ulong userId, CancellationToken ct = default(CancellationToken))
    Parameters
    Type Name Description
    System.UInt64 channelId

    The channel id.

    System.UInt64 messageId

    The message id of the message where the reaction will be deleted from.

    System.String emoji

    The emoji that will be deleted from the message, you must encode it in the format name:id with the emoji name and emoji id.

    System.UInt64 userId

    The user ID of the user that added the reaction.

    System.Threading.CancellationToken ct

    The System.Threading.CancellationToken.

    Returns
    Type Description
    System.Threading.Tasks.Task<Result>

    A Result with the request results.

    | Improve this Doc View Source

    EditMessageAsync(UInt64, UInt64, DiscordEditChannelMessage, CancellationToken)

    Edit a previously sent message.

    Declaration
    Task<Result<IDiscordMessage>> EditMessageAsync(ulong channelId, ulong messageId, DiscordEditChannelMessage editChannelMessage, CancellationToken ct = default(CancellationToken))
    Parameters
    Type Name Description
    System.UInt64 channelId

    The channel id.

    System.UInt64 messageId

    The ID of the message that will be edited.

    DiscordEditChannelMessage editChannelMessage

    The DiscordEditChannelMessage containing the new content for the message.

    System.Threading.CancellationToken ct

    The System.Threading.CancellationToken.

    Returns
    Type Description
    System.Threading.Tasks.Task<Result<IDiscordMessage>>

    A Result<T> of IDiscordMessage with the request results.

    Remarks

    The fields content, embeds, and flags can be edited by the original message author. Other users can only edit flags and only if they have the MANAGE_MESSAGES permission in the corresponding channel.

    When the content field is edited, the mentions array in the message object will be reconstructed from scratch based on the new content.

    | Improve this Doc View Source

    GetChannelAsync(UInt64, CancellationToken)

    Gets a channel.

    Declaration
    Task<Result<IDiscordChannel>> GetChannelAsync(ulong channelId, CancellationToken ct = default(CancellationToken))
    Parameters
    Type Name Description
    System.UInt64 channelId

    The channel id.

    System.Threading.CancellationToken ct

    The System.Threading.CancellationToken.

    Returns
    Type Description
    System.Threading.Tasks.Task<Result<IDiscordChannel>>

    A Result<T> of IDiscordChannel with the request results.

    | Improve this Doc View Source

    GetChannelMessageAsync(UInt64, UInt64, CancellationToken)

    Get a specific message from a channel.

    Declaration
    Task<Result<IDiscordMessage>> GetChannelMessageAsync(ulong channelId, ulong messageId, CancellationToken ct = default(CancellationToken))
    Parameters
    Type Name Description
    System.UInt64 channelId

    The channel id.

    System.UInt64 messageId

    The message id.

    System.Threading.CancellationToken ct

    The System.Threading.CancellationToken.

    Returns
    Type Description
    System.Threading.Tasks.Task<Result<IDiscordMessage>>

    A Result<T> of IDiscordMessage with the request results.

    Remarks

    If operating on a guild channel, this endpoint requires the 'READ_MESSAGE_HISTORY' permission to be present on the current user.

    | Improve this Doc View Source

    GetChannelMessagesAsync(UInt64, Nullable<UInt64>, Nullable<UInt64>, Nullable<UInt64>, Int32, CancellationToken)

    Get messages from a channel.

    Declaration
    Task<Result<IReadOnlyList<IDiscordMessage>>> GetChannelMessagesAsync(ulong channelId, ulong? around = null, ulong? before = null, ulong? after = null, int limit = 50, CancellationToken ct = default(CancellationToken))
    Parameters
    Type Name Description
    System.UInt64 channelId

    The channel id.

    System.Nullable<System.UInt64> around

    Get messages around this message ID.

    System.Nullable<System.UInt64> before

    Get messages before this message ID.

    System.Nullable<System.UInt64> after

    Get messages after this message ID.

    System.Int32 limit

    Max number of messages to return (1-100)

    System.Threading.CancellationToken ct

    The System.Threading.CancellationToken.

    Returns
    Type Description
    System.Threading.Tasks.Task<Result<System.Collections.Generic.IReadOnlyList<IDiscordMessage>>>

    A Result<T> of System.Collections.Generic.IReadOnlyList<T> of IDiscordMessage with the request results.

    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    Thrown when limit is out of range.

    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX