Fixed some console log spam which was incorrectly done by streamrole feature, upped version to 3.0.10 in stats

This commit is contained in:
Kwoth
2021-12-01 07:02:01 +01:00
parent 71f1e43272
commit 1e6d0806d7
2 changed files with 10 additions and 4 deletions

View File

@@ -227,6 +227,9 @@ namespace NadekoBot.Modules.Utility.Services
private async Task RescanUser(IGuildUser user, StreamRoleSettings setting, IRole addRole = null) private async Task RescanUser(IGuildUser user, StreamRoleSettings setting, IRole addRole = null)
{ {
if (user.IsBot)
return;
var g = (StreamingGame)user.Activities var g = (StreamingGame)user.Activities
.FirstOrDefault(a => a is StreamingGame && .FirstOrDefault(a => a is StreamingGame &&
(string.IsNullOrWhiteSpace(setting.Keyword) (string.IsNullOrWhiteSpace(setting.Keyword)
@@ -240,7 +243,7 @@ namespace NadekoBot.Modules.Utility.Services
{ {
try try
{ {
addRole = addRole ?? user.Guild.GetRole(setting.AddRoleId); addRole ??= user.Guild.GetRole(setting.AddRoleId);
if (addRole is null) if (addRole is null)
{ {
await StopStreamRole(user.Guild).ConfigureAwait(false); await StopStreamRole(user.Guild).ConfigureAwait(false);
@@ -249,9 +252,12 @@ namespace NadekoBot.Modules.Utility.Services
} }
//check if he doesn't have addrole already, to avoid errors //check if he doesn't have addrole already, to avoid errors
if (!user.RoleIds.Contains(setting.AddRoleId)) if (!user.RoleIds.Contains(addRole.Id))
{
await user.AddRoleAsync(addRole).ConfigureAwait(false); await user.AddRoleAsync(addRole).ConfigureAwait(false);
Log.Information("Added stream role to user {0} in {1} server", user.ToString(), user.Guild.ToString()); Log.Information("Added stream role to user {0} in {1} server", user.ToString(),
user.Guild.ToString());
}
} }
catch (HttpException ex) when (ex.HttpCode == System.Net.HttpStatusCode.Forbidden) catch (HttpException ex) when (ex.HttpCode == System.Net.HttpStatusCode.Forbidden)
{ {

View File

@@ -20,7 +20,7 @@ namespace NadekoBot.Services
private readonly IBotCredentials _creds; private readonly IBotCredentials _creds;
private readonly DateTime _started; private readonly DateTime _started;
public const string BotVersion = "3.0.9"; public const string BotVersion = "3.0.10";
public string Author => "Kwoth#2452"; public string Author => "Kwoth#2452";
public string Library => "Discord.Net"; public string Library => "Discord.Net";
public double MessagesPerSecond => MessageCounter / GetUptime().TotalSeconds; public double MessagesPerSecond => MessageCounter / GetUptime().TotalSeconds;