mention related stuff
This commit is contained in:
parent
833f4fe8e5
commit
b53af56fff
5 changed files with 29 additions and 2 deletions
|
@ -705,6 +705,7 @@ namespace Maki
|
||||||
OnMessageUpdate?.Invoke(msg);
|
OnMessageUpdate?.Invoke(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: account for DMs
|
||||||
private void ShardManager_OnTypingStart(GatewayShard shard, TypingStart typing)
|
private void ShardManager_OnTypingStart(GatewayShard shard, TypingStart typing)
|
||||||
{
|
{
|
||||||
DiscordChannel channel = channels.Find(x => x.Id == typing.Channel);
|
DiscordChannel channel = channels.Find(x => x.Id == typing.Channel);
|
||||||
|
|
|
@ -12,12 +12,14 @@ namespace Maki
|
||||||
private readonly Discord client;
|
private readonly Discord client;
|
||||||
|
|
||||||
public string Name { get; internal set; }
|
public string Name { get; internal set; }
|
||||||
|
public DiscordChannelType Type { get; internal set; }
|
||||||
|
|
||||||
internal DiscordChannel(Discord discord, Channel channel, DiscordServer server)
|
internal DiscordChannel(Discord discord, Channel channel, DiscordServer server)
|
||||||
{
|
{
|
||||||
client = discord;
|
client = discord;
|
||||||
Id = channel.Id;
|
Id = channel.Id;
|
||||||
Name = channel.Name;
|
Name = channel.Name;
|
||||||
|
Type = (DiscordChannelType)channel.Type;
|
||||||
Server = server;
|
Server = server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
9
Maki/DiscordChannelType.cs
Normal file
9
Maki/DiscordChannelType.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
namespace Maki
|
||||||
|
{
|
||||||
|
public enum DiscordChannelType
|
||||||
|
{
|
||||||
|
Text = 0,
|
||||||
|
Private = 1,
|
||||||
|
Voice = 2,
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
using Maki.Structures.Messages;
|
using Maki.Structures.Messages;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Maki
|
namespace Maki
|
||||||
{
|
{
|
||||||
|
@ -13,6 +14,16 @@ namespace Maki
|
||||||
|
|
||||||
public string Text { get; internal set; }
|
public string Text { get; internal set; }
|
||||||
public DateTime Edited { 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)
|
internal DiscordMessage(Discord discord, Message msg, DiscordMember member, DiscordChannel channel)
|
||||||
{
|
{
|
||||||
|
@ -22,6 +33,9 @@ namespace Maki
|
||||||
Text = msg.Content;
|
Text = msg.Content;
|
||||||
Sender = member;
|
Sender = member;
|
||||||
Channel = channel;
|
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)
|
public DiscordMessage Edit(string text)
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
<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>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
@ -46,12 +46,13 @@
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="websocket-sharp, Version=1.0.2.59611, Culture=neutral, PublicKeyToken=5660b08a1845a91e, processorArchitecture=MSIL">
|
<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>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="DiscordChannel.cs" />
|
<Compile Include="DiscordChannel.cs" />
|
||||||
<Compile Include="Discord.cs" />
|
<Compile Include="Discord.cs" />
|
||||||
|
<Compile Include="DiscordChannelType.cs" />
|
||||||
<Compile Include="DiscordColour.cs" />
|
<Compile Include="DiscordColour.cs" />
|
||||||
<Compile Include="DiscordEmbed.cs" />
|
<Compile Include="DiscordEmbed.cs" />
|
||||||
<Compile Include="DiscordEmbedAuthor.cs" />
|
<Compile Include="DiscordEmbedAuthor.cs" />
|
||||||
|
|
Reference in a new issue