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:
committed by
Christopher F
parent
4d7de176d0
commit
1f55f01866
@@ -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++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user