public static async Task ExecuteCommandAsync(IServiceProvider serviceProvider, SocketSlashCommand command) { var scopeFactory = serviceProvider.GetService<IServiceScopeFactory>(); using var scope = scopeFactory.CreateScope(); var services = scope.ServiceProvider; var client = services.GetService<DiscordSocketClient>(); var commandService = services.GetService<CommandService>(); var dbContext = scope.ServiceProvider.GetService<DatabaseContext>(); var configuration = scope.ServiceProvider.GetService<IConfigurationRoot>(); switch (command.Data.Name) { case "stats": await UserLogic.StatsSlashAsync(command, client, dbContext, configuration); break; case "leaderboard": await LeaderboardLogic.LeaderboardSlashAsync(command, dbContext, configuration); break; case "about": await UtilLogic.AboutSlashAsync(command); break; case "help": await UtilLogic.HelpSlashAsync(command, commandService); break; } }
public void SaveScore() { Player p = new Player(playerNameInput.text, CollectCoin.bestScore); LeaderboardLogic.addPlayerToLeaderboard(p); LeaderboardLogic.SaveFile(); saveScorePanel.SetActive(false); gameOverMenu = true; }