Fixes to custom reactions, invite link in help now works

This commit is contained in:
Kwoth 2016-10-09 04:26:14 +02:00
parent c426a1709b
commit b69f416295
3 changed files with 17 additions and 9 deletions

View File

@ -73,7 +73,7 @@ namespace NadekoBot.Modules.CustomReactions
if ((channel == null && !NadekoBot.Credentials.IsOwner(imsg.Author)) || (channel != null && !((IGuildUser)imsg.Author).GuildPermissions.Administrator)) if ((channel == null && !NadekoBot.Credentials.IsOwner(imsg.Author)) || (channel != null && !((IGuildUser)imsg.Author).GuildPermissions.Administrator))
{ {
try { await channel.SendMessageAsync("Insufficient permissions. Requires Bot ownership for global custom reactions, and Administrator for guild custom reactions."); } catch { } try { await imsg.Channel.SendMessageAsync("Insufficient permissions. Requires Bot ownership for global custom reactions, and Administrator for guild custom reactions."); } catch { }
return; return;
} }
@ -102,7 +102,7 @@ namespace NadekoBot.Modules.CustomReactions
reactions.Add(cr); reactions.Add(cr);
} }
await channel.SendMessageAsync($"`Added new custom reaction:`\n\t`Trigger:` {key}\n\t`Response:` {message}").ConfigureAwait(false); await imsg.Channel.SendMessageAsync($"`Added new custom reaction:`\n\t`Trigger:` {key}\n\t`Response:` {message}").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -132,7 +132,7 @@ namespace NadekoBot.Modules.CustomReactions
if ((channel == null && !NadekoBot.Credentials.IsOwner(imsg.Author)) || (channel != null && !((IGuildUser)imsg.Author).GuildPermissions.Administrator)) if ((channel == null && !NadekoBot.Credentials.IsOwner(imsg.Author)) || (channel != null && !((IGuildUser)imsg.Author).GuildPermissions.Administrator))
{ {
try { await channel.SendMessageAsync("Insufficient permissions. Requires Bot ownership for global custom reactions, and Administrator for guild custom reactions."); } catch { } try { await imsg.Channel.SendMessageAsync("Insufficient permissions. Requires Bot ownership for global custom reactions, and Administrator for guild custom reactions."); } catch { }
return; return;
} }
@ -147,11 +147,13 @@ namespace NadekoBot.Modules.CustomReactions
if (toDelete.GuildId == null && channel == null) if (toDelete.GuildId == null && channel == null)
{ {
uow.CustomReactions.Remove(toDelete); uow.CustomReactions.Remove(toDelete);
success = true; success = true;
} }
else if (toDelete.GuildId != null && channel.Guild.Id == toDelete.GuildId) else if (toDelete.GuildId != null && channel?.Guild.Id == toDelete.GuildId)
{ {
uow.CustomReactions.Remove(toDelete); uow.CustomReactions.Remove(toDelete);
GuildReactions.GetOrAdd(channel.Guild.Id, new HashSet<CustomReaction>()).RemoveWhere(cr => cr.Id == toDelete.Id);
success = true; success = true;
} }
if(success) if(success)
@ -159,9 +161,9 @@ namespace NadekoBot.Modules.CustomReactions
} }
if (success) if (success)
await channel.SendMessageAsync("**Successfully deleted custom reaction** " + toDelete.ToString()).ConfigureAwait(false); await imsg.Channel.SendMessageAsync("**Successfully deleted custom reaction** " + toDelete.ToString()).ConfigureAwait(false);
else else
await channel.SendMessageAsync("Failed to find that custom reaction.").ConfigureAwait(false); await imsg.Channel.SendMessageAsync("`Failed to find that custom reaction.`").ConfigureAwait(false);
} }
} }
} }

View File

@ -6,7 +6,9 @@ namespace NadekoBot.Services
{ {
public interface IBotCredentials public interface IBotCredentials
{ {
string ClientId { get; } ulong ClientId { get; }
ulong BotId { get; }
string Token { get; } string Token { get; }
string GoogleApiKey { get; } string GoogleApiKey { get; }
ulong[] OwnerIds { get; } ulong[] OwnerIds { get; }

View File

@ -12,7 +12,8 @@ namespace NadekoBot.Services.Impl
{ {
private Logger _log; private Logger _log;
public string ClientId { get; } public ulong ClientId { get; }
public ulong BotId { get; }
public string GoogleApiKey { get; } public string GoogleApiKey { get; }
@ -42,7 +43,8 @@ namespace NadekoBot.Services.Impl
MashapeKey = cm.MashapeKey; MashapeKey = cm.MashapeKey;
OsuApiKey = cm.OsuApiKey; OsuApiKey = cm.OsuApiKey;
TotalShards = cm.TotalShards < 1 ? 1 : cm.TotalShards; TotalShards = cm.TotalShards < 1 ? 1 : cm.TotalShards;
SoundCloudClientId = cm.SoundCloudClientId; BotId = cm.BotId ?? cm.ClientId;
ClientId = cm.ClientId;
if (cm.Db == null) if (cm.Db == null)
Db = new DB("sqlite", ""); Db = new DB("sqlite", "");
else else
@ -58,6 +60,8 @@ namespace NadekoBot.Services.Impl
private class CredentialsModel private class CredentialsModel
{ {
public ulong ClientId { get; set; }
public ulong? BotId { get; set; }
public string Token { get; set; } public string Token { get; set; }
public ulong[] OwnerIds { get; set; } public ulong[] OwnerIds { get; set; }
public string LoLApiKey { get; set; } public string LoLApiKey { get; set; }