small chance crashfix when 502 happens on sendfile

This commit is contained in:
Master Kwoth 2016-07-07 04:44:52 +02:00
parent e47b47b498
commit 9d88627e19

View File

@ -31,19 +31,23 @@ namespace NadekoBot.Modules.Games.Commands
private async void PotentialFlowerGeneration(object sender, Discord.MessageEventArgs e) private async void PotentialFlowerGeneration(object sender, Discord.MessageEventArgs e)
{ {
if (e.Server == null || e.Channel.IsPrivate) try
return;
var config = Classes.SpecificConfigurations.Default.Of(e.Server.Id);
if (config.GenerateCurrencyChannels.Contains(e.Channel.Id))
{ {
var rnd = Math.Abs(GetRandomNumber()); if (e.Server == null || e.Channel.IsPrivate)
if ((rnd % 50) == 0) return;
var config = Classes.SpecificConfigurations.Default.Of(e.Server.Id);
if (config.GenerateCurrencyChannels.Contains(e.Channel.Id))
{ {
var msg = await e.Channel.SendFile(GetRandomCurrencyImagePath()); var rnd = Math.Abs(GetRandomNumber());
await e.Channel.SendMessage($"❗ A random {NadekoBot.Config.CurrencyName} appeared! Pick it up by typing `>pick`"); if ((rnd % 50) == 0)
plantedFlowerChannels.AddOrUpdate(e.Channel.Id, msg, (u, m) => { m.Delete().GetAwaiter().GetResult(); return msg; }); {
var msg = await e.Channel.SendFile(GetRandomCurrencyImagePath());
await e.Channel.SendMessage($"❗ A random {NadekoBot.Config.CurrencyName} appeared! Pick it up by typing `>pick`");
plantedFlowerChannels.AddOrUpdate(e.Channel.Id, msg, (u, m) => { m.Delete().GetAwaiter().GetResult(); return msg; });
}
} }
} }
catch { }
} }
//channelid/messageid pair //channelid/messageid pair
ConcurrentDictionary<ulong, Message> plantedFlowerChannels = new ConcurrentDictionary<ulong, Message>(); ConcurrentDictionary<ulong, Message> plantedFlowerChannels = new ConcurrentDictionary<ulong, Message>();