private void On_MidnightTimer(object sender, ElapsedEventArgs e) { UserDataService.On_MidnightTimer(); UserDataService.BackupUserData(); GiveAwayService.BackupGiveAways(); CleanBackups(); midnightTimer = new Timer((DateTime.Today.AddDays(1) - DateTime.Now).TotalMilliseconds); midnightTimer.AutoReset = false; midnightTimer.Elapsed += On_MidnightTimer; }
public Task Client_Ready() { var wowService = _serviceProvider.GetRequiredService <WoWService>(); var userDataService = _serviceProvider.GetRequiredService <UserDataService>(); UserDataService.LoadUserData(); userDataService.InitializeRanks(_client); wowService.Initialize(); GiveAwayService.LoadGiveAways(); return(Task.CompletedTask); }
public async Task Start() { client = new DiscordSocketClient(); commandService = new CommandService(); IServiceCollection services = new ServiceCollection() .AddSingleton <WoWService>() .AddSingleton <UserDataService>() .AddSingleton <GiveAwayService>() .AddSingleton(commandService) .AddSingleton(client); serviceProvider = services.BuildServiceProvider(); commandHandler = new CommandHandler(client, commandService, serviceProvider); eventHandler = new EventHandler(client, serviceProvider); string AuthToken = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "authkey.secret"); await client.LoginAsync(TokenType.Bot, AuthToken, true); await client.StartAsync(); await client.SetGameAsync("Aequinoctium"); while (true) { string command = Console.ReadLine(); switch (command.ToLower()) { case "backup": UserDataService.BackupUserData(); GiveAwayService.BackupGiveAways(); break; case "save": UserDataService.SaveUserData(); GiveAwayService.SaveGiveAways(); break; case "load": UserDataService.LoadUserData(); GiveAwayService.LoadGiveAways(); break; case "stop": UserDataService.SaveUserData(); GiveAwayService.SaveGiveAways(); return; } } }
public async Task getTickets([Summary("GiveawayID")] int giveAwayID) { GiveAwayService.getTickets(giveAwayID, Context); }
public async Task BuyTickets([Summary("GiveawayID")] int giveAwayID, [Summary("Amount")] int amountToBuy) { GiveAwayService.BuyTickets(Context, giveAwayID, amountToBuy); }
public async Task EndGiveAway([Summary("GiveAwayID")] int giveAwayID) { GiveAwayService.EndGiveAway(giveAwayID); }
public async Task SetGiveawayStatus([Summary("GiveAwayID")] int giveAwayID, string status) { GiveAwayService.SetGiveawayStatus(giveAwayID, status); }
public async Task AddReward([Summary("ID")] int giveawayID, [Summary("Reward")] string reward) { GiveAwayService.AddReward(giveawayID, reward); }
public async Task CreateGiveAway([Summary("endsInDays")] int endsInDays, [Summary("entryCost")] int entryCost, params string[] rewards) { GiveAwayService.CreateGiveAway(entryCost, endsInDays, rewards); }