Skip to content

Commit

Permalink
Account for missing "trackingChannels" key in db
Browse files Browse the repository at this point in the history
  • Loading branch information
FloatingMilkshake committed Nov 16, 2024
1 parent 062b780 commit d645505
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions Events/MessageEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,21 +144,24 @@ public static async Task MessageHandlerAsync(DiscordClient client, MockDiscordMe
{
// Check current channel against tracking channels
var trackingChannels = await Program.db.HashGetAsync("trackingChannels", message.Author.Id);
var trackingChannelsList = JsonConvert.DeserializeObject<List<ulong>>(trackingChannels);
if (trackingChannelsList.Count > 0)
if (trackingChannels.HasValue)
{
// This user's tracking is filtered to channels; check the channel before relaying the msg to the tracking thread
var channels = JsonConvert.DeserializeObject<List<ulong>>(trackingChannels);
if (channels.Contains(channel.Id) || channels.Contains(channel.Parent.Id))
var trackingChannelsList = JsonConvert.DeserializeObject<List<ulong>>(trackingChannels);
if (trackingChannelsList.Count > 0)
{
// This user's tracking is filtered to channels; check the channel before relaying the msg to the tracking thread
var channels = JsonConvert.DeserializeObject<List<ulong>>(trackingChannels);
if (channels.Contains(channel.Id) || channels.Contains(channel.Parent.Id))
{
await RelayTrackedMessageAsync(client, message);
}
}
else
{
// This user's tracking is not filtered to channels, so just relay the msg to the tracking thread
await RelayTrackedMessageAsync(client, message);
}
}
else
{
// This user's tracking is not filtered to channels, so just relay the msg to the tracking thread
await RelayTrackedMessageAsync(client, message);
}
}

if (!isAnEdit && channel.IsPrivate && Program.cfgjson.LogChannels.ContainsKey("dms"))
Expand Down

0 comments on commit d645505

Please sign in to comment.