More refactoring

This commit is contained in:
Master Kwoth 2017-07-15 18:34:34 +02:00
parent b3243eb0e9
commit 4e11a6c8bc
39 changed files with 174 additions and 284 deletions

View File

@ -12,16 +12,14 @@ using NadekoBot.Services.Administration;
namespace NadekoBot.Modules.Administration namespace NadekoBot.Modules.Administration
{ {
public partial class Administration : NadekoTopLevelModule public partial class Administration : NadekoTopLevelModule<AdministrationService>
{ {
private IGuild _nadekoSupportServer; private IGuild _nadekoSupportServer;
private readonly DbService _db; private readonly DbService _db;
private readonly AdministrationService _admin;
public Administration(DbService db, AdministrationService admin) public Administration(DbService db)
{ {
_db = db; _db = db;
_admin = admin;
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -40,12 +38,12 @@ namespace NadekoBot.Modules.Administration
} }
if (enabled) if (enabled)
{ {
_admin.DeleteMessagesOnCommand.Add(Context.Guild.Id); _service.DeleteMessagesOnCommand.Add(Context.Guild.Id);
await ReplyConfirmLocalized("delmsg_on").ConfigureAwait(false); await ReplyConfirmLocalized("delmsg_on").ConfigureAwait(false);
} }
else else
{ {
_admin.DeleteMessagesOnCommand.TryRemove(Context.Guild.Id); _service.DeleteMessagesOnCommand.TryRemove(Context.Guild.Id);
await ReplyConfirmLocalized("delmsg_off").ConfigureAwait(false); await ReplyConfirmLocalized("delmsg_off").ConfigureAwait(false);
} }
} }

View File

@ -12,15 +12,13 @@ namespace NadekoBot.Modules.Administration
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class AutoAssignRoleCommands : NadekoSubmodule public class AutoAssignRoleCommands : NadekoSubmodule<AutoAssignRoleService>
{ {
private readonly DbService _db; private readonly DbService _db;
private readonly AutoAssignRoleService _service;
public AutoAssignRoleCommands(AutoAssignRoleService service, DbService db) public AutoAssignRoleCommands(DbService db)
{ {
_db = db; _db = db;
_service = service;
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]

View File

@ -10,15 +10,13 @@ namespace NadekoBot.Modules.Administration
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class GameChannelCommands : NadekoSubmodule public class GameChannelCommands : NadekoSubmodule<GameVoiceChannelService>
{ {
private readonly DbService _db; private readonly DbService _db;
private readonly GameVoiceChannelService _service;
public GameChannelCommands(GameVoiceChannelService service, DbService db) public GameChannelCommands(DbService db)
{ {
_db = db; _db = db;
_service = service;
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]

View File

@ -18,14 +18,12 @@ namespace NadekoBot.Modules.Administration
{ {
[Group] [Group]
[NoPublicBot] [NoPublicBot]
public class LogCommands : NadekoSubmodule public class LogCommands : NadekoSubmodule<LogCommandService>
{ {
private readonly LogCommandService _lc;
private readonly DbService _db; private readonly DbService _db;
public LogCommands(LogCommandService lc, DbService db) public LogCommands(DbService db)
{ {
_lc = lc;
_db = db; _db = db;
} }
@ -46,7 +44,7 @@ namespace NadekoBot.Modules.Administration
using (var uow = _db.UnitOfWork) using (var uow = _db.UnitOfWork)
{ {
logSetting = uow.GuildConfigs.LogSettingsFor(channel.Guild.Id).LogSetting; logSetting = uow.GuildConfigs.LogSettingsFor(channel.Guild.Id).LogSetting;
_lc.GuildLogSettings.AddOrUpdate(channel.Guild.Id, (id) => logSetting, (id, old) => logSetting); _service.GuildLogSettings.AddOrUpdate(channel.Guild.Id, (id) => logSetting, (id, old) => logSetting);
logSetting.LogOtherId = logSetting.LogOtherId =
logSetting.MessageUpdatedId = logSetting.MessageUpdatedId =
logSetting.MessageDeletedId = logSetting.MessageDeletedId =
@ -82,7 +80,7 @@ namespace NadekoBot.Modules.Administration
using (var uow = _db.UnitOfWork) using (var uow = _db.UnitOfWork)
{ {
var config = uow.GuildConfigs.LogSettingsFor(channel.Guild.Id); var config = uow.GuildConfigs.LogSettingsFor(channel.Guild.Id);
LogSetting logSetting = _lc.GuildLogSettings.GetOrAdd(channel.Guild.Id, (id) => config.LogSetting); LogSetting logSetting = _service.GuildLogSettings.GetOrAdd(channel.Guild.Id, (id) => config.LogSetting);
removed = logSetting.IgnoredChannels.RemoveWhere(ilc => ilc.ChannelId == channel.Id); removed = logSetting.IgnoredChannels.RemoveWhere(ilc => ilc.ChannelId == channel.Id);
config.LogSetting.IgnoredChannels.RemoveWhere(ilc => ilc.ChannelId == channel.Id); config.LogSetting.IgnoredChannels.RemoveWhere(ilc => ilc.ChannelId == channel.Id);
if (removed == 0) if (removed == 0)
@ -122,7 +120,7 @@ namespace NadekoBot.Modules.Administration
using (var uow = _db.UnitOfWork) using (var uow = _db.UnitOfWork)
{ {
var logSetting = uow.GuildConfigs.LogSettingsFor(channel.Guild.Id).LogSetting; var logSetting = uow.GuildConfigs.LogSettingsFor(channel.Guild.Id).LogSetting;
_lc.GuildLogSettings.AddOrUpdate(channel.Guild.Id, (id) => logSetting, (id, old) => logSetting); _service.GuildLogSettings.AddOrUpdate(channel.Guild.Id, (id) => logSetting, (id, old) => logSetting);
switch (type) switch (type)
{ {
case LogType.Other: case LogType.Other:

View File

@ -11,14 +11,12 @@ namespace NadekoBot.Modules.Administration
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class MuteCommands : NadekoSubmodule public class MuteCommands : NadekoSubmodule<MuteService>
{ {
private readonly MuteService _service;
private readonly DbService _db; private readonly DbService _db;
public MuteCommands(MuteService service, DbService db) public MuteCommands(DbService db)
{ {
_service = service;
_db = db; _db = db;
} }

View File

@ -11,16 +11,14 @@ namespace NadekoBot.Modules.Administration
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class PlayingRotateCommands : NadekoSubmodule public class PlayingRotateCommands : NadekoSubmodule<PlayingRotateService>
{ {
private static readonly object _locker = new object(); private static readonly object _locker = new object();
private readonly DbService _db; private readonly DbService _db;
private readonly PlayingRotateService _service;
public PlayingRotateCommands(PlayingRotateService service, DbService db) public PlayingRotateCommands(DbService db)
{ {
_db = db; _db = db;
_service = service;
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]

View File

@ -15,15 +15,13 @@ namespace NadekoBot.Modules.Administration
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class ProtectionCommands : NadekoSubmodule public class ProtectionCommands : NadekoSubmodule<ProtectionService>
{ {
private readonly ProtectionService _service;
private readonly MuteService _mute; private readonly MuteService _mute;
private readonly DbService _db; private readonly DbService _db;
public ProtectionCommands(ProtectionService service, MuteService mute, DbService db) public ProtectionCommands(MuteService mute, DbService db)
{ {
_service = service;
_mute = mute; _mute = mute;
_db = db; _db = db;
} }

View File

@ -4,9 +4,6 @@ using NadekoBot.Attributes;
using NadekoBot.Extensions; using NadekoBot.Extensions;
using NadekoBot.Services.Administration; using NadekoBot.Services.Administration;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace NadekoBot.Modules.Administration namespace NadekoBot.Modules.Administration
@ -14,15 +11,9 @@ namespace NadekoBot.Modules.Administration
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class PruneCommands : ModuleBase public class PruneCommands : NadekoSubmodule<PruneService>
{ {
private readonly TimeSpan twoWeeks = TimeSpan.FromDays(14); private readonly TimeSpan twoWeeks = TimeSpan.FromDays(14);
private readonly PruneService _prune;
public PruneCommands(PruneService prune)
{
_prune = prune;
}
//delets her own messages, no perm required //delets her own messages, no perm required
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -31,7 +22,7 @@ namespace NadekoBot.Modules.Administration
{ {
var user = await Context.Guild.GetCurrentUserAsync().ConfigureAwait(false); var user = await Context.Guild.GetCurrentUserAsync().ConfigureAwait(false);
await _prune.PruneWhere((ITextChannel)Context.Channel, 100, (x) => x.Author.Id == user.Id).ConfigureAwait(false); await _service.PruneWhere((ITextChannel)Context.Channel, 100, (x) => x.Author.Id == user.Id).ConfigureAwait(false);
Context.Message.DeleteAfter(3); Context.Message.DeleteAfter(3);
} }
// prune x // prune x
@ -47,7 +38,7 @@ namespace NadekoBot.Modules.Administration
return; return;
if (count > 1000) if (count > 1000)
count = 1000; count = 1000;
await _prune.PruneWhere((ITextChannel)Context.Channel, count, x => true).ConfigureAwait(false); await _service.PruneWhere((ITextChannel)Context.Channel, count, x => true).ConfigureAwait(false);
} }
//prune @user [x] //prune @user [x]
@ -66,7 +57,7 @@ namespace NadekoBot.Modules.Administration
if (count > 1000) if (count > 1000)
count = 1000; count = 1000;
await _prune.PruneWhere((ITextChannel)Context.Channel, count, m => m.Author.Id == user.Id && DateTime.UtcNow - m.CreatedAt < twoWeeks); await _service.PruneWhere((ITextChannel)Context.Channel, count, m => m.Author.Id == user.Id && DateTime.UtcNow - m.CreatedAt < twoWeeks);
} }
} }
} }

View File

@ -15,14 +15,12 @@ namespace NadekoBot.Modules.Administration
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class SlowModeCommands : NadekoSubmodule public class SlowModeCommands : NadekoSubmodule<SlowmodeService>
{ {
private readonly SlowmodeService _service;
private readonly DbService _db; private readonly DbService _db;
public SlowModeCommands(SlowmodeService service, DbService db) public SlowModeCommands(DbService db)
{ {
_service = service;
_db = db; _db = db;
} }

View File

@ -14,7 +14,6 @@ using NadekoBot.Services.Database.Models;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Administration; using NadekoBot.Services.Administration;
using System.Diagnostics; using System.Diagnostics;
using NadekoBot.DataStructures;
using NadekoBot.Services.Music; using NadekoBot.Services.Music;
namespace NadekoBot.Modules.Administration namespace NadekoBot.Modules.Administration
@ -22,21 +21,19 @@ namespace NadekoBot.Modules.Administration
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class SelfCommands : NadekoSubmodule public class SelfCommands : NadekoSubmodule<SelfService>
{ {
private readonly DbService _db; private readonly DbService _db;
private static readonly object _locker = new object(); private static readonly object _locker = new object();
private readonly SelfService _service;
private readonly DiscordSocketClient _client; private readonly DiscordSocketClient _client;
private readonly IImagesService _images; private readonly IImagesService _images;
private readonly MusicService _music; private readonly MusicService _music;
public SelfCommands(DbService db, SelfService service, DiscordSocketClient client, public SelfCommands(DbService db, DiscordSocketClient client,
MusicService music, IImagesService images) MusicService music, IImagesService images)
{ {
_db = db; _db = db;
_service = service;
_client = client; _client = client;
_images = images; _images = images;
_music = music; _music = music;

View File

@ -11,14 +11,12 @@ namespace NadekoBot.Modules.Administration
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class ServerGreetCommands : NadekoSubmodule public class ServerGreetCommands : NadekoSubmodule<GreetSettingsService>
{ {
private readonly GreetSettingsService _greetService;
private readonly DbService _db; private readonly DbService _db;
public ServerGreetCommands(GreetSettingsService greetService, DbService db) public ServerGreetCommands(DbService db)
{ {
_greetService = greetService;
_db = db; _db = db;
} }
@ -30,7 +28,7 @@ namespace NadekoBot.Modules.Administration
if (timer < 0 || timer > 600) if (timer < 0 || timer > 600)
return; return;
await _greetService.SetGreetDel(Context.Guild.Id, timer).ConfigureAwait(false); await _service.SetGreetDel(Context.Guild.Id, timer).ConfigureAwait(false);
if (timer > 0) if (timer > 0)
await ReplyConfirmLocalized("greetdel_on", timer).ConfigureAwait(false); await ReplyConfirmLocalized("greetdel_on", timer).ConfigureAwait(false);
@ -43,7 +41,7 @@ namespace NadekoBot.Modules.Administration
[RequireUserPermission(GuildPermission.ManageGuild)] [RequireUserPermission(GuildPermission.ManageGuild)]
public async Task Greet() public async Task Greet()
{ {
var enabled = await _greetService.SetGreet(Context.Guild.Id, Context.Channel.Id).ConfigureAwait(false); var enabled = await _service.SetGreet(Context.Guild.Id, Context.Channel.Id).ConfigureAwait(false);
if (enabled) if (enabled)
await ReplyConfirmLocalized("greet_on").ConfigureAwait(false); await ReplyConfirmLocalized("greet_on").ConfigureAwait(false);
@ -67,7 +65,7 @@ namespace NadekoBot.Modules.Administration
return; return;
} }
var sendGreetEnabled = _greetService.SetGreetMessage(Context.Guild.Id, ref text); var sendGreetEnabled = _service.SetGreetMessage(Context.Guild.Id, ref text);
await ReplyConfirmLocalized("greetmsg_new").ConfigureAwait(false); await ReplyConfirmLocalized("greetmsg_new").ConfigureAwait(false);
if (!sendGreetEnabled) if (!sendGreetEnabled)
@ -79,7 +77,7 @@ namespace NadekoBot.Modules.Administration
[RequireUserPermission(GuildPermission.ManageGuild)] [RequireUserPermission(GuildPermission.ManageGuild)]
public async Task GreetDm() public async Task GreetDm()
{ {
var enabled = await _greetService.SetGreetDm(Context.Guild.Id).ConfigureAwait(false); var enabled = await _service.SetGreetDm(Context.Guild.Id).ConfigureAwait(false);
if (enabled) if (enabled)
await ReplyConfirmLocalized("greetdm_on").ConfigureAwait(false); await ReplyConfirmLocalized("greetdm_on").ConfigureAwait(false);
@ -103,7 +101,7 @@ namespace NadekoBot.Modules.Administration
return; return;
} }
var sendGreetEnabled = _greetService.SetGreetDmMessage(Context.Guild.Id, ref text); var sendGreetEnabled = _service.SetGreetDmMessage(Context.Guild.Id, ref text);
await ReplyConfirmLocalized("greetdmmsg_new").ConfigureAwait(false); await ReplyConfirmLocalized("greetdmmsg_new").ConfigureAwait(false);
if (!sendGreetEnabled) if (!sendGreetEnabled)
@ -115,7 +113,7 @@ namespace NadekoBot.Modules.Administration
[RequireUserPermission(GuildPermission.ManageGuild)] [RequireUserPermission(GuildPermission.ManageGuild)]
public async Task Bye() public async Task Bye()
{ {
var enabled = await _greetService.SetBye(Context.Guild.Id, Context.Channel.Id).ConfigureAwait(false); var enabled = await _service.SetBye(Context.Guild.Id, Context.Channel.Id).ConfigureAwait(false);
if (enabled) if (enabled)
await ReplyConfirmLocalized("bye_on").ConfigureAwait(false); await ReplyConfirmLocalized("bye_on").ConfigureAwait(false);
@ -139,7 +137,7 @@ namespace NadekoBot.Modules.Administration
return; return;
} }
var sendByeEnabled = _greetService.SetByeMessage(Context.Guild.Id, ref text); var sendByeEnabled = _service.SetByeMessage(Context.Guild.Id, ref text);
await ReplyConfirmLocalized("byemsg_new").ConfigureAwait(false); await ReplyConfirmLocalized("byemsg_new").ConfigureAwait(false);
if (!sendByeEnabled) if (!sendByeEnabled)
@ -151,7 +149,7 @@ namespace NadekoBot.Modules.Administration
[RequireUserPermission(GuildPermission.ManageGuild)] [RequireUserPermission(GuildPermission.ManageGuild)]
public async Task ByeDel(int timer = 30) public async Task ByeDel(int timer = 30)
{ {
await _greetService.SetByeDel(Context.Guild.Id, timer).ConfigureAwait(false); await _service.SetByeDel(Context.Guild.Id, timer).ConfigureAwait(false);
if (timer > 0) if (timer > 0)
await ReplyConfirmLocalized("byedel_on", timer).ConfigureAwait(false); await ReplyConfirmLocalized("byedel_on", timer).ConfigureAwait(false);

View File

@ -13,15 +13,8 @@ namespace NadekoBot.Modules.Administration
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class TimeZoneCommands : NadekoSubmodule public class TimeZoneCommands : NadekoSubmodule<GuildTimezoneService>
{ {
private readonly GuildTimezoneService _service;
public TimeZoneCommands(GuildTimezoneService service)
{
_service = service;
}
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Timezones(int page = 1) public async Task Timezones(int page = 1)

View File

@ -15,15 +15,13 @@ namespace NadekoBot.Modules.Administration
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class UserPunishCommands : NadekoSubmodule public class UserPunishCommands : NadekoSubmodule<UserPunishService>
{ {
private readonly DbService _db; private readonly DbService _db;
private readonly UserPunishService _service;
public UserPunishCommands(UserPunishService service, DbService db, MuteService muteService) public UserPunishCommands(DbService db, MuteService muteService)
{ {
_db = db; _db = db;
_service = service;
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]

View File

@ -16,14 +16,12 @@ namespace NadekoBot.Modules.Administration
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class VcRoleCommands : NadekoSubmodule public class VcRoleCommands : NadekoSubmodule<VcRoleService>
{ {
private readonly VcRoleService _service;
private readonly DbService _db; private readonly DbService _db;
public VcRoleCommands(VcRoleService service, DbService db) public VcRoleCommands(DbService db)
{ {
_service = service;
_db = db; _db = db;
} }

View File

@ -15,14 +15,12 @@ namespace NadekoBot.Modules.Administration
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class VoicePlusTextCommands : NadekoSubmodule public class VoicePlusTextCommands : NadekoSubmodule<VplusTService>
{ {
private readonly VplusTService _service;
private readonly DbService _db; private readonly DbService _db;
public VoicePlusTextCommands(VplusTService service, DbService db) public VoicePlusTextCommands(DbService db)
{ {
_service = service;
_db = db; _db = db;
} }

View File

@ -12,19 +12,17 @@ using NadekoBot.Services.CustomReactions;
namespace NadekoBot.Modules.CustomReactions namespace NadekoBot.Modules.CustomReactions
{ {
public class CustomReactions : NadekoTopLevelModule public class CustomReactions : NadekoTopLevelModule<CustomReactionsService>
{ {
private readonly IBotCredentials _creds; private readonly IBotCredentials _creds;
private readonly DbService _db; private readonly DbService _db;
private readonly CustomReactionsService _crs;
private readonly DiscordSocketClient _client; private readonly DiscordSocketClient _client;
public CustomReactions(IBotCredentials creds, DbService db, CustomReactionsService crs, public CustomReactions(IBotCredentials creds, DbService db,
DiscordSocketClient client) DiscordSocketClient client)
{ {
_creds = creds; _creds = creds;
_db = db; _db = db;
_crs = crs;
_client = client; _client = client;
} }
@ -60,12 +58,12 @@ namespace NadekoBot.Modules.CustomReactions
if (channel == null) if (channel == null)
{ {
Array.Resize(ref _crs.GlobalReactions, _crs.GlobalReactions.Length + 1); Array.Resize(ref _service.GlobalReactions, _service.GlobalReactions.Length + 1);
_crs.GlobalReactions[_crs.GlobalReactions.Length - 1] = cr; _service.GlobalReactions[_service.GlobalReactions.Length - 1] = cr;
} }
else else
{ {
_crs.GuildReactions.AddOrUpdate(Context.Guild.Id, _service.GuildReactions.AddOrUpdate(Context.Guild.Id,
new CustomReaction[] { cr }, new CustomReaction[] { cr },
(k, old) => (k, old) =>
{ {
@ -91,9 +89,9 @@ namespace NadekoBot.Modules.CustomReactions
return; return;
CustomReaction[] customReactions; CustomReaction[] customReactions;
if (Context.Guild == null) if (Context.Guild == null)
customReactions = _crs.GlobalReactions.Where(cr => cr != null).ToArray(); customReactions = _service.GlobalReactions.Where(cr => cr != null).ToArray();
else else
customReactions = _crs.GuildReactions.GetOrAdd(Context.Guild.Id, Array.Empty<CustomReaction>()).Where(cr => cr != null).ToArray(); customReactions = _service.GuildReactions.GetOrAdd(Context.Guild.Id, Array.Empty<CustomReaction>()).Where(cr => cr != null).ToArray();
if (customReactions == null || !customReactions.Any()) if (customReactions == null || !customReactions.Any())
{ {
@ -135,9 +133,9 @@ namespace NadekoBot.Modules.CustomReactions
{ {
CustomReaction[] customReactions; CustomReaction[] customReactions;
if (Context.Guild == null) if (Context.Guild == null)
customReactions = _crs.GlobalReactions.Where(cr => cr != null).ToArray(); customReactions = _service.GlobalReactions.Where(cr => cr != null).ToArray();
else else
customReactions = _crs.GuildReactions.GetOrAdd(Context.Guild.Id, new CustomReaction[]{ }).Where(cr => cr != null).ToArray(); customReactions = _service.GuildReactions.GetOrAdd(Context.Guild.Id, new CustomReaction[]{ }).Where(cr => cr != null).ToArray();
if (customReactions == null || !customReactions.Any()) if (customReactions == null || !customReactions.Any())
{ {
@ -165,9 +163,9 @@ namespace NadekoBot.Modules.CustomReactions
return; return;
CustomReaction[] customReactions; CustomReaction[] customReactions;
if (Context.Guild == null) if (Context.Guild == null)
customReactions = _crs.GlobalReactions.Where(cr => cr != null).ToArray(); customReactions = _service.GlobalReactions.Where(cr => cr != null).ToArray();
else else
customReactions = _crs.GuildReactions.GetOrAdd(Context.Guild.Id, new CustomReaction[]{ }).Where(cr => cr != null).ToArray(); customReactions = _service.GuildReactions.GetOrAdd(Context.Guild.Id, new CustomReaction[]{ }).Where(cr => cr != null).ToArray();
if (customReactions == null || !customReactions.Any()) if (customReactions == null || !customReactions.Any())
{ {
@ -197,9 +195,9 @@ namespace NadekoBot.Modules.CustomReactions
{ {
CustomReaction[] customReactions; CustomReaction[] customReactions;
if (Context.Guild == null) if (Context.Guild == null)
customReactions = _crs.GlobalReactions; customReactions = _service.GlobalReactions;
else else
customReactions = _crs.GuildReactions.GetOrAdd(Context.Guild.Id, new CustomReaction[]{ }); customReactions = _service.GuildReactions.GetOrAdd(Context.Guild.Id, new CustomReaction[]{ });
var found = customReactions.FirstOrDefault(cr => cr?.Id == id); var found = customReactions.FirstOrDefault(cr => cr?.Id == id);
@ -240,13 +238,13 @@ namespace NadekoBot.Modules.CustomReactions
{ {
uow.CustomReactions.Remove(toDelete); uow.CustomReactions.Remove(toDelete);
//todo 91 i can dramatically improve performance of this, if Ids are ordered. //todo 91 i can dramatically improve performance of this, if Ids are ordered.
_crs.GlobalReactions = _crs.GlobalReactions.Where(cr => cr?.Id != toDelete.Id).ToArray(); _service.GlobalReactions = _service.GlobalReactions.Where(cr => cr?.Id != toDelete.Id).ToArray();
success = true; success = true;
} }
else if ((toDelete.GuildId != null && toDelete.GuildId != 0) && Context.Guild.Id == toDelete.GuildId) else if ((toDelete.GuildId != null && toDelete.GuildId != 0) && Context.Guild.Id == toDelete.GuildId)
{ {
uow.CustomReactions.Remove(toDelete); uow.CustomReactions.Remove(toDelete);
_crs.GuildReactions.AddOrUpdate(Context.Guild.Id, new CustomReaction[] { }, (key, old) => _service.GuildReactions.AddOrUpdate(Context.Guild.Id, new CustomReaction[] { }, (key, old) =>
{ {
return old.Where(cr => cr?.Id != toDelete.Id).ToArray(); return old.Where(cr => cr?.Id != toDelete.Id).ToArray();
}); });
@ -284,10 +282,10 @@ namespace NadekoBot.Modules.CustomReactions
CustomReaction[] reactions = new CustomReaction[0]; CustomReaction[] reactions = new CustomReaction[0];
if (Context.Guild == null) if (Context.Guild == null)
reactions = _crs.GlobalReactions; reactions = _service.GlobalReactions;
else else
{ {
_crs.GuildReactions.TryGetValue(Context.Guild.Id, out reactions); _service.GuildReactions.TryGetValue(Context.Guild.Id, out reactions);
} }
if (reactions.Any()) if (reactions.Any())
{ {
@ -335,10 +333,10 @@ namespace NadekoBot.Modules.CustomReactions
CustomReaction[] reactions = new CustomReaction[0]; CustomReaction[] reactions = new CustomReaction[0];
if (Context.Guild == null) if (Context.Guild == null)
reactions = _crs.GlobalReactions; reactions = _service.GlobalReactions;
else else
{ {
_crs.GuildReactions.TryGetValue(Context.Guild.Id, out reactions); _service.GuildReactions.TryGetValue(Context.Guild.Id, out reactions);
} }
if (reactions.Any()) if (reactions.Any())
{ {
@ -379,13 +377,13 @@ namespace NadekoBot.Modules.CustomReactions
{ {
if (string.IsNullOrWhiteSpace(trigger)) if (string.IsNullOrWhiteSpace(trigger))
{ {
_crs.ClearStats(); _service.ClearStats();
await ReplyConfirmLocalized("all_stats_cleared").ConfigureAwait(false); await ReplyConfirmLocalized("all_stats_cleared").ConfigureAwait(false);
} }
else else
{ {
uint throwaway; uint throwaway;
if (_crs.ReactionStats.TryRemove(trigger, out throwaway)) if (_service.ReactionStats.TryRemove(trigger, out throwaway))
{ {
await ReplyErrorLocalized("stats_cleared", Format.Bold(trigger)).ConfigureAwait(false); await ReplyErrorLocalized("stats_cleared", Format.Bold(trigger)).ConfigureAwait(false);
} }
@ -401,7 +399,7 @@ namespace NadekoBot.Modules.CustomReactions
{ {
if (--page < 0) if (--page < 0)
return; return;
var ordered = _crs.ReactionStats.OrderByDescending(x => x.Value).ToArray(); var ordered = _service.ReactionStats.OrderByDescending(x => x.Value).ToArray();
if (!ordered.Any()) if (!ordered.Any())
return; return;
var lastPage = ordered.Length / 9; var lastPage = ordered.Length / 9;

View File

@ -11,15 +11,13 @@ namespace NadekoBot.Modules.Games
public partial class Games public partial class Games
{ {
[Group] [Group]
public class CleverBotCommands : NadekoSubmodule public class CleverBotCommands : NadekoSubmodule<ChatterBotService>
{ {
private readonly DbService _db; private readonly DbService _db;
private readonly ChatterBotService _games;
public CleverBotCommands(DbService db, ChatterBotService games) public CleverBotCommands(DbService db)
{ {
_db = db; _db = db;
_games = games;
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -29,7 +27,7 @@ namespace NadekoBot.Modules.Games
{ {
var channel = (ITextChannel)Context.Channel; var channel = (ITextChannel)Context.Channel;
if (_games.ChatterBotGuilds.TryRemove(channel.Guild.Id, out Lazy<ChatterBotSession> throwaway)) if (_service.ChatterBotGuilds.TryRemove(channel.Guild.Id, out Lazy<ChatterBotSession> throwaway))
{ {
using (var uow = _db.UnitOfWork) using (var uow = _db.UnitOfWork)
{ {
@ -40,7 +38,7 @@ namespace NadekoBot.Modules.Games
return; return;
} }
_games.ChatterBotGuilds.TryAdd(channel.Guild.Id, new Lazy<ChatterBotSession>(() => new ChatterBotSession(Context.Guild.Id), true)); _service.ChatterBotGuilds.TryAdd(channel.Guild.Id, new Lazy<ChatterBotSession>(() => new ChatterBotSession(Context.Guild.Id), true));
using (var uow = _db.UnitOfWork) using (var uow = _db.UnitOfWork)
{ {

View File

@ -11,15 +11,13 @@ namespace NadekoBot.Modules.Games
public partial class Games public partial class Games
{ {
[Group] [Group]
public class PollCommands : NadekoSubmodule public class PollCommands : NadekoSubmodule<PollService>
{ {
private readonly DiscordSocketClient _client; private readonly DiscordSocketClient _client;
private readonly PollService _polls;
public PollCommands(DiscordSocketClient client, PollService polls) public PollCommands(DiscordSocketClient client)
{ {
_client = client; _client = client;
_polls = polls;
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -33,7 +31,7 @@ namespace NadekoBot.Modules.Games
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task PollStats() public async Task PollStats()
{ {
if (!_polls.ActivePolls.TryGetValue(Context.Guild.Id, out var poll)) if (!_service.ActivePolls.TryGetValue(Context.Guild.Id, out var poll))
return; return;
await Context.Channel.EmbedAsync(poll.GetStats(GetText("current_poll_results"))); await Context.Channel.EmbedAsync(poll.GetStats(GetText("current_poll_results")));
@ -41,7 +39,7 @@ namespace NadekoBot.Modules.Games
private async Task InternalStartPoll(string arg) private async Task InternalStartPoll(string arg)
{ {
if(await _polls.StartPoll((ITextChannel)Context.Channel, Context.Message, arg) == false) if(await _service.StartPoll((ITextChannel)Context.Channel, Context.Message, arg) == false)
await ReplyErrorLocalized("poll_already_running").ConfigureAwait(false); await ReplyErrorLocalized("poll_already_running").ConfigureAwait(false);
} }
@ -52,7 +50,7 @@ namespace NadekoBot.Modules.Games
{ {
var channel = (ITextChannel)Context.Channel; var channel = (ITextChannel)Context.Channel;
_polls.ActivePolls.TryRemove(channel.Guild.Id, out var poll); _service.ActivePolls.TryRemove(channel.Guild.Id, out var poll);
await poll.StopPoll().ConfigureAwait(false); await poll.StopPoll().ConfigureAwait(false);
} }
} }

View File

@ -9,14 +9,12 @@ using NadekoBot.Services.Games;
namespace NadekoBot.Modules.Games namespace NadekoBot.Modules.Games
{ {
public partial class Games : NadekoTopLevelModule public partial class Games : NadekoTopLevelModule<GamesService>
{ {
private readonly GamesService _games;
private readonly IImagesService _images; private readonly IImagesService _images;
public Games(GamesService games, IImagesService images) public Games(IImagesService images)
{ {
_games = games;
_images = images; _images = images;
} }
@ -40,7 +38,7 @@ namespace NadekoBot.Modules.Games
await Context.Channel.EmbedAsync(new EmbedBuilder().WithColor(NadekoBot.OkColor) await Context.Channel.EmbedAsync(new EmbedBuilder().WithColor(NadekoBot.OkColor)
.AddField(efb => efb.WithName("❓ " + GetText("question") ).WithValue(question).WithIsInline(false)) .AddField(efb => efb.WithName("❓ " + GetText("question") ).WithValue(question).WithIsInline(false))
.AddField(efb => efb.WithName("🎱 " + GetText("8ball")).WithValue(_games.EightBallResponses[new NadekoRandom().Next(0, _games.EightBallResponses.Length)]).WithIsInline(false))); .AddField(efb => efb.WithName("🎱 " + GetText("8ball")).WithValue(_service.EightBallResponses[new NadekoRandom().Next(0, _service.EightBallResponses.Length)]).WithIsInline(false)));
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -100,7 +98,7 @@ namespace NadekoBot.Modules.Games
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task RateGirl(IGuildUser usr) public async Task RateGirl(IGuildUser usr)
{ {
var gr = _games.GirlRatings.GetOrAdd(usr.Id, GetGirl); var gr = _service.GirlRatings.GetOrAdd(usr.Id, GetGirl);
var img = await gr.Url; var img = await gr.Url;
await Context.Channel.EmbedAsync(new EmbedBuilder().WithOkColor() await Context.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
.WithTitle("Girl Rating For " + usr) .WithTitle("Girl Rating For " + usr)

View File

@ -15,7 +15,7 @@ using NadekoBot.Services.Help;
namespace NadekoBot.Modules.Help namespace NadekoBot.Modules.Help
{ {
public class Help : NadekoTopLevelModule public class Help : NadekoTopLevelModule<HelpService>
{ {
public const string PatreonUrl = "https://patreon.com/nadekobot"; public const string PatreonUrl = "https://patreon.com/nadekobot";
public const string PaypalUrl = "https://paypal.me/Kwoth"; public const string PaypalUrl = "https://paypal.me/Kwoth";
@ -23,18 +23,16 @@ namespace NadekoBot.Modules.Help
private readonly BotConfig _config; private readonly BotConfig _config;
private readonly CommandService _cmds; private readonly CommandService _cmds;
private readonly GlobalPermissionService _perms; private readonly GlobalPermissionService _perms;
private readonly HelpService _h;
public string HelpString => String.Format(_config.HelpString, _creds.ClientId, Prefix); public string HelpString => String.Format(_config.HelpString, _creds.ClientId, Prefix);
public string DMHelpString => _config.DMHelpString; public string DMHelpString => _config.DMHelpString;
public Help(IBotCredentials creds, GlobalPermissionService perms, BotConfig config, CommandService cmds, HelpService h) public Help(IBotCredentials creds, GlobalPermissionService perms, BotConfig config, CommandService cmds)
{ {
_creds = creds; _creds = creds;
_config = config; _config = config;
_cmds = cmds; _cmds = cmds;
_perms = perms; _perms = perms;
_h = h;
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -107,7 +105,7 @@ namespace NadekoBot.Modules.Help
// return; // return;
//} //}
var embed = _h.GetCommandHelp(com, Context.Guild); var embed = _service.GetCommandHelp(com, Context.Guild);
await channel.EmbedAsync(embed).ConfigureAwait(false); await channel.EmbedAsync(embed).ConfigureAwait(false);
} }
@ -144,7 +142,7 @@ namespace NadekoBot.Modules.Help
lastModule = module.Name; lastModule = module.Name;
} }
helpstr.AppendLine($"{string.Join(" ", com.Aliases.Select(a => "`" + Prefix + a + "`"))} |" + helpstr.AppendLine($"{string.Join(" ", com.Aliases.Select(a => "`" + Prefix + a + "`"))} |" +
$" {string.Format(com.Summary, Prefix)} {_h.GetCommandRequirements(com, Context.Guild)} |" + $" {string.Format(com.Summary, Prefix)} {_service.GetCommandRequirements(com, Context.Guild)} |" +
$" {string.Format(com.Remarks, Prefix)}"); $" {string.Format(com.Remarks, Prefix)}");
} }
File.WriteAllText("../../docs/Commands List.md", helpstr.ToString()); File.WriteAllText("../../docs/Commands List.md", helpstr.ToString());

View File

@ -21,22 +21,20 @@ using NadekoBot.Services.Impl;
namespace NadekoBot.Modules.Music namespace NadekoBot.Modules.Music
{ {
[NoPublicBot] [NoPublicBot]
public class Music : NadekoTopLevelModule public class Music : NadekoTopLevelModule<MusicService>
{ {
private static MusicService _music;
private readonly DiscordSocketClient _client; private readonly DiscordSocketClient _client;
private readonly IBotCredentials _creds; private readonly IBotCredentials _creds;
private readonly IGoogleApiService _google; private readonly IGoogleApiService _google;
private readonly DbService _db; private readonly DbService _db;
public Music(DiscordSocketClient client, IBotCredentials creds, IGoogleApiService google, public Music(DiscordSocketClient client, IBotCredentials creds, IGoogleApiService google,
DbService db, MusicService music) DbService db)
{ {
_client = client; _client = client;
_creds = creds; _creds = creds;
_google = google; _google = google;
_db = db; _db = db;
_music = music;
//_client.UserVoiceStateUpdated += Client_UserVoiceStateUpdated; //_client.UserVoiceStateUpdated += Client_UserVoiceStateUpdated;
_client.LeftGuild += _client_LeftGuild; _client.LeftGuild += _client_LeftGuild;
@ -44,7 +42,7 @@ namespace NadekoBot.Modules.Music
private Task _client_LeftGuild(SocketGuild arg) private Task _client_LeftGuild(SocketGuild arg)
{ {
var t = _music.DestroyPlayer(arg.Id); var t = _service.DestroyPlayer(arg.Id);
return Task.CompletedTask; return Task.CompletedTask;
} }
@ -151,7 +149,7 @@ namespace NadekoBot.Modules.Music
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Play([Remainder] string query = null) public async Task Play([Remainder] string query = null)
{ {
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
if (string.IsNullOrWhiteSpace(query)) if (string.IsNullOrWhiteSpace(query))
{ {
await Next(); await Next();
@ -176,9 +174,9 @@ namespace NadekoBot.Modules.Music
public async Task Queue([Remainder] string query) public async Task Queue([Remainder] string query)
{ {
_log.Info("Getting player"); _log.Info("Getting player");
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
_log.Info("Resolving song"); _log.Info("Resolving song");
var songInfo = await _music.ResolveSong(query, Context.User.ToString()); var songInfo = await _service.ResolveSong(query, Context.User.ToString());
_log.Info("Queueing song"); _log.Info("Queueing song");
try { await InternalQueue(mp, songInfo, false); } catch (QueueFullException) { return; } try { await InternalQueue(mp, songInfo, false); } catch (QueueFullException) { return; }
_log.Info("--------------"); _log.Info("--------------");
@ -229,7 +227,7 @@ namespace NadekoBot.Modules.Music
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task ListQueue(int page = 0) public async Task ListQueue(int page = 0)
{ {
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
var (current, songs) = mp.QueueArray(); var (current, songs) = mp.QueueArray();
if (!songs.Any()) if (!songs.Any())
@ -316,7 +314,7 @@ namespace NadekoBot.Modules.Music
if (skipCount < 1) if (skipCount < 1)
return; return;
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
mp.Next(skipCount); mp.Next(skipCount);
} }
@ -325,7 +323,7 @@ namespace NadekoBot.Modules.Music
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Stop() public async Task Stop()
{ {
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
mp.Stop(); mp.Stop();
} }
@ -333,14 +331,14 @@ namespace NadekoBot.Modules.Music
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Destroy() public async Task Destroy()
{ {
await _music.DestroyPlayer(Context.Guild.Id); await _service.DestroyPlayer(Context.Guild.Id);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Pause() public async Task Pause()
{ {
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
mp.TogglePause(); mp.TogglePause();
} }
@ -348,7 +346,7 @@ namespace NadekoBot.Modules.Music
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Volume(int val) public async Task Volume(int val)
{ {
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
if (val < 0 || val > 100) if (val < 0 || val > 100)
{ {
await ReplyErrorLocalized("volume_input_invalid").ConfigureAwait(false); await ReplyErrorLocalized("volume_input_invalid").ConfigureAwait(false);
@ -385,7 +383,7 @@ namespace NadekoBot.Modules.Music
await ReplyErrorLocalized("removed_song_error").ConfigureAwait(false); await ReplyErrorLocalized("removed_song_error").ConfigureAwait(false);
return; return;
} }
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
try try
{ {
var song = mp.RemoveAt(index - 1); var song = mp.RemoveAt(index - 1);
@ -409,7 +407,7 @@ namespace NadekoBot.Modules.Music
[Priority(0)] [Priority(0)]
public async Task SongRemove(All all) public async Task SongRemove(All all)
{ {
var mp = _music.GetPlayerOrDefault(Context.Guild.Id); var mp = _service.GetPlayerOrDefault(Context.Guild.Id);
if (mp == null) if (mp == null)
return; return;
mp.Stop(true); mp.Stop(true);
@ -476,7 +474,7 @@ namespace NadekoBot.Modules.Music
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Save([Remainder] string name) public async Task Save([Remainder] string name)
{ {
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
var songs = mp.QueueArray().Songs var songs = mp.QueueArray().Songs
.Select(s => new PlaylistSong() .Select(s => new PlaylistSong()
@ -517,7 +515,7 @@ namespace NadekoBot.Modules.Music
return; return;
try try
{ {
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
MusicPlaylist mpl; MusicPlaylist mpl;
using (var uow = _db.UnitOfWork) using (var uow = _db.UnitOfWork)
{ {
@ -537,7 +535,7 @@ namespace NadekoBot.Modules.Music
{ {
await Task.Yield(); await Task.Yield();
await Task.WhenAll(Task.Delay(1000), InternalQueue(mp, await _music.ResolveSong(item.Query, Context.User.ToString(), item.ProviderType), true)).ConfigureAwait(false); await Task.WhenAll(Task.Delay(1000), InternalQueue(mp, await _service.ResolveSong(item.Query, Context.User.ToString(), item.ProviderType), true)).ConfigureAwait(false);
} }
catch (SongNotFoundException) { } catch (SongNotFoundException) { }
catch { break; } catch { break; }
@ -555,7 +553,7 @@ namespace NadekoBot.Modules.Music
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Fairplay() public async Task Fairplay()
{ {
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
var val = mp.FairPlay = !mp.FairPlay; var val = mp.FairPlay = !mp.FairPlay;
if (val) if (val)
@ -572,8 +570,8 @@ namespace NadekoBot.Modules.Music
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task SoundCloudQueue([Remainder] string query) public async Task SoundCloudQueue([Remainder] string query)
{ {
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
var song = await _music.ResolveSong(query, Context.User.ToString(), MusicType.Soundcloud); var song = await _service.ResolveSong(query, Context.User.ToString(), MusicType.Soundcloud);
await InternalQueue(mp, song, false).ConfigureAwait(false); await InternalQueue(mp, song, false).ConfigureAwait(false);
} }
@ -586,7 +584,7 @@ namespace NadekoBot.Modules.Music
if (string.IsNullOrWhiteSpace(pl)) if (string.IsNullOrWhiteSpace(pl))
return; return;
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
using (var http = new HttpClient()) using (var http = new HttpClient())
{ {
@ -617,7 +615,7 @@ namespace NadekoBot.Modules.Music
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task NowPlaying() public async Task NowPlaying()
{ {
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
var (_, currentSong) = mp.Current; var (_, currentSong) = mp.Current;
if (currentSong == null) if (currentSong == null)
return; return;
@ -636,7 +634,7 @@ namespace NadekoBot.Modules.Music
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task ShufflePlaylist() public async Task ShufflePlaylist()
{ {
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
var val = mp.ToggleShuffle(); var val = mp.ToggleShuffle();
if(val) if(val)
await ReplyConfirmLocalized("songs_shuffle_enable").ConfigureAwait(false); await ReplyConfirmLocalized("songs_shuffle_enable").ConfigureAwait(false);
@ -651,7 +649,7 @@ namespace NadekoBot.Modules.Music
if (string.IsNullOrWhiteSpace(playlist)) if (string.IsNullOrWhiteSpace(playlist))
return; return;
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
var plId = (await _google.GetPlaylistIdsByKeywordsAsync(playlist).ConfigureAwait(false)).FirstOrDefault(); var plId = (await _google.GetPlaylistIdsByKeywordsAsync(playlist).ConfigureAwait(false)).FirstOrDefault();
if (plId == null) if (plId == null)
@ -676,7 +674,7 @@ namespace NadekoBot.Modules.Music
if (mp.Exited) if (mp.Exited)
return; return;
await Task.WhenAll(Task.Delay(150), InternalQueue(mp, await _music.ResolveSong(song, Context.User.ToString(), MusicType.YouTube), true)); await Task.WhenAll(Task.Delay(150), InternalQueue(mp, await _service.ResolveSong(song, Context.User.ToString(), MusicType.YouTube), true));
} }
catch (SongNotFoundException) { } catch (SongNotFoundException) { }
catch { break; } catch { break; }
@ -690,8 +688,8 @@ namespace NadekoBot.Modules.Music
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Radio(string radioLink) public async Task Radio(string radioLink)
{ {
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
var song = await _music.ResolveSong(radioLink, Context.User.ToString(), MusicType.Radio); var song = await _service.ResolveSong(radioLink, Context.User.ToString(), MusicType.Radio);
await InternalQueue(mp, song, false).ConfigureAwait(false); await InternalQueue(mp, song, false).ConfigureAwait(false);
} }
@ -700,8 +698,8 @@ namespace NadekoBot.Modules.Music
[OwnerOnly] [OwnerOnly]
public async Task Local([Remainder] string path) public async Task Local([Remainder] string path)
{ {
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
var song = await _music.ResolveSong(path, Context.User.ToString(), MusicType.Local); var song = await _service.ResolveSong(path, Context.User.ToString(), MusicType.Local);
await InternalQueue(mp, song, false).ConfigureAwait(false); await InternalQueue(mp, song, false).ConfigureAwait(false);
} }
@ -713,7 +711,7 @@ namespace NadekoBot.Modules.Music
if (string.IsNullOrWhiteSpace(dirPath)) if (string.IsNullOrWhiteSpace(dirPath))
return; return;
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
DirectoryInfo dir; DirectoryInfo dir;
try { dir = new DirectoryInfo(dirPath); } catch { return; } try { dir = new DirectoryInfo(dirPath); } catch { return; }
@ -724,7 +722,7 @@ namespace NadekoBot.Modules.Music
try try
{ {
await Task.Yield(); await Task.Yield();
var song = await _music.ResolveSong(file.FullName, Context.User.ToString(), MusicType.Local); var song = await _service.ResolveSong(file.FullName, Context.User.ToString(), MusicType.Local);
await InternalQueue(mp, song, true).ConfigureAwait(false); await InternalQueue(mp, song, true).ConfigureAwait(false);
} }
catch (QueueFullException) catch (QueueFullException)
@ -749,7 +747,7 @@ namespace NadekoBot.Modules.Music
if (vch == null) if (vch == null)
return; return;
var mp = _music.GetPlayerOrDefault(Context.Guild.Id); var mp = _service.GetPlayerOrDefault(Context.Guild.Id);
if (mp == null) if (mp == null)
return; return;
@ -764,7 +762,7 @@ namespace NadekoBot.Modules.Music
if (string.IsNullOrWhiteSpace(fromto)) if (string.IsNullOrWhiteSpace(fromto))
return; return;
MusicPlayer mp = _music.GetPlayerOrDefault(Context.Guild.Id); MusicPlayer mp = _service.GetPlayerOrDefault(Context.Guild.Id);
if (mp == null) if (mp == null)
return; return;
@ -796,7 +794,7 @@ namespace NadekoBot.Modules.Music
{ {
if (size < 0) if (size < 0)
return; return;
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
mp.MaxQueueSize = size; mp.MaxQueueSize = size;
@ -813,7 +811,7 @@ namespace NadekoBot.Modules.Music
if (seconds < 15 && seconds != 0) if (seconds < 15 && seconds != 0)
return; return;
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
mp.MaxPlaytimeSeconds = seconds; mp.MaxPlaytimeSeconds = seconds;
if (seconds == 0) if (seconds == 0)
await ReplyConfirmLocalized("max_playtime_none").ConfigureAwait(false); await ReplyConfirmLocalized("max_playtime_none").ConfigureAwait(false);
@ -825,7 +823,7 @@ namespace NadekoBot.Modules.Music
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task ReptCurSong() public async Task ReptCurSong()
{ {
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
var (_, currentSong) = mp.Current; var (_, currentSong) = mp.Current;
if (currentSong == null) if (currentSong == null)
return; return;
@ -846,7 +844,7 @@ namespace NadekoBot.Modules.Music
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task RepeatPl() public async Task RepeatPl()
{ {
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
var currentValue = mp.ToggleRepeatPlaylist(); var currentValue = mp.ToggleRepeatPlaylist();
if (currentValue) if (currentValue)
await ReplyConfirmLocalized("rpl_enabled").ConfigureAwait(false); await ReplyConfirmLocalized("rpl_enabled").ConfigureAwait(false);
@ -858,7 +856,7 @@ namespace NadekoBot.Modules.Music
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Autoplay() public async Task Autoplay()
{ {
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
if (!mp.ToggleAutoplay()) if (!mp.ToggleAutoplay())
await ReplyConfirmLocalized("autoplay_disabled").ConfigureAwait(false); await ReplyConfirmLocalized("autoplay_disabled").ConfigureAwait(false);
@ -871,7 +869,7 @@ namespace NadekoBot.Modules.Music
[RequireUserPermission(GuildPermission.ManageMessages)] [RequireUserPermission(GuildPermission.ManageMessages)]
public async Task SetMusicChannel() public async Task SetMusicChannel()
{ {
var mp = await _music.GetOrCreatePlayer(Context); var mp = await _service.GetOrCreatePlayer(Context);
mp.OutputTextChannel = (ITextChannel)Context.Channel; mp.OutputTextChannel = (ITextChannel)Context.Channel;

View File

@ -8,7 +8,6 @@ using System.Threading.Tasks;
using NadekoBot.Services; using NadekoBot.Services;
using System.Net.Http; using System.Net.Http;
using NadekoBot.Extensions; using NadekoBot.Extensions;
using System.Xml;
using System.Threading; using System.Threading;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using NadekoBot.Services.Searches; using NadekoBot.Services.Searches;
@ -16,16 +15,10 @@ using NadekoBot.DataStructures;
namespace NadekoBot.Modules.NSFW namespace NadekoBot.Modules.NSFW
{ {
public class NSFW : NadekoTopLevelModule public class NSFW : NadekoTopLevelModule<SearchesService>
{ {
private static readonly ConcurrentDictionary<ulong, Timer> _autoHentaiTimers = new ConcurrentDictionary<ulong, Timer>(); private static readonly ConcurrentDictionary<ulong, Timer> _autoHentaiTimers = new ConcurrentDictionary<ulong, Timer>();
private static readonly ConcurrentHashSet<ulong> _hentaiBombBlacklist = new ConcurrentHashSet<ulong>(); private static readonly ConcurrentHashSet<ulong> _hentaiBombBlacklist = new ConcurrentHashSet<ulong>();
private readonly SearchesService _service;
public NSFW(SearchesService service)
{
_service = service;
}
private async Task InternalHentai(IMessageChannel channel, string tag, bool noError) private async Task InternalHentai(IMessageChannel channel, string tag, bool noError)
{ {

View File

@ -131,7 +131,21 @@ namespace NadekoBot.Modules
} }
} }
public abstract class NadekoTopLevelModule<TService> : NadekoTopLevelModule where TService : INService
{
public TService _service { get; set; }
public NadekoTopLevelModule(bool isTopLevel = true) : base(isTopLevel)
{
}
}
public abstract class NadekoSubmodule : NadekoTopLevelModule public abstract class NadekoSubmodule : NadekoTopLevelModule
{
protected NadekoSubmodule() : base(false) { }
}
public abstract class NadekoSubmodule<TService> : NadekoTopLevelModule<TService> where TService : INService
{ {
protected NadekoSubmodule() : base(false) protected NadekoSubmodule() : base(false)
{ {

View File

@ -13,15 +13,13 @@ using NadekoBot.Services.Permissions;
namespace NadekoBot.Modules.Permissions namespace NadekoBot.Modules.Permissions
{ {
public partial class Permissions : NadekoTopLevelModule public partial class Permissions : NadekoTopLevelModule<PermissionService>
{ {
private readonly DbService _db; private readonly DbService _db;
private readonly PermissionService _service;
public Permissions(PermissionService service, DbService db) public Permissions(DbService db)
{ {
_db = db; _db = db;
_service = service;
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]

View File

@ -12,16 +12,14 @@ using NadekoBot.Services.Pokemon;
namespace NadekoBot.Modules.Pokemon namespace NadekoBot.Modules.Pokemon
{ {
public class Pokemon : NadekoTopLevelModule public class Pokemon : NadekoTopLevelModule<PokemonService>
{ {
private readonly PokemonService _service;
private readonly DbService _db; private readonly DbService _db;
private readonly BotConfig _bc; private readonly BotConfig _bc;
private readonly CurrencyService _cs; private readonly CurrencyService _cs;
public Pokemon(PokemonService pokemonService, DbService db, BotConfig bc, CurrencyService cs) public Pokemon(DbService db, BotConfig bc, CurrencyService cs)
{ {
_service = pokemonService;
_db = db; _db = db;
_bc = bc; _bc = bc;
_cs = cs; _cs = cs;

View File

@ -15,15 +15,8 @@ namespace NadekoBot.Modules.Searches
public partial class Searches public partial class Searches
{ {
[Group] [Group]
public class AnimeSearchCommands : NadekoSubmodule public class AnimeSearchCommands : NadekoSubmodule<AnimeSearchService>
{ {
private readonly AnimeSearchService _service;
public AnimeSearchCommands(AnimeSearchService service)
{
_service = service;
}
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[Priority(0)] [Priority(0)]
public async Task Mal([Remainder] string name) public async Task Mal([Remainder] string name)

View File

@ -14,14 +14,8 @@ namespace NadekoBot.Modules.Searches
public partial class Searches public partial class Searches
{ {
[Group] [Group]
public class JokeCommands : NadekoSubmodule public class JokeCommands : NadekoSubmodule<SearchesService>
{ {
private readonly SearchesService _searches;
public JokeCommands(SearchesService searches)
{
_searches = searches;
}
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
public async Task Yomama() public async Task Yomama()
@ -65,24 +59,24 @@ namespace NadekoBot.Modules.Searches
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
public async Task WowJoke() public async Task WowJoke()
{ {
if (!_searches.WowJokes.Any()) if (!_service.WowJokes.Any())
{ {
await ReplyErrorLocalized("jokes_not_loaded").ConfigureAwait(false); await ReplyErrorLocalized("jokes_not_loaded").ConfigureAwait(false);
return; return;
} }
var joke = _searches.WowJokes[new NadekoRandom().Next(0, _searches.WowJokes.Count)]; var joke = _service.WowJokes[new NadekoRandom().Next(0, _service.WowJokes.Count)];
await Context.Channel.SendConfirmAsync(joke.Question, joke.Answer).ConfigureAwait(false); await Context.Channel.SendConfirmAsync(joke.Question, joke.Answer).ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
public async Task MagicItem() public async Task MagicItem()
{ {
if (!_searches.WowJokes.Any()) if (!_service.WowJokes.Any())
{ {
await ReplyErrorLocalized("magicitems_not_loaded").ConfigureAwait(false); await ReplyErrorLocalized("magicitems_not_loaded").ConfigureAwait(false);
return; return;
} }
var item = _searches.MagicItems[new NadekoRandom().Next(0, _searches.MagicItems.Count)]; var item = _service.MagicItems[new NadekoRandom().Next(0, _service.MagicItems.Count)];
await Context.Channel.SendConfirmAsync("✨" + item.Name, item.Description).ConfigureAwait(false); await Context.Channel.SendConfirmAsync("✨" + item.Name, item.Description).ConfigureAwait(false);
} }

View File

@ -12,17 +12,10 @@ namespace NadekoBot.Modules.Searches
public partial class Searches public partial class Searches
{ {
[Group] [Group]
public class PokemonSearchCommands : NadekoSubmodule public class PokemonSearchCommands : NadekoSubmodule<SearchesService>
{ {
private readonly SearchesService _searches; public Dictionary<string, SearchPokemon> Pokemons => _service.Pokemons;
public Dictionary<string, SearchPokemonAbility> PokemonAbilities => _service.PokemonAbilities;
public Dictionary<string, SearchPokemon> Pokemons => _searches.Pokemons;
public Dictionary<string, SearchPokemonAbility> PokemonAbilities => _searches.PokemonAbilities;
public PokemonSearchCommands(SearchesService searches)
{
_searches = searches;
}
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
public async Task Pokemon([Remainder] string pokemon = null) public async Task Pokemon([Remainder] string pokemon = null)

View File

@ -15,15 +15,13 @@ namespace NadekoBot.Modules.Searches
public partial class Searches public partial class Searches
{ {
[Group] [Group]
public class StreamNotificationCommands : NadekoSubmodule public class StreamNotificationCommands : NadekoSubmodule<StreamNotificationService>
{ {
private readonly DbService _db; private readonly DbService _db;
private readonly StreamNotificationService _service;
public StreamNotificationCommands(DbService db, StreamNotificationService service) public StreamNotificationCommands(DbService db)
{ {
_db = db; _db = db;
_service = service;
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]

View File

@ -25,17 +25,16 @@ using NadekoBot.DataStructures;
namespace NadekoBot.Modules.Searches namespace NadekoBot.Modules.Searches
{ {
public partial class Searches : NadekoTopLevelModule public partial class Searches : NadekoTopLevelModule<SearchesService>
{ {
private readonly IBotCredentials _creds; private readonly IBotCredentials _creds;
private readonly IGoogleApiService _google; private readonly IGoogleApiService _google;
private readonly SearchesService _searches; private readonly SearchesService _searches;
public Searches(IBotCredentials creds, IGoogleApiService google, SearchesService searches) public Searches(IBotCredentials creds, IGoogleApiService google)
{ {
_creds = creds; _creds = creds;
_google = google; _google = google;
_searches = searches;
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]

View File

@ -17,15 +17,13 @@ namespace NadekoBot.Modules.Utility
public partial class Utility public partial class Utility
{ {
[Group] [Group]
public class CommandMapCommands : NadekoSubmodule public class CommandMapCommands : NadekoSubmodule<CommandMapService>
{ {
private readonly CommandMapService _service;
private readonly DbService _db; private readonly DbService _db;
private readonly DiscordSocketClient _client; private readonly DiscordSocketClient _client;
public CommandMapCommands(CommandMapService service, DbService db, DiscordSocketClient client) public CommandMapCommands(DbService db, DiscordSocketClient client)
{ {
_service = service;
_db = db; _db = db;
_client = client; _client = client;
} }

View File

@ -13,21 +13,19 @@ namespace NadekoBot.Modules.Utility
public partial class Utility public partial class Utility
{ {
[Group] [Group]
public class PatreonCommands : NadekoSubmodule public class PatreonCommands : NadekoSubmodule<PatreonRewardsService>
{ {
private readonly PatreonRewardsService _patreon;
private readonly IBotCredentials _creds; private readonly IBotCredentials _creds;
private readonly BotConfig _config; private readonly BotConfig _config;
private readonly DbService _db; private readonly DbService _db;
private readonly CurrencyService _currency; private readonly CurrencyService _currency;
public PatreonCommands(PatreonRewardsService p, IBotCredentials creds, BotConfig config, DbService db, CurrencyService currency) public PatreonCommands(IBotCredentials creds, BotConfig config, DbService db, CurrencyService currency)
{ {
_creds = creds; _creds = creds;
_config = config; _config = config;
_db = db; _db = db;
_currency = currency; _currency = currency;
_patreon = p;
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -37,7 +35,7 @@ namespace NadekoBot.Modules.Utility
{ {
if (string.IsNullOrWhiteSpace(_creds.PatreonAccessToken)) if (string.IsNullOrWhiteSpace(_creds.PatreonAccessToken))
return; return;
await _patreon.RefreshPledges(true).ConfigureAwait(false); await _service.RefreshPledges(true).ConfigureAwait(false);
await Context.Channel.SendConfirmAsync("👌").ConfigureAwait(false); await Context.Channel.SendConfirmAsync("👌").ConfigureAwait(false);
} }
@ -57,7 +55,7 @@ namespace NadekoBot.Modules.Utility
int amount = 0; int amount = 0;
try try
{ {
amount = await _patreon.ClaimReward(Context.User.Id).ConfigureAwait(false); amount = await _service.ClaimReward(Context.User.Id).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -69,7 +67,7 @@ namespace NadekoBot.Modules.Utility
await ReplyConfirmLocalized("clpa_success", amount + _config.CurrencySign).ConfigureAwait(false); await ReplyConfirmLocalized("clpa_success", amount + _config.CurrencySign).ConfigureAwait(false);
return; return;
} }
var rem = (_patreon.Interval - (DateTime.UtcNow - _patreon.LastUpdate)); var rem = (_service.Interval - (DateTime.UtcNow - _service.LastUpdate));
var helpcmd = Format.Code(Prefix + "donate"); var helpcmd = Format.Code(Prefix + "donate");
await Context.Channel.EmbedAsync(new EmbedBuilder().WithOkColor() await Context.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
.WithDescription(GetText("clpa_fail")) .WithDescription(GetText("clpa_fail"))

View File

@ -16,15 +16,13 @@ namespace NadekoBot.Modules.Utility
public partial class Utility public partial class Utility
{ {
[Group] [Group]
public class RemindCommands : NadekoSubmodule public class RemindCommands : NadekoSubmodule<RemindService>
{ {
private readonly RemindService _service;
private readonly DbService _db; private readonly DbService _db;
private readonly GuildTimezoneService _tz; private readonly GuildTimezoneService _tz;
public RemindCommands(RemindService service, DbService db, GuildTimezoneService tz) public RemindCommands(DbService db, GuildTimezoneService tz)
{ {
_service = service;
_db = db; _db = db;
_tz = tz; _tz = tz;
} }

View File

@ -19,15 +19,13 @@ namespace NadekoBot.Modules.Utility
public partial class Utility public partial class Utility
{ {
[Group] [Group]
public class RepeatCommands : NadekoSubmodule public class RepeatCommands : NadekoSubmodule<MessageRepeaterService>
{ {
private readonly MessageRepeaterService _service;
private readonly DiscordSocketClient _client; private readonly DiscordSocketClient _client;
private readonly DbService _db; private readonly DbService _db;
public RepeatCommands(MessageRepeaterService service, DiscordSocketClient client, DbService db) public RepeatCommands(DiscordSocketClient client, DbService db)
{ {
_service = service;
_client = client; _client = client;
_db = db; _db = db;
} }

View File

@ -8,22 +8,15 @@ namespace NadekoBot.Modules.Utility
{ {
public partial class Utility public partial class Utility
{ {
public class StreamRoleCommands : NadekoSubmodule public class StreamRoleCommands : NadekoSubmodule<StreamRoleService>
{ {
private readonly StreamRoleService service;
public StreamRoleCommands(StreamRoleService service)
{
this.service = service;
}
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireBotPermission(GuildPermission.ManageRoles)] [RequireBotPermission(GuildPermission.ManageRoles)]
[RequireUserPermission(GuildPermission.ManageRoles)] [RequireUserPermission(GuildPermission.ManageRoles)]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task StreamRole(IRole fromRole, IRole addRole) public async Task StreamRole(IRole fromRole, IRole addRole)
{ {
this.service.SetStreamRole(fromRole, addRole); this._service.SetStreamRole(fromRole, addRole);
await ReplyConfirmLocalized("stream_role_enabled", Format.Bold(fromRole.ToString()), Format.Bold(addRole.ToString())).ConfigureAwait(false); await ReplyConfirmLocalized("stream_role_enabled", Format.Bold(fromRole.ToString()), Format.Bold(addRole.ToString())).ConfigureAwait(false);
} }
@ -34,7 +27,7 @@ namespace NadekoBot.Modules.Utility
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task StreamRole() public async Task StreamRole()
{ {
this.service.StopStreamRole(Context.Guild.Id); this._service.StopStreamRole(Context.Guild.Id);
await ReplyConfirmLocalized("stream_role_disabled").ConfigureAwait(false); await ReplyConfirmLocalized("stream_role_disabled").ConfigureAwait(false);
} }
} }

View File

@ -11,15 +11,8 @@ namespace NadekoBot.Modules.Utility
public partial class Utility public partial class Utility
{ {
[Group] [Group]
public class UnitConverterCommands : NadekoSubmodule public class UnitConverterCommands : NadekoSubmodule<ConverterService>
{ {
private readonly ConverterService _service;
public UnitConverterCommands(ConverterService service)
{
_service = service;
}
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
public async Task ConvertList() public async Task ConvertList()
{ {

View File

@ -8,21 +8,14 @@ namespace NadekoBot.Modules.Utility
public partial class Utility public partial class Utility
{ {
[Group] [Group]
public class VerboseCommandErrors : NadekoSubmodule public class VerboseCommandErrors : NadekoSubmodule<VerboseErrorsService>
{ {
private readonly VerboseErrorsService _ves;
public VerboseCommandErrors(VerboseErrorsService ves)
{
_ves = ves;
}
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[RequireUserPermission(Discord.GuildPermission.ManageMessages)] [RequireUserPermission(Discord.GuildPermission.ManageMessages)]
public async Task VerboseError() public async Task VerboseError()
{ {
var state = _ves.ToggleVerboseErrors(Context.Guild.Id); var state = _service.ToggleVerboseErrors(Context.Guild.Id);
if (state) if (state)
await ReplyConfirmLocalized("verbose_errors_enabled").ConfigureAwait(false); await ReplyConfirmLocalized("verbose_errors_enabled").ConfigureAwait(false);

View File

@ -31,8 +31,11 @@
<ItemGroup> <ItemGroup>
<Compile Remove="data\**\*;credentials.json" /> <Compile Remove="data\**\*;credentials.json" />
<Compile Remove="Modules\Music\Classes\**" />
<Compile Remove="Modules\Utility\Models\**" /> <Compile Remove="Modules\Utility\Models\**" />
<EmbeddedResource Remove="Modules\Music\Classes\**" />
<EmbeddedResource Remove="Modules\Utility\Models\**" /> <EmbeddedResource Remove="Modules\Utility\Models\**" />
<None Remove="Modules\Music\Classes\**" />
<None Remove="Modules\Utility\Models\**" /> <None Remove="Modules\Utility\Models\**" />
<None Update="credentials_example.json"> <None Update="credentials_example.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
@ -88,8 +91,4 @@
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" /> <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" /> <DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Modules\Music\Classes\" />
</ItemGroup>
</Project> </Project>

View File

@ -4,12 +4,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Reflection; using System.Reflection;
using Discord.Commands;
using Discord.WebSocket;
using NadekoBot.Services.Database.Models;
using NadekoBot.Services.Impl;
using System.Linq; using System.Linq;
using NadekoBot.Extensions;
using System.Diagnostics; using System.Diagnostics;
using NLog; using NLog;