Browse Source

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
tags/2.1.1
Chris Johnston Christopher F 6 years ago
parent
commit
1f55f01866
1 changed files with 2 additions and 4 deletions
  1. +2
    -4
      src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs

+ 2
- 4
src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs View File

@@ -152,10 +152,9 @@ namespace Discord.Rest
{
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++;
}

@@ -164,10 +163,9 @@ namespace Discord.Rest
{
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++;
}



Loading…
Cancel
Save