đź“–
Wiki Nova Life
  • Bienvenue !
  • Discord MOD
  • Serveur
    • Introduction
    • L'hĂ©bergeur
    • La configuration
    • Ajouter des plugins
  • Plugins
    • Introduction
    • Informations pour dĂ©buter
    • Aides
      • ModKit
      • Base d'un plugin
      • CenterText
      • Config JSON
      • Commande
      • Cooldown individuel
      • Cooldown global
      • ÉvĂ©nements
      • Points
      • Panels
      • Webhook (Embed)
      • Webhook (Message)
  • Flocages
    • Introduction
    • Informations pour dĂ©buter
    • Flocage de vĂŞtement
    • Flocage de vĂ©hicule
    • Flocage de panneau
Propulsé par GitBook
Sur cette page
  1. Plugins
  2. Aides

Webhook (Message)

Voici comment créer un webhook :

  • Avec ModKit :

public static DiscordWebhookClient WebhookClient = new DiscordWebhookClient("url_webhook");

await DiscordHelper.SendMsg(DiscordPlugin.WebhookClient, $"Votre message");

  • Sans ModKit :

private static readonly HttpClient client = new HttpClient();

public static async Task SendWebhook(string message, string url)
{
    try
    {
        var payload = new
        {
            content = message
        };

        string json = JsonConvert.SerializeObject(payload);
        StringContent data = new StringContent(json, Encoding.UTF8, "application/json");

        HttpResponseMessage response = await client.PostAsync(url, data);

        if (!response.IsSuccessStatusCode)
        {
                UnityEngine.Debug.LogError($"Erreur Webhook : {response.StatusCode} - {response.ReasonPhrase}");
        }
    }
    catch (Exception ex)
    {
        UnityEngine.Debug.LogError("Erreur lors de l'envoi du webhook : " + ex.Message);
    }
}
PrécédentWebhook (Embed)SuivantIntroduction

Dernière mise à jour il y a 3 mois