예제 #1
0
        /// <summary>
        /// Replaces this message with a new copy of itself and modifies it with the specified properties.
        /// </summary>
        public static async Task <IUserMessage> ReplaceAsync(this IUserMessage message,
                                                             MemoryStream gif,
                                                             string path,
                                                             string text                     = null,
                                                             bool isTTS                      = false,
                                                             Embed embed                     = null,
                                                             bool deleteLastMessage          = false,
                                                             RequestOptions options          = null,
                                                             bool isSpoiler                  = false,
                                                             AllowedMentions allowedMentions = null)
        {
            IUserMessage next = await message.Channel.SendGifAsync(gif,
                                                                   path,
                                                                   Check.NotNull(text)?text : message.Content,
                                                                   isTTS,
                                                                   embed ?? message.GetRichEmbed()?.Build(),
                                                                   options,
                                                                   isSpoiler,
                                                                   allowedMentions);

            if (deleteLastMessage)
            {
                await message.DeleteAsync();
            }

            return(next);
        }
예제 #2
0
        /// <summary>
        /// Replaces this message with a new copy of itself and modifies it with the specified properties.
        /// </summary>
        public static async Task <IUserMessage> ReplaceAsync(this IUserMessage message,
                                                             System.Drawing.Image image,
                                                             string path,
                                                             string text                     = null,
                                                             bool isTTS                      = false,
                                                             Embed embed                     = null,
                                                             GraphicsFormat format           = GraphicsFormat.Png,
                                                             bool deleteLastMessage          = false,
                                                             RequestOptions options          = null,
                                                             bool isSpoiler                  = false,
                                                             AllowedMentions allowedMentions = null)
        {
            IUserMessage next = await message.Channel.SendImageAsync(image,
                                                                     path,
                                                                     !string.IsNullOrWhiteSpace(text)?text : message.Content,
                                                                     isTTS,
                                                                     embed ?? message.GetRichEmbed()?.Build(),
                                                                     format,
                                                                     options,
                                                                     isSpoiler,
                                                                     allowedMentions);

            if (deleteLastMessage)
            {
                await message.DeleteAsync();
            }

            return(next);
        }
예제 #3
0
 /// <summary>
 /// Modifies this message.
 /// </summary>
 public static async Task ModifyAsync(this IUserMessage message,
                                      string text            = null,
                                      Embed embed            = null,
                                      RequestOptions options = null)
 {
     await message.ModifyAsync(delegate(MessageProperties x)
     {
         x.Content = !string.IsNullOrWhiteSpace(text) ? text : message.Content;
         x.Embed   = embed ?? message.GetRichEmbed()?.Build();
     }, options);
 }
예제 #4
0
        /// <summary>
        /// Replaces this message with a new copy of itself and modifies it with the specified properties.
        /// </summary>
        public static async Task <IUserMessage> ReplaceAsync(this IUserMessage message,
                                                             string text                     = null,
                                                             bool isTTS                      = false,
                                                             Embed embed                     = null,
                                                             string filePath                 = null,
                                                             bool deleteLastMessage          = false,
                                                             RequestOptions options          = null,
                                                             bool isSpoiler                  = false,
                                                             AllowedMentions allowedMentions = null)
        {
            IUserMessage next;

            if (!string.IsNullOrWhiteSpace(filePath))
            {
                next = await message.Channel.SendFileAsync(filePath,
                                                           !string.IsNullOrWhiteSpace(text)?text : message.Content,
                                                           isTTS,
                                                           embed ?? message.GetRichEmbed()?.Build(),
                                                           options,
                                                           isSpoiler,
                                                           allowedMentions);
            }
            else
            {
                next = await message.Channel.SendMessageAsync(
                    !string.IsNullOrWhiteSpace(text)?text : message.Content,
                    isTTS,
                    embed ?? message.GetRichEmbed()?.Build(),
                    options,
                    allowedMentions);
            }

            if (deleteLastMessage)
            {
                await message.DeleteAsync();
            }

            return(next);
        }