Ejemplo n.º 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="embeds">A <see cref="Embed"/> to send with this response.</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="allowedMentions">The allowed mentions for this response.</param>
        /// <param name="flags"></param>
        /// <param name="options">The request options for this response.</param>
        /// <returns>
        ///     The sent message.
        /// </returns>
        public async Task <IMessage> FollowupEmbedsAsync(IEnumerable <Embed> embeds, string text = null, bool isTTS = false, AllowedMentions allowedMentions = null,
                                                         int?flags = null, RequestOptions options = null)
        {
            if (!IsValidToken)
            {
                throw new InvalidOperationException("Interaction token is no longer valid");
            }

            var args = new CreateWebhookMessageParams(text)
            {
                IsTTS = isTTS
            };

            if (embeds != null)
            {
                args.Embeds = embeds.Select(x => x.ToModel()).ToArray();
            }
            if (allowedMentions != null)
            {
                args.AllowedMentions = allowedMentions.ToModel();
            }
            if (flags.HasValue)
            {
                args.Flags = flags.Value;
            }

            return(await InteractionHelper.SendFollowupAsync(Discord.Rest, args, Token, Channel, options).ConfigureAwait(false));
        }
Ejemplo n.º 2
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));
        }