Skip to content

Itamaram/Itamaram.Azure.WebJobs.Extensions.Discord

Repository files navigation

Itamaram.Azure.WebJobs.Extensions.Discord

A custom Azure WebJob input binding trigger for Discord

Usage:

  • Create a new WebJob project
  • Install the nuget package Itamaram.Azure.WebJobs.Extensions.Discord
  • Ensure your configuration scope includes a variable named token containing your bot's token
  • Call AddDiscord in your ConfigureWebJobs
  • Get triggered

Sample Code

  public class Program
  {
      public static async Task Main()
      {
          var host = new HostBuilder()
              .ConfigureWebJobs(b => b.AddDiscord())
              .Build();

          using (host)
              await host.RunAsync();
      }
  }

  public class Pingers
  {
      public async Task Ping([DiscordMessageTrigger("%token%")] MessageCreateEventArgs args)
      {
          if (args.Message.Content.ToLower().StartsWith("ping"))
              await args.Message.RespondAsync("pong!");
      }

      public async Task Hell([DiscordMessageTrigger("%token%")] MessageCreateEventArgs args)
      {
          if (args.Message.Content.ToLower().StartsWith("hell"))
              await args.Message.RespondAsync("yeah!");
      }
  }

(Full code sample is included in this repo)

About

A custom Azure WebJob input binding trigger for Discord

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages