feature(internal): Set the @everyone IRole for @everyone and @here tags (#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
This commit is contained in:
Chris Johnston
2019-06-02 16:53:26 -07:00
committed by Christopher F
parent 4d7de176d0
commit 1f55f01866

View File

@@ -152,10 +152,9 @@ namespace Discord.Rest
{ {
index = text.IndexOf("@everyone", index); index = text.IndexOf("@everyone", index);
if (index == -1) break; if (index == -1) break;
var tagIndex = FindIndex(tags, index); var tagIndex = FindIndex(tags, index);
if (tagIndex.HasValue) 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++; index++;
} }
@@ -164,10 +163,9 @@ namespace Discord.Rest
{ {
index = text.IndexOf("@here", index); index = text.IndexOf("@here", index);
if (index == -1) break; if (index == -1) break;
var tagIndex = FindIndex(tags, index); var tagIndex = FindIndex(tags, index);
if (tagIndex.HasValue) 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++; index++;
} }