Exemplo n.º 1
0
 public async Task FileAsync()
 {
     using (var attachment = new LocalAttachment(@"C:\Users\quahu\Desktop\bbb.png"))
     {
         await ReplyAsync(attachment);
     }
 }
 private DiscordCommandResult(string text, LocalEmbed embed, LocalAttachment attachment, bool isSuccessful)
 {
     Text         = text;
     Embed        = embed;
     Attachment   = attachment;
     IsSuccessful = isSuccessful;
 }
Exemplo n.º 3
0
        public async Task <RestGuildEmoji> CreateEmojiAsync(string name, LocalAttachment image, IEnumerable <Snowflake> roleIds = null, RestRequestOptions options = null)
        {
            var emoji = await Client.CreateGuildEmojiAsync(Id, name, image, roleIds, options).ConfigureAwait(false);

            emoji.Guild.SetValue(this);
            return(emoji);
        }
Exemplo n.º 4
0
 public AdminCommandResult(TimeSpan executionTime, string text, LocalEmbed embed, LocalAttachment attachment, bool isSuccessful)
 {
     ExecutionTime = executionTime;
     Text          = text;
     Embed         = embed;
     Attachment    = attachment;
     IsSuccessful  = isSuccessful;
 }
Exemplo n.º 5
0
        public async Task <RestGuild> CreateGuildAsync(
            string name, string voiceRegionId = null, LocalAttachment icon = null, VerificationLevel verificationLevel = default,
            DefaultNotificationLevel defaultNotificationLevel = default, ContentFilterLevel contentFilterLevel = default,
            RestRequestOptions options = null)
        {
            var model = await ApiClient.CreateGuildAsync(name, voiceRegionId, icon, verificationLevel, defaultNotificationLevel, contentFilterLevel, options).ConfigureAwait(false);

            return(new RestGuild(this, model));
        }
Exemplo n.º 6
0
        public async Task <RestUserMessage> SendMessageAsync(Snowflake channelId, LocalAttachment attachment, string content = null, bool textToSpeech = false, LocalEmbed embed = null, LocalMentions mentions = null, RestRequestOptions options = null)
        {
            if (attachment == null)
            {
                throw new ArgumentNullException(nameof(attachment));
            }

            var model = await ApiClient.CreateMessageAsync(channelId, attachment, content, textToSpeech, embed, mentions, options).ConfigureAwait(false);

            return(new RestUserMessage(this, model));
        }
Exemplo n.º 7
0
        public async Task <RestUserMessage> ExecuteWebhookAsync(Snowflake webhookId, string webhookToken,
                                                                LocalAttachment attachment,
                                                                string content             = null, bool textToSpeech = false, IEnumerable <Embed> embeds = null,
                                                                string name                = null, string avatarUrl  = null,
                                                                bool wait                  = false,
                                                                RestRequestOptions options = null)
        {
            var model = await ApiClient.ExecuteWebhookAsync(webhookId, webhookToken, attachment, content, textToSpeech, embeds, name, avatarUrl, wait, options).ConfigureAwait(false);

            if (!wait)
            {
                return(null);
            }

            return(new RestUserMessage(this, model));
        }
Exemplo n.º 8
0
        public async Task RandomColorAsync(Color color)
        {
            var colorImagePath = _colorService.GetColorImage(color.ToString());

            using (var colorImage = LocalAttachment.File(colorImagePath, "colorImage.png"))
            {
                var eb = new LocalEmbed()
                         .WithColor(color)
                         .WithDescription($"Hex: {color.ToString()}\nRGB: {color.R} {color.G} {color.B}")
                         .WithImageUrl("attachment://colorImage.png");

                var mb = new LocalMessage()
                         .WithAttachments(colorImage)
                         .WithEmbeds(eb);

                await Response(mb);
            }

            File.Delete(colorImagePath);
        }
