diff --git a/NadekoBot/Modules/Games/Commands/PlantPick.cs b/NadekoBot/Modules/Games/Commands/PlantPick.cs index badbfae8..6f01c170 100644 --- a/NadekoBot/Modules/Games/Commands/PlantPick.cs +++ b/NadekoBot/Modules/Games/Commands/PlantPick.cs @@ -92,7 +92,7 @@ namespace NadekoBot.Modules.Games.Commands e.Channel.SendMessage($"There is already a {NadekoBot.Config.CurrencyName} in this channel."); return; } - var removed = FlowersHandler.RemoveFlowers(e.User, "Planted a flower.", 1); + var removed = FlowersHandler.RemoveFlowers(e.User, "Planted a flower.", 1).GetAwaiter().GetResult(); if (!removed) { e.Channel.SendMessage($"You don't have any {NadekoBot.Config.CurrencyName}s.").Wait(); diff --git a/NadekoBot/NadekoBot.cs b/NadekoBot/NadekoBot.cs index 86d22219..9a4b804c 100644 --- a/NadekoBot/NadekoBot.cs +++ b/NadekoBot/NadekoBot.cs @@ -42,7 +42,7 @@ namespace NadekoBot public static string BotMention { get; set; } = ""; public static bool Ready { get; set; } = false; - private static Channel OwnerPrivateChannel { get; set; } + private static List OwnerPrivateChannels { get; set; } private static void Main() { @@ -205,15 +205,19 @@ namespace NadekoBot Console.WriteLine(await NadekoStats.Instance.GetStats().ConfigureAwait(false)); Console.WriteLine("-----------------"); - try - { - OwnerPrivateChannel = await Client.CreatePrivateChannel(Creds.OwnerIds[0]).ConfigureAwait(false); - } - catch - { - Console.WriteLine("Failed creating private channel with the first owner listed in credentials.json"); - } + OwnerPrivateChannels = new List(Creds.OwnerIds.Length); + foreach (var id in Creds.OwnerIds) + { + try + { + OwnerPrivateChannels.Add(await Client.CreatePrivateChannel(id).ConfigureAwait(false)); + } + catch + { + Console.WriteLine($"Failed creating private channel with the owner {id} listed in credentials.json"); + } + } Client.ClientAPI.SendingRequest += (s, e) => { var request = e.Request as Discord.API.Client.Rest.SendMessageRequest; @@ -234,8 +238,18 @@ namespace NadekoBot public static async Task SendMessageToOwner(string message) { - if (Config.ForwardMessages && OwnerPrivateChannel != null) - await OwnerPrivateChannel.SendMessage(message).ConfigureAwait(false); + if (Config.ForwardMessages && OwnerPrivateChannels.Any()) + if (Config.ForwardToAllOwners) + OwnerPrivateChannels.ForEach(async c => + { + try { await c.SendMessage(message).ConfigureAwait(false); } catch { } + }); + else + { + var c = OwnerPrivateChannels.FirstOrDefault(); + if (c != null) + await c.SendMessage(message).ConfigureAwait(false); + } } private static bool repliedRecently = false; @@ -248,8 +262,8 @@ namespace NadekoBot if (ConfigHandler.IsBlackListed(e)) return; - if (Config.ForwardMessages && !NadekoBot.Creds.OwnerIds.Contains(e.User.Id) && OwnerPrivateChannel != null) - await OwnerPrivateChannel.SendMessage(e.User + ": ```\n" + e.Message.Text + "\n```").ConfigureAwait(false); + if (Config.ForwardMessages && !NadekoBot.Creds.OwnerIds.Contains(e.User.Id) && OwnerPrivateChannels.Any()) + await SendMessageToOwner(e.User + ": ```\n" + e.Message.Text + "\n```").ConfigureAwait(false); if (repliedRecently) return; diff --git a/NadekoBot/_Models/JSONModels/Configuration.cs b/NadekoBot/_Models/JSONModels/Configuration.cs index bafdb84e..93f9ebb9 100644 --- a/NadekoBot/_Models/JSONModels/Configuration.cs +++ b/NadekoBot/_Models/JSONModels/Configuration.cs @@ -84,6 +84,7 @@ namespace NadekoBot.Classes.JSONModels public bool DontJoinServers { get; set; } = false; public bool ForwardMessages { get; set; } = true; + public bool ForwardToAllOwners { get; set; } = false; public bool IsRotatingStatus { get; set; } = false; public int BufferSize { get; set; } = 4.MiB();