fix: .xpexclude should will now work with forums too. If you exclude a forum you won't be able to gain xp in any of the threads.

This commit is contained in:
Kwoth
2024-06-13 20:52:40 +00:00
parent ef4b1c8868
commit 30f3ae1ade
3 changed files with 10 additions and 5 deletions

View File

@@ -27,6 +27,8 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
- Fixed xp bg buy button not working, and possibly some other buttons too - Fixed xp bg buy button not working, and possibly some other buttons too
- Fixed shopbuy %user% placeholders and updated help text - Fixed shopbuy %user% placeholders and updated help text
- All .feed overloads should now work"
- `.xpexclude` should will now work with forums too. If you exclude a forum you won't be able to gain xp in any of the threads.
### Removed ### Removed

View File

@@ -668,7 +668,7 @@ public class XpService : INService, IReadyExecutor, IExecNoCommand
/// <param name="channel"></param> /// <param name="channel"></param>
private async Task ScanUserForVoiceXp(SocketGuildUser user, SocketVoiceChannel channel) private async Task ScanUserForVoiceXp(SocketGuildUser user, SocketVoiceChannel channel)
{ {
if (UserParticipatingInVoiceChannel(user) && ShouldTrackXp(user, channel.Id)) if (UserParticipatingInVoiceChannel(user) && ShouldTrackXp(user, channel))
await UserJoinedVoiceChannel(user); await UserJoinedVoiceChannel(user);
else else
await UserLeftVoiceChannel(user, channel); await UserLeftVoiceChannel(user, channel);
@@ -767,9 +767,12 @@ public class XpService : INService, IReadyExecutor, IExecNoCommand
} }
*/ */
private bool ShouldTrackXp(SocketGuildUser user, ulong channelId) private bool ShouldTrackXp(SocketGuildUser user, IMessageChannel channel)
{ {
if (_excludedChannels.TryGetValue(user.Guild.Id, out var chans) && chans.Contains(channelId)) var channelId = channel.Id;
if (_excludedChannels.TryGetValue(user.Guild.Id, out var chans) && (chans.Contains(channelId)
|| (channel is SocketThreadChannel tc && chans.Contains(tc.ParentChannel.Id))))
return false; return false;
if (_excludedServers.Contains(user.Guild.Id)) if (_excludedServers.Contains(user.Guild.Id))
@@ -788,7 +791,7 @@ public class XpService : INService, IReadyExecutor, IExecNoCommand
_ = Task.Run(async () => _ = Task.Run(async () =>
{ {
if (!ShouldTrackXp(user, arg.Channel.Id)) if (!ShouldTrackXp(user, arg.Channel))
return; return;
var xpConf = _xpConfig.Data; var xpConf = _xpConfig.Data;

View File

@@ -53,7 +53,7 @@ public class YtdlOperation
} }
catch (Win32Exception) catch (Win32Exception)
{ {
Log.Error("youtube-dl is likely not installed. " + "Please install it before running the command again"); Log.Error("youtube-dl is likely not installed. Please install it before running the command again");
return default; return default;
} }
catch (Exception ex) catch (Exception ex)