Playing status fixed? Added a lot of catches to try to fix the error
This commit is contained in:
parent
c24281d17b
commit
0c7d077df1
@ -749,7 +749,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
game = game ?? "";
|
||||
|
||||
await NadekoBot.Client.GetCurrentUser().ModifyStatusAsync(u => u.Game = new Game(game)).ConfigureAwait(false);
|
||||
await NadekoBot.Client.SetGame(game).ConfigureAwait(false);
|
||||
|
||||
await channel.SendMessageAsync("`New game set.`").ConfigureAwait(false);
|
||||
}
|
||||
@ -763,7 +763,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
name = name ?? "";
|
||||
|
||||
await NadekoBot.Client.GetCurrentUser().ModifyStatusAsync(u => u.Game = new Game(name, url, StreamType.Twitch)).ConfigureAwait(false);
|
||||
await NadekoBot.Client.SetStream(name, url).ConfigureAwait(false);
|
||||
|
||||
await channel.SendMessageAsync("`New stream set.`").ConfigureAwait(false);
|
||||
}
|
||||
|
@ -100,6 +100,8 @@ namespace NadekoBot.Modules.Administration
|
||||
return Task.CompletedTask;
|
||||
|
||||
var t = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
AntiSpamSetting spamSettings;
|
||||
if (!antiSpamGuilds.TryGetValue(channel.Guild.Id, out spamSettings))
|
||||
@ -114,10 +116,10 @@ namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
var log = await PunishUser((IGuildUser)msg.Author, spamSettings.Action, spamSettings.MuteRole, ProtectionType.Spamming)
|
||||
.ConfigureAwait(false);
|
||||
try { await channel.Guild.SendMessageToOwnerAsync(log).ConfigureAwait(false); } catch { }
|
||||
await channel.Guild.SendMessageToOwnerAsync(log).ConfigureAwait(false); }
|
||||
}
|
||||
}
|
||||
|
||||
catch { }
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
@ -26,6 +26,8 @@ namespace NadekoBot.Modules.Administration
|
||||
_client.UserJoined += (user) =>
|
||||
{
|
||||
var t = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
GuildConfig conf;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
@ -39,7 +41,9 @@ namespace NadekoBot.Modules.Administration
|
||||
var role = user.Guild.Roles.FirstOrDefault(r => r.Id == conf.AutoAssignRoleId);
|
||||
|
||||
if (role != null)
|
||||
try { await user.AddRolesAsync(role); } catch (Exception ex) { _log.Warn(ex); }
|
||||
await user.AddRolesAsync(role);
|
||||
}
|
||||
catch (Exception ex) { _log.Warn(ex); }
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
@ -89,6 +89,8 @@ namespace NadekoBot.Modules.Administration
|
||||
return Task.CompletedTask;
|
||||
|
||||
var task = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
string str = $"🕔`{prettyCurrentTime}`";
|
||||
if (before.Username != after.Username)
|
||||
@ -113,6 +115,8 @@ namespace NadekoBot.Modules.Administration
|
||||
else
|
||||
return;
|
||||
try { await logChannel.SendMessageAsync(str).ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); }
|
||||
}
|
||||
catch { }
|
||||
});
|
||||
|
||||
return Task.CompletedTask;
|
||||
@ -137,6 +141,8 @@ namespace NadekoBot.Modules.Administration
|
||||
return Task.CompletedTask;
|
||||
|
||||
var task = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (before.Name != after.Name)
|
||||
await logChannel.SendMessageAsync($@"`{prettyCurrentTime}` **Channel Name Changed** `#{after.Name}` ({after.Id})
|
||||
@ -146,6 +152,8 @@ namespace NadekoBot.Modules.Administration
|
||||
await logChannel.SendMessageAsync($@"`{prettyCurrentTime}` **Channel Topic Changed** `#{after.Name}` ({after.Id})
|
||||
`Old:` {((ITextChannel)before).Topic}
|
||||
`New:` {((ITextChannel)after).Topic}").ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
});
|
||||
|
||||
return Task.CompletedTask;
|
||||
@ -364,12 +372,16 @@ namespace NadekoBot.Modules.Administration
|
||||
return Task.CompletedTask;
|
||||
|
||||
var task = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var str = $@"🕔`{prettyCurrentTime}` **Message** 🚮 `#{channel.Name}`
|
||||
👤`{msg.Author.Username}`: {msg.Resolve(userHandling:UserMentionHandling.NameAndDiscriminator)}";
|
||||
👤`{msg.Author.Username}`: {msg.Resolve(userHandling: UserMentionHandling.NameAndDiscriminator)}";
|
||||
if (msg.Attachments.Any())
|
||||
str += $"{Environment.NewLine}`Attachements`: {string.Join(", ", msg.Attachments.Select(a => a.ProxyUrl))}";
|
||||
try { await logChannel.SendMessageAsync(str).ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); }
|
||||
await logChannel.SendMessageAsync(str).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex) { _log.Warn(ex); }
|
||||
});
|
||||
|
||||
return Task.CompletedTask;
|
||||
@ -377,6 +389,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
private Task _client_MessageUpdated(Optional<IMessage> optmsg, IMessage imsg2)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
var after = imsg2 as IUserMessage;
|
||||
if (after == null || after.IsAuthor())
|
||||
return Task.CompletedTask;
|
||||
|
@ -58,9 +58,7 @@ namespace NadekoBot.Modules.Administration
|
||||
if (string.IsNullOrWhiteSpace(status))
|
||||
continue;
|
||||
PlayingPlaceholders.ForEach(e => status = status.Replace(e.Key, e.Value()));
|
||||
await (await NadekoBot.Client.GetCurrentUserAsync())
|
||||
.ModifyStatusAsync(mpp => mpp.Game = new Game(status))
|
||||
.ConfigureAwait(false);
|
||||
await NadekoBot.Client.SetGame(status);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -39,9 +39,10 @@ namespace NadekoBot.Modules.Administration
|
||||
return Task.CompletedTask;
|
||||
var task = Task.Run(async () =>
|
||||
{
|
||||
var botUserPerms = guild.GetCurrentUser().GuildPermissions;
|
||||
try
|
||||
{
|
||||
var botUserPerms = guild.GetCurrentUser().GuildPermissions;
|
||||
|
||||
if (before.VoiceChannel == after.VoiceChannel) return;
|
||||
|
||||
if (!voicePlusTextCache.Contains(guild.Id))
|
||||
|
@ -186,6 +186,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
await Task.Delay(2500);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
finally
|
||||
{
|
||||
NadekoBot.Client.MessageReceived -= Client_MessageReceived;
|
||||
|
@ -34,11 +34,15 @@ namespace NadekoBot.Modules.Gambling
|
||||
var num1 = gen / 10;
|
||||
var num2 = gen % 10;
|
||||
var imageStream = await Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var ms = new MemoryStream();
|
||||
new[] { GetDice(num1), GetDice(num2) }.Merge().SaveAsPng(ms);
|
||||
ms.Position = 0;
|
||||
return ms;
|
||||
}
|
||||
catch { return new MemoryStream(); }
|
||||
});
|
||||
|
||||
await channel.SendFileAsync(imageStream, "dice.png", $"{umsg.Author.Mention} rolled " + Format.Code(gen.ToString())).ConfigureAwait(false);
|
||||
|
@ -42,7 +42,7 @@ namespace NadekoBot.Modules.Games.Trivia
|
||||
this.guild = guild;
|
||||
this.channel = channel;
|
||||
WinRequirement = winReq;
|
||||
Task.Run(StartGame);
|
||||
Task.Run(async () => { try { await StartGame().ConfigureAwait(false); } catch { } });
|
||||
}
|
||||
|
||||
private async Task StartGame()
|
||||
|
@ -306,7 +306,7 @@ namespace NadekoBot.Modules.Music.Classes
|
||||
var link = (await NadekoBot.Google.GetVideosByKeywordsAsync(query).ConfigureAwait(false)).FirstOrDefault();
|
||||
if (string.IsNullOrWhiteSpace(link))
|
||||
throw new OperationCanceledException("Not a valid youtube query.");
|
||||
var allVideos = await Task.Run(async () => await YouTube.Default.GetAllVideosAsync(link).ConfigureAwait(false)).ConfigureAwait(false);
|
||||
var allVideos = await Task.Run(async () => { try { return await YouTube.Default.GetAllVideosAsync(link).ConfigureAwait(false); } catch { return Enumerable.Empty<YouTubeVideo>(); } }).ConfigureAwait(false);
|
||||
var videos = allVideos.Where(v => v.AdaptiveKind == AdaptiveKind.Audio);
|
||||
var video = videos
|
||||
.Where(v => v.AudioBitrate < 192)
|
||||
|
@ -799,9 +799,10 @@ namespace NadekoBot.Modules.Music
|
||||
var queuedMessage = await textCh.SendMessageAsync($"🎵`Queued`{resolvedSong.PrettyName} **at** `#{musicPlayer.Playlist.Count + 1}`").ConfigureAwait(false);
|
||||
var t = Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(10000).ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
await Task.Delay(10000).ConfigureAwait(false);
|
||||
|
||||
await queuedMessage.DeleteAsync().ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
|
@ -111,9 +111,13 @@ namespace NadekoBot.Modules.Permissions
|
||||
Command = cmd.Text.ToLowerInvariant(),
|
||||
});
|
||||
var t = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await Task.Delay(cdRule.Seconds * 1000);
|
||||
activeCdsForGuild.RemoveWhere(ac => ac.Command == cmd.Text.ToLowerInvariant() && ac.UserId == user.Id);
|
||||
}
|
||||
catch { }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ namespace NadekoBot.Modules.Searches
|
||||
var smallObj = JArray.Parse(res)[0];
|
||||
var aniData = await http.GetStringAsync("http://anilist.co/api/anime/" + smallObj["id"] + $"?access_token={anilistToken}").ConfigureAwait(false);
|
||||
|
||||
return await Task.Run(() => JsonConvert.DeserializeObject<AnimeResult>(aniData)).ConfigureAwait(false);
|
||||
return await Task.Run(() => { try { return JsonConvert.DeserializeObject<AnimeResult>(aniData); } catch { return null; } }).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
@ -118,7 +118,7 @@ namespace NadekoBot.Modules.Searches
|
||||
var smallObj = JArray.Parse(res)[0];
|
||||
var aniData = await http.GetStringAsync("http://anilist.co/api/manga/" + smallObj["id"] + $"?access_token={anilistToken}").ConfigureAwait(false);
|
||||
|
||||
return await Task.Run(() => JsonConvert.DeserializeObject<MangaResult>(aniData)).ConfigureAwait(false);
|
||||
return await Task.Run(() => { try { return JsonConvert.DeserializeObject<MangaResult>(aniData); } catch { return null; } }).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -9,6 +9,7 @@ using Discord.API;
|
||||
using Discord.Logging;
|
||||
using System.IO;
|
||||
using NLog;
|
||||
using NadekoBot.Extensions;
|
||||
|
||||
namespace NadekoBot
|
||||
{
|
||||
@ -70,6 +71,9 @@ namespace NadekoBot
|
||||
public Task<ISelfUser> GetCurrentUserAsync() =>
|
||||
Clients[0].GetCurrentUserAsync();
|
||||
|
||||
public Task<ISelfUser[]> GetAllCurrentUsersAsync() =>
|
||||
Task.WhenAll(Clients.Select(c => c.GetCurrentUserAsync()));
|
||||
|
||||
public IReadOnlyCollection<IGuild> GetGuilds() =>
|
||||
Clients.SelectMany(c => c.GetGuilds()).ToArray();
|
||||
|
||||
@ -87,5 +91,18 @@ namespace NadekoBot
|
||||
|
||||
internal Task DownloadAllUsersAsync() =>
|
||||
Task.WhenAll(Clients.Select(async c => { await c.DownloadAllUsersAsync(); _log.Info($"Shard #{c.ShardId} downloaded {c.GetGuilds().Sum(g => g.GetUsers().Count)} users."); }));
|
||||
|
||||
public async Task SetGame(string game)
|
||||
{
|
||||
await Task.WhenAll((await GetAllCurrentUsersAsync())
|
||||
.Select(u => u.ModifyStatusAsync(ms => ms.Game = new Discord.Game(game))));
|
||||
}
|
||||
|
||||
public async Task SetStream(string name, string url)
|
||||
{
|
||||
await Task.WhenAll((await GetAllCurrentUsersAsync())
|
||||
.Select(u => u.ModifyStatusAsync(ms => ms.Game = new Discord.Game(name, url, StreamType.Twitch))));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user