Exemplo n.º 9
0
        public async Task SearchColorAsync(
            [Description("The R component"), Range(0, 256)] int r,
            [Description("The G component"), Range(0, 256)] int g,
            [Description("The B component"), Range(0, 256)] int b)
        {
            var color  = new Color(Convert.ToByte(r), Convert.ToByte(g), Convert.ToByte(b));
            var result = await _colorService.GetColorInfo(color.ToString().Substring(1));

            var colorImagePath = _colorService.GetColorImage(color.ToString());

            using (var colorImage = LocalAttachment.File(colorImagePath, "colorImage.png"))
            {
                var eb = new LocalEmbed()
                         .WithTitle(result.Name.Value)
                         .WithColor(color)
                         .WithImageUrl("attachment://colorImage.png");

                if (result.Name.ExactMatchName)
                {
                    eb.AddField("Hex value", result.Hex.Value);
                }
                else
                {
                    eb.AddField("Closest Match Hex", result.Name.ClosestNamedHex);
                }

                eb.AddField("RGB", result.Rgb.Value)
                .AddField("HSL", result.Hsl.Value)
                .AddField("HSV", result.Hsv.Value)
                .AddField("CMYK", result.Cmyk.Value);

                var mb = new LocalMessage()
                         .WithAttachments(colorImage)
                         .WithEmbeds(eb);

                await Response(mb);
            }

            File.Delete(colorImagePath);
        }
Exemplo n.º 10
0
 public Task <RestUserMessage> ExecuteAsync(LocalAttachment attachment, string content = null, bool textToSpeech = false, params Embed[] embeds)
 => _client.ExecuteWebhookAsync(Id, Token, attachment, content, textToSpeech, embeds);
Exemplo n.º 11
0
 public Task <RestWebhook> CreateWebhookAsync(string name, LocalAttachment avatar = null, RestRequestOptions options = null)
 => Client.CreateWebhookAsync(Id, name, avatar, options);
Exemplo n.º 12
0
        public async Task <RestUserMessage> SendMessageAsync(LocalAttachment attachment, string content = null, bool textToSpeech = false, LocalEmbed embed = null, LocalMentions mentions = null, RestRequestOptions options = null)
        {
            var channel = await CreateDmChannelAsync(options).ConfigureAwait(false);

            return(await channel.SendMessageAsync(attachment, content, textToSpeech, embed, mentions, options).ConfigureAwait(false));
        }
Exemplo n.º 13
0
        public async Task <RestWebhook> CreateWebhookAsync(Snowflake channelId, string name, LocalAttachment avatar = null, RestRequestOptions options = null)
        {
            var model = await ApiClient.CreateWebhookAsync(channelId, name, avatar, options).ConfigureAwait(false);

            return(new RestWebhook(this, model));
        }
 public static DiscordCommandResult Unsuccessful(string text = default, LocalEmbed embed = default, LocalAttachment attachment = null)
 => new DiscordCommandResult(text, embed, attachment, false);
Exemplo n.º 15
0
 public Task <RestUserMessage> ExecuteAsync(LocalAttachment attachment, string content = null, bool textToSpeech = false, IEnumerable <Embed> embeds = null, string name = null, string avatarUrl = null, bool wait = false)
 => _client.ExecuteWebhookAsync(Id, Token, attachment, content, textToSpeech, embeds, name, avatarUrl, wait);
Exemplo n.º 16
0
 protected AdminCommandResult CommandErrorLocalized(string key, LocalEmbed embed = null, LocalAttachment attachment = null,
                                                    params object[] args)
 => new AdminCommandResult(_watch.Elapsed, Localization.Localize(Context.Language, key, args), embed, attachment,
                           false);
Exemplo n.º 17
0
 protected AdminCommandResult CommandError(string text, LocalEmbed embed = null, LocalAttachment attachment = null)
 => new AdminCommandResult(_watch.Elapsed, text, embed, attachment, false);
Exemplo n.º 18
0
 protected AdminCommandResult CommandSuccess(string text = null, LocalEmbed embed = null, LocalAttachment attachment = null)
 => new AdminCommandResult(_watch.Elapsed, text, embed, attachment, true);
 public DiscordCommandResult Success(string text = default, LocalEmbed embed = default, LocalAttachment attachment = default)
 => DiscordCommandResult.Successful(text, embed, attachment);
Exemplo n.º 20
0
 public Task <RestUserMessage> SendMessageAsync(LocalAttachment attachment, string content = null, bool isTTS = false, Embed embed = null, RestRequestOptions options = null)
 => Client.SendMessageAsync(Id, attachment, content, isTTS, embed, options);
Exemplo n.º 21
0
        public async Task <RestGuildEmoji> CreateGuildEmojiAsync(Snowflake guildId, string name, LocalAttachment image, IEnumerable <Snowflake> roleIds = null, RestRequestOptions options = null)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            name = name ?? Path.GetFileNameWithoutExtension(image.FileName);
            var model = await ApiClient.CreateGuildEmojiAsync(guildId, name, image, roleIds.Select(x => x.RawValue), options).ConfigureAwait(false);

            return(new RestGuildEmoji(this, model, guildId));
        }