Now even compiles and runs

This commit is contained in:
Kwoth 2016-12-08 18:46:08 +01:00
parent 318701e25a
commit b3635ae577
8 changed files with 16 additions and 35 deletions

View File

@ -63,7 +63,7 @@ namespace NadekoBot.Modules.Administration
}, null, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10));
}
public LogCommands(ShardedDiscordClient client)
public LogCommands()
{
//_client.MessageReceived += _client_MessageReceived;
_client.MessageUpdated += _client_MessageUpdated;

View File

@ -13,9 +13,9 @@ namespace NadekoBot.Modules.Administration
{
private ShardedDiscordClient _client;
public SelfCommands(ShardedDiscordClient client)
public SelfCommands()
{
this._client = client;
this._client = NadekoBot.Client;
}
[NadekoCommand, Usage, Description, Aliases]

View File

@ -20,19 +20,16 @@ namespace NadekoBot.Modules.Music
[NadekoModule("Music", "!!", AutoLoad = false)]
public partial class Music : DiscordModule
{
public static ConcurrentDictionary<ulong, MusicPlayer> MusicPlayers = new ConcurrentDictionary<ulong, MusicPlayer>();
public static ConcurrentDictionary<ulong, MusicPlayer> MusicPlayers { get; } = new ConcurrentDictionary<ulong, MusicPlayer>();
public const string MusicDataPath = "data/musicdata";
private IGoogleApiService _google;
public Music(ILocalization loc, CommandService cmds, ShardedDiscordClient client, IGoogleApiService google) : base()
public Music() : base()
{
//it can fail if its currenctly opened or doesn't exist. Either way i don't care
try { Directory.Delete(MusicDataPath, true); } catch { }
Directory.CreateDirectory(MusicDataPath);
_google = google;
}
[NadekoCommand, Usage, Description, Aliases]
@ -259,13 +256,13 @@ namespace NadekoBot.Modules.Music
await channel.SendMessageAsync("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining it.").ConfigureAwait(false);
return;
}
var plId = (await _google.GetPlaylistIdsByKeywordsAsync(arg).ConfigureAwait(false)).FirstOrDefault();
var plId = (await NadekoBot.Google.GetPlaylistIdsByKeywordsAsync(arg).ConfigureAwait(false)).FirstOrDefault();
if (plId == null)
{
await channel.SendMessageAsync("No search results for that query.");
return;
}
var ids = await _google.GetPlaylistTracksAsync(plId, 500).ConfigureAwait(false);
var ids = await NadekoBot.Google.GetPlaylistTracksAsync(plId, 500).ConfigureAwait(false);
if (!ids.Any())
{
await channel.SendMessageAsync($"🎵 `Failed to find any songs.`").ConfigureAwait(false);

View File

@ -23,13 +23,6 @@ namespace NadekoBot.Modules.Searches
[NadekoModule("Searches", "~")]
public partial class Searches : DiscordModule
{
private IGoogleApiService _google { get; }
public Searches(ILocalization loc, CommandService cmds, ShardedDiscordClient client, IGoogleApiService youtube) : base()
{
_google = youtube;
}
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
public async Task Weather(IUserMessage umsg, string city, string country)
@ -63,7 +56,7 @@ namespace NadekoBot.Modules.Searches
{
var channel = (ITextChannel)umsg.Channel;
if (!(await ValidateQuery(channel, query).ConfigureAwait(false))) return;
var result = (await _google.GetVideosByKeywordsAsync(query, 1)).FirstOrDefault();
var result = (await NadekoBot.Google.GetVideosByKeywordsAsync(query, 1)).FirstOrDefault();
if (string.IsNullOrWhiteSpace(result))
{
await channel.SendMessageAsync("No results found for that query.");
@ -186,7 +179,7 @@ namespace NadekoBot.Modules.Searches
if (string.IsNullOrWhiteSpace(ffs))
return;
await channel.SendMessageAsync(await _google.ShortenUrl($"<http://lmgtfy.com/?q={ Uri.EscapeUriString(ffs) }>"))
await channel.SendMessageAsync(await NadekoBot.Google.ShortenUrl($"<http://lmgtfy.com/?q={ Uri.EscapeUriString(ffs) }>"))
.ConfigureAwait(false);
}
@ -240,7 +233,7 @@ namespace NadekoBot.Modules.Searches
throw new KeyNotFoundException("Cannot find a card by that name");
var msg = $@"```css
[☕ Magic The Gathering]: {items[0]["name"].ToString()}
[Store URL]: {await _google.ShortenUrl(items[0]["store_url"].ToString())}
[Store URL]: {await NadekoBot.Google.ShortenUrl(items[0]["store_url"].ToString())}
[Cost]: {items[0]["cost"].ToString()}
[Description]: {items[0]["text"].ToString()}
```
@ -387,7 +380,7 @@ namespace NadekoBot.Modules.Searches
var sb = new StringBuilder();
sb.AppendLine($"`Term:` {items["list"][0]["word"].ToString()}");
sb.AppendLine($"`Definition:` {items["list"][0]["definition"].ToString()}");
sb.Append($"`Link:` <{await _google.ShortenUrl(items["list"][0]["permalink"].ToString()).ConfigureAwait(false)}>");
sb.Append($"`Link:` <{await NadekoBot.Google.ShortenUrl(items["list"][0]["permalink"].ToString()).ConfigureAwait(false)}>");
await channel.SendMessageAsync(sb.ToString());
}
catch
@ -429,7 +422,7 @@ namespace NadekoBot.Modules.Searches
var items = JObject.Parse(res);
var str = $@"`Hashtag:` {items["defs"]["def"]["hashtag"].ToString()}
`Definition:` {items["defs"]["def"]["text"].ToString()}
`Link:` <{await _google.ShortenUrl(items["defs"]["def"]["uri"].ToString()).ConfigureAwait(false)}>";
`Link:` <{await NadekoBot.Google.ShortenUrl(items["defs"]["def"]["uri"].ToString()).ConfigureAwait(false)}>";
await channel.SendMessageAsync(str);
}
catch
@ -564,7 +557,7 @@ namespace NadekoBot.Modules.Searches
await channel.SendMessageAsync("Invalid user specified.").ConfigureAwait(false);
return;
}
await channel.SendMessageAsync(await _google.ShortenUrl(usr.AvatarUrl).ConfigureAwait(false)).ConfigureAwait(false);
await channel.SendMessageAsync(await NadekoBot.Google.ShortenUrl(usr.AvatarUrl).ConfigureAwait(false)).ConfigureAwait(false);
}
public static async Task<string> GetSafebooruImageLink(string tag)

View File

@ -30,7 +30,6 @@ namespace NadekoBot
public static CommandService CommandService { get; private set; }
public static CommandHandler CommandHandler { get; private set; }
public static ShardedDiscordClient Client { get; private set; }
public static Localization Localizer { get; private set; }
public static BotCredentials Credentials { get; private set; }
public static GoogleApiService Google { get; private set; }
@ -70,7 +69,6 @@ namespace NadekoBot
//initialize Services
CommandService = new CommandService();
Localizer = new Localization();
Google = new GoogleApiService();
CommandHandler = new CommandHandler(Client, CommandService);
Stats = new StatsService(Client, CommandHandler);
@ -106,7 +104,7 @@ namespace NadekoBot
await CommandService.LoadAssembly(this.GetType().GetTypeInfo().Assembly).ConfigureAwait(false);
#if !GLOBAL_NADEKO
await CommandService.Load(new Music(Localizer, CommandService, Client, Google)).ConfigureAwait(false);
await CommandService.Load(new Music()).ConfigureAwait(false);
#endif
Ready = true;
Console.WriteLine(await Stats.Print().ConfigureAwait(false));

View File

@ -1,7 +0,0 @@
namespace NadekoBot.Services
{
public interface ILocalization
{
string this[string key] { get; }
}
}

View File

@ -1,6 +1,6 @@
namespace NadekoBot.Services
{
public class Localization : ILocalization
public class Localization
{
public string this[string key] => LoadCommandString(key);