DM fixes
This commit is contained in:
parent
a2528d64da
commit
8a22b05cc4
3 changed files with 19 additions and 8 deletions
|
@ -674,8 +674,8 @@ namespace Maki
|
||||||
private void ShardManager_OnMessageCreate(GatewayShard shard, Message message)
|
private void ShardManager_OnMessageCreate(GatewayShard shard, Message message)
|
||||||
{
|
{
|
||||||
DiscordChannel channel = channels.Find(x => x.Id == message.ChannelId);
|
DiscordChannel channel = channels.Find(x => x.Id == message.ChannelId);
|
||||||
DiscordMember member = members.Find(x => x.User.Id == message.User.Id && x.Server == channel.Server);
|
DiscordMember member = members.Where(x => x.User.Id == message.User.Id && x.Server == channel.Server).FirstOrDefault();
|
||||||
DiscordMessage msg = new DiscordMessage(this, message, member, channel);
|
DiscordMessage msg = new DiscordMessage(this, message, channel, member);
|
||||||
messages.Add(msg);
|
messages.Add(msg);
|
||||||
OnMessageCreate?.Invoke(msg);
|
OnMessageCreate?.Invoke(msg);
|
||||||
}
|
}
|
||||||
|
@ -696,7 +696,7 @@ namespace Maki
|
||||||
RestResponse<Message> getMsg = RestClient.Request<Message>(RestRequestMethod.GET, RestEndpoints.ChannelMessage(message.ChannelId, message.Id));
|
RestResponse<Message> getMsg = RestClient.Request<Message>(RestRequestMethod.GET, RestEndpoints.ChannelMessage(message.ChannelId, message.Id));
|
||||||
DiscordChannel channel = channels.Where(x => x.Id == getMsg.Response.ChannelId).FirstOrDefault();
|
DiscordChannel channel = channels.Where(x => x.Id == getMsg.Response.ChannelId).FirstOrDefault();
|
||||||
DiscordMember member = members.Where(x => x.User.Id == getMsg.Response.User.Id && (channel.Server == null || channel.Server == x.Server)).FirstOrDefault();
|
DiscordMember member = members.Where(x => x.User.Id == getMsg.Response.User.Id && (channel.Server == null || channel.Server == x.Server)).FirstOrDefault();
|
||||||
msg = new DiscordMessage(this, getMsg.Response, member, channel);
|
msg = new DiscordMessage(this, getMsg.Response, channel, member);
|
||||||
messages.Add(msg);
|
messages.Add(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace Maki
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
DiscordMessage message = new DiscordMessage(client, msg.Response, client.members.Find(x => x.User.Id == msg.Response.User.Id), this);
|
DiscordMessage message = new DiscordMessage(client, msg.Response, this, client.members.Find(x => x.User.Id == msg.Response.User.Id));
|
||||||
client.messages.Add(message);
|
client.messages.Add(message);
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,8 @@ namespace Maki
|
||||||
{
|
{
|
||||||
public readonly ulong Id;
|
public readonly ulong Id;
|
||||||
public readonly DateTime Sent;
|
public readonly DateTime Sent;
|
||||||
public readonly DiscordMember Sender;
|
public readonly DiscordMember Member;
|
||||||
|
public readonly DiscordUser User;
|
||||||
public readonly DiscordChannel Channel;
|
public readonly DiscordChannel Channel;
|
||||||
private readonly Discord client;
|
private readonly Discord client;
|
||||||
|
|
||||||
|
@ -26,15 +27,25 @@ namespace Maki
|
||||||
|| (Channel.Type != DiscordChannelType.Private && roles && client.members.Where(x => x.User == client.Me && x.Server == Channel.Server).First().Roles.Where(x => MentionsRoles.Contains(x)).Count() > 0)
|
|| (Channel.Type != DiscordChannelType.Private && 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);
|
|| MentionsUsers.Select(x => x.User).Contains(client.Me);
|
||||||
|
|
||||||
public bool IsMe => client.Me == Sender.User;
|
public bool IsMe => client.Me == User;
|
||||||
|
|
||||||
internal DiscordMessage(Discord discord, Message msg, DiscordMember member, DiscordChannel channel)
|
internal DiscordMessage(Discord discord, Message msg, DiscordChannel channel, DiscordMember member = null)
|
||||||
{
|
{
|
||||||
client = discord;
|
client = discord;
|
||||||
Id = msg.Id;
|
Id = msg.Id;
|
||||||
Sent = msg.Sent;
|
Sent = msg.Sent;
|
||||||
Text = msg.Content;
|
Text = msg.Content;
|
||||||
Sender = member;
|
|
||||||
|
if (member != null)
|
||||||
|
{
|
||||||
|
Member = member;
|
||||||
|
User = member.User;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
member = null;
|
||||||
|
User = client.users.Where(x => x.Id == msg.User.Id).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
Channel = channel;
|
Channel = channel;
|
||||||
MentionsUsers = client.members.Where(x => x.Server == channel.Server && msg.Mentions.Select(y => y.Id).Contains(x.User.Id)).ToArray();
|
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();
|
MentionsRoles = client.roles.Where(x => x.Server == channel.Server && msg.MentionsRoles.Contains(x.Id)).ToArray();
|
||||||
|
|
Reference in a new issue