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; }
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); }
public AdminCommandResult(TimeSpan executionTime, string text, LocalEmbed embed, LocalAttachment attachment, bool isSuccessful) { ExecutionTime = executionTime; Text = text; Embed = embed; Attachment = attachment; IsSuccessful = isSuccessful; }
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)); }
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)); }
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)); }
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); }
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); }
public Task <RestUserMessage> ExecuteAsync(LocalAttachment attachment, string content = null, bool textToSpeech = false, params Embed[] embeds) => _client.ExecuteWebhookAsync(Id, Token, attachment, content, textToSpeech, embeds);
public Task <RestWebhook> CreateWebhookAsync(string name, LocalAttachment avatar = null, RestRequestOptions options = null) => Client.CreateWebhookAsync(Id, name, avatar, options);
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)); }
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);
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);
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);
protected AdminCommandResult CommandError(string text, LocalEmbed embed = null, LocalAttachment attachment = null) => new AdminCommandResult(_watch.Elapsed, text, embed, attachment, false);
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);
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);
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)); }