示例#1
0
 /// <summary>
 /// Sends a message through the webhook
 /// </summary>
 /// <param name="webhookId">ID of the webhook</param>
 /// <param name="webhookToken">The webhook's token</param>
 /// <param name="content">The message to send</param>
 /// <param name="embed">Embed to include in the message</param>
 /// <param name="profile">Custom Username and Avatar url (both are optional)</param>
 public static void SendWebhookMessage(this DiscordClient client, ulong webhookId, string webhookToken, string content, DiscordEmbed embed = null, DiscordWebhookProfile profile = null)
 {
     client.SendWebhookMessageAsync(webhookId, webhookToken, content, embed, profile).GetAwaiter().GetResult();
 }
示例#2
0
 /// <summary>
 /// Sends a message through the webhook
 /// </summary>
 /// <param name="content">The message to send</param>
 /// <param name="embed">Embed to include in the message</param>
 /// <param name="profile">Custom Username and Avatar url (both are optional)</param>
 public void SendMessage(string content, DiscordEmbed embed = null, DiscordWebhookProfile profile = null)
 {
     SendMessageAsync(content, embed, profile).GetAwaiter().GetResult();
 }
示例#3
0
        public static async Task SendWebhookMessageAsync(this DiscordClient client, ulong webhookId, string webhookToken, string content, DiscordEmbed embed = null, DiscordWebhookProfile profile = null)
        {
            var properties = new WebhookMessageProperties()
            {
                Content = content, Embed = embed
            };

            if (profile != null)
            {
                if (profile.NameProperty.Set)
                {
                    properties.Username = profile.Username;
                }
                if (profile.AvatarProperty.Set)
                {
                    properties.AvatarUrl = profile.AvatarUrl;
                }
            }

            await client.HttpClient.PostAsync($"/webhooks/{webhookId}/{webhookToken}", properties);
        }
示例#4
0
 public async Task SendMessageAsync(string content, DiscordEmbed embed = null, DiscordWebhookProfile profile = null)
 {
     await Client.SendWebhookMessageAsync(Id, Token, content, embed, profile);
 }