Archived
1
0
Fork 0

mention related stuff

This commit is contained in:
flash 2017-05-17 00:45:28 +02:00
parent 833f4fe8e5
commit b53af56fff
5 changed files with 29 additions and 2 deletions

View file

@ -705,6 +705,7 @@ namespace Maki
OnMessageUpdate?.Invoke(msg);
}
// TODO: account for DMs
private void ShardManager_OnTypingStart(GatewayShard shard, TypingStart typing)
{
DiscordChannel channel = channels.Find(x => x.Id == typing.Channel);

View file

@ -12,12 +12,14 @@ namespace Maki
private readonly Discord client;
public string Name { get; internal set; }
public DiscordChannelType Type { get; internal set; }
internal DiscordChannel(Discord discord, Channel channel, DiscordServer server)
{
client = discord;
Id = channel.Id;
Name = channel.Name;
Type = (DiscordChannelType)channel.Type;
Server = server;
}

View file

@ -0,0 +1,9 @@
namespace Maki
{
public enum DiscordChannelType
{
Text = 0,
Private = 1,
Voice = 2,
}
}

View file

@ -1,5 +1,6 @@
using Maki.Structures.Messages;
using System;
using System.Linq;
namespace Maki
{
@ -13,6 +14,16 @@ namespace Maki
public string Text { get; internal set; }
public DateTime Edited { get; internal set; }
public DiscordMember[] MentionsUsers { get; internal set; }
public DiscordRole[] MentionsRoles { get; internal set; }
public bool MentionsEveryone { get; internal set; }
public bool MentionsMe(bool everyone = false, bool roles = true) =>
(everyone && MentionsEveryone)
|| (roles && client.members.Where(x => x.User == client.Me && x.Server == Channel.Server).First().Roles.Where(x => MentionsRoles.Contains(x)).Count() > 0)
|| MentionsUsers.Select(x => x.User).Contains(client.Me);
public bool IsMe => client.Me == Sender.User;
internal DiscordMessage(Discord discord, Message msg, DiscordMember member, DiscordChannel channel)
{
@ -22,6 +33,9 @@ namespace Maki
Text = msg.Content;
Sender = member;
Channel = channel;
MentionsUsers = client.members.Where(x => x.Server == channel.Server && msg.Mentions.Select(y => y.Id).Contains(x.User.Id)).ToArray();
MentionsRoles = client.roles.Where(x => x.Server == channel.Server && msg.MentionsRoles.Contains(x.Id)).ToArray();
MentionsEveryone = msg.MentioningEveryone;
}
public DiscordMessage Edit(string text)

View file

@ -36,7 +36,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@ -46,12 +46,13 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="websocket-sharp, Version=1.0.2.59611, Culture=neutral, PublicKeyToken=5660b08a1845a91e, processorArchitecture=MSIL">
<HintPath>..\packages\WebSocketSharp.1.0.3-rc11\lib\websocket-sharp.dll</HintPath>
<HintPath>..\..\packages\WebSocketSharp.1.0.3-rc11\lib\websocket-sharp.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="DiscordChannel.cs" />
<Compile Include="Discord.cs" />
<Compile Include="DiscordChannelType.cs" />
<Compile Include="DiscordColour.cs" />
<Compile Include="DiscordEmbed.cs" />
<Compile Include="DiscordEmbedAuthor.cs" />