title: Hourly auto command for Discord
body: <p>I'm making a bot for discord and have little to no experience with c# coding. I got a basic structure going for basic commands but I can't implement an infinite looping timer which will run the command once every hour into the code. I've gotten far enough where the command works and is random I just cant get the hourly timer. Any help is greatly appreciated.</p>
  
  <pre><code>using Discord;
  using Discord.Commands;
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace bleachedbot
  {
  class MyBot
  {
  
      DiscordClient discord;
      CommandService commands;
  
      Random rand;
  
      string[] bestBleach;
  
      public MyBot()
      {
  
          rand = new Random();
  
          bestBleach = new string[]
              {
                  //All images in the folder.
                  "imagetests/Bleach 001.jpg",
                  "imagetests/Bleach 002.jpg",
                  "imagetests/Bleach 003.jpg"
  
              };
  
          discord = new DiscordClient(x =&gt;
          {
              x.LogLevel = LogSeverity.Info;
              x.LogHandler = Log;
          });
  
          discord.UsingCommands(x =&gt;
          {
              x.PrefixChar = '-';
              x.AllowMentionPrefix = true;
          });
  
          commands = discord.GetService&lt;CommandService&gt;();
          commands.CreateCommand("help")
              .Do(async (e) =&gt;
              {
                  await e.Channel.SendMessage("Commands: ");
              });
  
          RegiseterAutoBleachCommand();
  
          discord.ExecuteAndWait(async () =&gt;
          {
              await discord.Connect("&lt;TOKEN&gt;", TokenType.Bot);
          });
      }
  
      private void RegiseterAutoBleachCommand()
      {
          commands.CreateCommand("foldertest")
              .Do(async (e) =&gt;
              {
  
                  int randomHentaiIndex = rand.Next(bestBleach.Length);
                  string bleachToPost = bestBleach[randomBleachIndex];
                  await e.Channel.SendFile(bleachToPost);
              });
      }
  
      private void Log(object sender, LogMessageEventArgs e)
      {
          Console.WriteLine(e.Message);
      }
  
  }
  }
  </code></pre>