Skip to content

Commit

Permalink
fix: handle channel types in new packages
Browse files Browse the repository at this point in the history
  • Loading branch information
aamiaa committed Aug 14, 2024
1 parent 8dc6e98 commit 8402242
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/Classes/Parsing/DChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class DChannel
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("type")]
public int Type { get; set; }
public ChannelType Type { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("guild")]
Expand Down Expand Up @@ -83,17 +83,17 @@ private void AddMessage(string id, string timestamp, string contents, string att

public bool IsDM()
{
return this.Type == 1;
return this.Type == ChannelType.DM;
}

public bool IsGroupDM()
{
return this.Type == 3;
return this.Type == ChannelType.GROUP_DM;
}

public bool IsVoice()
{
return this.Type == 2 || this.Type == 13;
return this.Type == ChannelType.GUILD_VOICE || this.Type == ChannelType.GUILD_STAGE_VOICE;
}

public string GetOtherDMRecipient(DUser user)
Expand All @@ -114,4 +114,22 @@ public string GetOtherDMRecipient(DUser user)
throw new Exception("This shouldn't happen");
}
}

public enum ChannelType
{
GUILD_TEXT = 0,
DM = 1,
GUILD_VOICE = 2,
GROUP_DM = 3,
GUILD_CATEGORY = 4,
GUILD_ANNOUNCEMENT = 5,
GUILD_STORE = 6,
ANNOUNCEMENT_THREAD = 10,
PUBLIC_THREAD = 11,
PRIVATE_THREAD = 12,
GUILD_STAGE_VOICE = 13,
GUILD_DIRECTORY = 14,
GUILD_FORUM = 15,
GUILD_MEDIA = 16
}
}

0 comments on commit 8402242

Please sign in to comment.