Пример #1
0
        /// <summary>
        ///     Sends a followup message for this interaction
        /// </summary>
        /// <param name="text">The text of the message to be sent</param>
        /// <param name="isTTS"><see langword="true"/> if the message should be read out by a text-to-speech reader, otherwise <see langword="false"/></param>
        /// <param name="embed">A <see cref="Embed"/> to send with this response</param>
        /// <param name="Type">The type of response to this Interaction</param>
        /// <param name="allowedMentions">The allowed mentions for this response</param>
        /// <param name="options">The request options for this response</param>
        /// <returns>
        ///     The sent message
        /// </returns>
        public async Task <IMessage> FollowupAsync(string text = null, bool isTTS = false, Embed embed = null, InteractionResponseType Type = InteractionResponseType.ChannelMessageWithSource,
                                                   AllowedMentions allowedMentions = null, RequestOptions options = null)
        {
            if (Type == InteractionResponseType.ACKWithSource || Type == InteractionResponseType.ACKWithSource || Type == InteractionResponseType.Pong)
            {
                throw new InvalidOperationException($"Cannot use {Type} on a send message function");
            }

            if (!IsValidToken)
            {
                throw new InvalidOperationException("Interaction token is no longer valid");
            }

            var args = new API.Rest.CreateWebhookMessageParams(text)
            {
                IsTTS  = isTTS,
                Embeds = embed != null
                        ? new API.Embed[] { embed.ToModel() }
                        : Optional <API.Embed[]> .Unspecified,
            };

            return(await InteractionHelper.SendFollowupAsync(Discord.Rest, args, Token, Channel, options));
        }
Пример #2
0
        internal static async Task <RestUserMessage> SendFollowupAsync(BaseDiscordClient client, API.Rest.CreateWebhookMessageParams args,
                                                                       string token, IMessageChannel channel, RequestOptions options = null)
        {
            var model = await client.ApiClient.CreateInteractionFollowupMessage(args, token, options).ConfigureAwait(false);

            var entity = RestUserMessage.Create(client, channel, client.CurrentUser, model);

            return(entity);
        }