コード例 #1
0
 /// <summary>
 /// Post a message to a guild text or DM channel.
 /// If operating on a guild channel, this endpoint requires the SEND_MESSAGES permission to be present on the current user.
 /// If the tts field is set to true, the SEND_TTS_MESSAGES permission is required for the message to be spoken.
 /// See <a href="https://discord.com/developers/docs/resources/channel#create-message">Create Message</a>
 /// </summary>
 /// <param name="client">Client to use</param>
 /// <param name="channelId">Channel ID to send the message to</param>
 /// <param name="message">Message to be created</param>
 /// <param name="callback">Callback with the created message</param>
 /// <param name="error">Callback when an error occurs with error information</param>
 public static void CreateMessage(DiscordClient client, Snowflake channelId, MessageCreate message, Action <DiscordMessage> callback = null, Action <RestError> error = null)
 {
     if (!channelId.IsValid())
     {
         throw new InvalidSnowflakeException(nameof(channelId));
     }
     message.Validate();
     message.ValidateChannelMessage();
     client.Bot.Rest.DoRequest($"/channels/{channelId}/messages", RequestMethod.POST, message, callback, error);
 }
コード例 #2
0
        /// <summary>
        /// Replies to a previously sent message
        /// See <a href="https://discord.com/developers/docs/resources/channel#create-message">Create Message</a>
        /// </summary>
        /// <param name="client">Client to use</param>
        /// <param name="message">Message to send</param>
        /// <param name="callback">Callback with the message</param>
        /// <param name="error">Callback when an error occurs with error information</param>
        public void Reply(DiscordClient client, MessageCreate message, Action <DiscordMessage> callback = null, Action <RestError> error = null)
        {
            if (message.MessageReference == null)
            {
                message.MessageReference = new MessageReference {
                    MessageId = Id, GuildId = GuildId
                };
            }

            message.Validate();
            client.Bot.Rest.DoRequest($"/channels/{ChannelId}/messages", RequestMethod.POST, message, callback, error);
        }
コード例 #3
0
 /// <summary>
 /// Post a message to a guild text or DM channel.
 /// If operating on a guild channel, this endpoint requires the SEND_MESSAGES permission to be present on the current user.
 /// If the tts field is set to true, the SEND_TTS_MESSAGES permission is required for the message to be spoken.
 /// See <a href="https://discord.com/developers/docs/resources/channel#create-message">Create Message</a>
 /// </summary>
 /// <param name="client">Client to use</param>
 /// <param name="channelId">Channel ID to send the message to</param>
 /// <param name="message">Message to be created</param>
 /// <param name="callback">Callback with the created message</param>
 /// <param name="error">Callback when an error occurs with error information</param>
 public static void CreateMessage(DiscordClient client, Snowflake channelId, MessageCreate message, Action <DiscordMessage> callback = null, Action <RestError> error = null)
 {
     message.Validate();
     client.Bot.Rest.DoRequest($"/channels/{channelId}/messages", RequestMethod.POST, message, callback, error);
 }