Skip to content

Commit

Permalink
feature(internal): Set the @everyone IRole for @everyone and @here ta…
Browse files Browse the repository at this point in the history
…gs (#1313)

* Set the @everyone IRole for @everyone and @here tags

Adds support for setting the IRole corresponding to @everyone or @here in a the tags of a message. Previously this would only set the TagType, but leave the value as null.

This does not distinguish between @everyone and @here, as that's done using TagType. The values of both will be the same.

This issue was suggested by @TheCasino

* use the EveryoneRole property

oops

* use null conditional operator instead of a null check
  • Loading branch information
Chris-Johnston authored and foxbot committed Jun 2, 2019
1 parent 4d7de17 commit 1f55f01
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,9 @@ public static ImmutableArray<ITag> ParseTags(string text, IMessageChannel channe
{
index = text.IndexOf("@everyone", index);
if (index == -1) break;

var tagIndex = FindIndex(tags, index);
if (tagIndex.HasValue)
tags.Insert(tagIndex.Value, new Tag<object>(TagType.EveryoneMention, index, "@everyone".Length, 0, null));
tags.Insert(tagIndex.Value, new Tag<IRole>(TagType.EveryoneMention, index, "@everyone".Length, 0, guild?.EveryoneRole));
index++;
}

Expand All @@ -164,10 +163,9 @@ public static ImmutableArray<ITag> ParseTags(string text, IMessageChannel channe
{
index = text.IndexOf("@here", index);
if (index == -1) break;

var tagIndex = FindIndex(tags, index);
if (tagIndex.HasValue)
tags.Insert(tagIndex.Value, new Tag<object>(TagType.HereMention, index, "@here".Length, 0, null));
tags.Insert(tagIndex.Value, new Tag<IRole>(TagType.HereMention, index, "@here".Length, 0, guild?.EveryoneRole));
index++;
}

Expand Down

0 comments on commit 1f55f01

Please sign in to comment.