Skip to content

Commit

Permalink
Make eval cmd async
Browse files Browse the repository at this point in the history
  • Loading branch information
Bond-009 committed May 5, 2017
1 parent 1fda25b commit a805125
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
3 changes: 1 addition & 2 deletions src/iTool.DiscordBot/AudioManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public static string GetSong(string name)
{
return Common.AudioDir + Path.DirectorySeparatorChar +
new Deserializer().Deserialize<List<AudioFile>>(File.ReadAllText(Common.AudioIndexFile))
.Where(x => x.Names.Contains(name))
.FirstOrDefault()?.FileName;
.FirstOrDefault(x => x.Names.Contains(name))?.FileName;
}
catch (Exception ex)
{
Expand Down
22 changes: 11 additions & 11 deletions src/iTool.DiscordBot/Bot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ public async Task<bool> Start()
await discordClient.LoginAsync(TokenType.Bot, settings.DiscordToken);
await discordClient.StartAsync();

IServiceCollection serviceCollection = new ServiceCollection();
serviceCollection.AddSingleton(new AudioService());
serviceCollection.AddSingleton(new Battlelog.Bf3.Bf3Client());
serviceCollection.AddSingleton(new Battlelog.Bf4.Bf4Client());
serviceCollection.AddSingleton(new Battlelog.BfH.BfHClient());
serviceCollection.AddSingleton(new BattlelogService());
serviceCollection.AddSingleton(new HOTSLogs.HOTSLogsClient());
serviceCollection.AddSingleton(new OpenWeather.OpenWeatherClient(settings.OpenWeatherMapKey));
serviceCollection.AddSingleton(settings);
serviceCollection.AddSingleton(new Steam.SteamAPI(settings.SteamKey));
serviceProvider = serviceCollection.BuildServiceProvider();
serviceProvider = new ServiceCollection()
.AddSingleton(new AudioService())
.AddSingleton(new Battlelog.Bf3.Bf3Client())
.AddSingleton(new Battlelog.Bf4.Bf4Client())
.AddSingleton(new Battlelog.BfH.BfHClient())
.AddSingleton(new BattlelogService())
.AddSingleton(new HOTSLogs.HOTSLogsClient())
.AddSingleton(new OpenWeather.OpenWeatherClient(settings.OpenWeatherMapKey))
.AddSingleton(settings)
.AddSingleton(new Steam.SteamAPI(settings.SteamKey))
.BuildServiceProvider();

await new CommandHandler(serviceProvider, discordClient, new CommandServiceConfig()
{
Expand Down
2 changes: 1 addition & 1 deletion src/iTool.DiscordBot/Modules/Dev.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public async Task GC()
});
}

[Command("eval")]
[Command("eval", RunMode = RunMode.Async)]
[Alias("cseval", "csharp", "evaluate")]
[Summary("Evaluates C# code")]
[RequireTrustedUser]
Expand Down
2 changes: 1 addition & 1 deletion src/iTool.DiscordBot/Modules/General.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public async Task Help(int page = 1)
public async Task Help(string cmdName)
{
CommandInfo cmd = cmdService.Commands
.Where(x => x.Aliases.Contains(cmdName)).FirstOrDefault();
.FirstOrDefault(x => x.Aliases.Contains(cmdName));

if (cmd == null)
{
Expand Down

0 comments on commit a805125

Please sign in to comment.