Archived
1
0
Fork 0
This commit is contained in:
flash 2017-05-21 03:08:34 +02:00
parent 699694db7c
commit a2528d64da
5 changed files with 19 additions and 45 deletions

View file

@ -468,6 +468,7 @@ namespace Maki
{ {
server = servers.Find(x => x.Id == guild.Id); server = servers.Find(x => x.Id == guild.Id);
server.Name = guild.Name; server.Name = guild.Name;
server.OwnerId = guild.OwnerId ?? 0;
} }
if (guild.Channels != null) if (guild.Channels != null)
@ -511,8 +512,8 @@ namespace Maki
DiscordServer server = servers.Find(x => x.Id == guild.Id); DiscordServer server = servers.Find(x => x.Id == guild.Id);
server.Name = guild.Name; server.Name = guild.Name;
/*server.OwnerId = guild.OwnerId; server.OwnerId = guild.OwnerId ?? 0;
server.VoiceRegionId = guild.VoiceRegionId; /*server.VoiceRegionId = guild.VoiceRegionId;
server.AfkChannelId = guild.AfkChannelId; server.AfkChannelId = guild.AfkChannelId;
server.AfkTimeout = guild.AfkTimeout; server.AfkTimeout = guild.AfkTimeout;
server.EmbedEnabled = guild.EmbedEnabled; server.EmbedEnabled = guild.EmbedEnabled;
@ -636,6 +637,11 @@ namespace Maki
DiscordRole role = roles.Find(x => x.Id == dRole.Id && x.Server.Id == sRole.Guild); DiscordRole role = roles.Find(x => x.Id == dRole.Id && x.Server.Id == sRole.Guild);
role.Name = dRole.Name; role.Name = dRole.Name;
role.IsHoisted = dRole.IsHoisted == true;
role.IsMentionable = dRole.IsMentionable == true;
role.Perms = (DiscordPermission)dRole.Permissions;
role.Position = dRole.Position ?? 0;
role.Colour.Raw = dRole.Colour ?? 0;
OnRoleUpdate?.Invoke(role); OnRoleUpdate?.Invoke(role);
} }
@ -668,7 +674,7 @@ 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); DiscordMember member = members.Find(x => x.User.Id == message.User.Id && x.Server == channel.Server);
DiscordMessage msg = new DiscordMessage(this, message, member, channel); DiscordMessage msg = new DiscordMessage(this, message, member, channel);
messages.Add(msg); messages.Add(msg);
OnMessageCreate?.Invoke(msg); OnMessageCreate?.Invoke(msg);
@ -727,7 +733,8 @@ namespace Maki
break; break;
case @"away": case @"away":
member.User.Status = DiscordUserStatus.Away; case @"idle":
member.User.Status = DiscordUserStatus.Idle;
break; break;
case @"dnd": case @"dnd":

View file

@ -38,39 +38,7 @@ namespace Maki
Server = server; Server = server;
} }
public DiscordMessage Send(string text) public DiscordMessage Send(string text = "", DiscordEmbed embed = null)
{
RestResponse<Message> msg = client.RestClient.Request<Message>(
RestRequestMethod.POST,
RestEndpoints.ChannelMessages(Id),
new MessageCreate {
Text = text,
}
);
DiscordMessage message = new DiscordMessage(client, msg.Response, client.members.Find(x => x.User.Id == msg.Response.User.Id), this);
client.messages.Add(message);
return message;
}
public DiscordMessage Send(DiscordEmbed embed)
{
RestResponse<Message> msg = client.RestClient.Request<Message>(
RestRequestMethod.POST,
RestEndpoints.ChannelMessages(Id),
new MessageCreate
{
Text = string.Empty,
Embed = embed.ToStruct(),
}
);
DiscordMessage message = new DiscordMessage(client, msg.Response, client.members.Find(x => x.User.Id == msg.Response.User.Id), this);
client.messages.Add(message);
return message;
}
public DiscordMessage Send(string text, DiscordEmbed embed)
{ {
RestResponse<Message> msg = client.RestClient.Request<Message>( RestResponse<Message> msg = client.RestClient.Request<Message>(
RestRequestMethod.POST, RestRequestMethod.POST,
@ -78,7 +46,7 @@ namespace Maki
new MessageCreate new MessageCreate
{ {
Text = text, Text = text,
Embed = embed.ToStruct(), Embed = embed?.ToStruct(),
} }
); );

View file

@ -12,7 +12,7 @@ namespace Maki
public readonly DiscordServer Server; public readonly DiscordServer Server;
private readonly Discord client; private readonly Discord client;
public DiscordRole[] Roles => client.roles.Where(x => HasRole(x.Id)).ToArray(); public DiscordRole[] Roles => client.roles.Where(x => HasRole(x.Id) || x.Id == Server.Id).OrderByDescending(x => x.Position).ToArray();
public DateTime Joined { get; internal set; } public DateTime Joined { get; internal set; }
public string Nickname { get; internal set; } public string Nickname { get; internal set; }
@ -38,10 +38,7 @@ namespace Maki
roles.AddRange(member.Roles); roles.AddRange(member.Roles);
} }
public bool HasRole(ulong id) public bool HasRole(ulong id) => roles.Contains(id);
{
return roles.Contains(id);
}
public void AddRoles(params DiscordRole[] roles) public void AddRoles(params DiscordRole[] roles)
{ {

View file

@ -16,6 +16,7 @@ namespace Maki
public DiscordPermission Perms { get; internal set; } public DiscordPermission Perms { get; internal set; }
public bool IsHoisted { get; internal set; } public bool IsHoisted { get; internal set; }
public bool IsMentionable { get; internal set; } public bool IsMentionable { get; internal set; }
public int Position { get; internal set; }
public override string ToString() => $@"<@&{Id}>"; public override string ToString() => $@"<@&{Id}>";
@ -27,6 +28,7 @@ namespace Maki
Perms = (DiscordPermission)role.Permissions; Perms = (DiscordPermission)role.Permissions;
IsHoisted = role.IsHoisted == true; IsHoisted = role.IsHoisted == true;
IsMentionable = role.IsMentionable == true; IsMentionable = role.IsMentionable == true;
Position = role.Position ?? 0;
Server = server; Server = server;
Colour = new DiscordColour(role.Colour ?? uint.MinValue); Colour = new DiscordColour(role.Colour ?? uint.MinValue);
} }

View file

@ -4,7 +4,7 @@
{ {
Online, Online,
Offline, Offline,
Away, Idle,
DoNotDisturb, DoNotDisturb,
} }
} }