updates
This commit is contained in:
parent
699694db7c
commit
a2528d64da
5 changed files with 19 additions and 45 deletions
|
@ -468,6 +468,7 @@ namespace Maki
|
|||
{
|
||||
server = servers.Find(x => x.Id == guild.Id);
|
||||
server.Name = guild.Name;
|
||||
server.OwnerId = guild.OwnerId ?? 0;
|
||||
}
|
||||
|
||||
if (guild.Channels != null)
|
||||
|
@ -511,8 +512,8 @@ namespace Maki
|
|||
DiscordServer server = servers.Find(x => x.Id == guild.Id);
|
||||
|
||||
server.Name = guild.Name;
|
||||
/*server.OwnerId = guild.OwnerId;
|
||||
server.VoiceRegionId = guild.VoiceRegionId;
|
||||
server.OwnerId = guild.OwnerId ?? 0;
|
||||
/*server.VoiceRegionId = guild.VoiceRegionId;
|
||||
server.AfkChannelId = guild.AfkChannelId;
|
||||
server.AfkTimeout = guild.AfkTimeout;
|
||||
server.EmbedEnabled = guild.EmbedEnabled;
|
||||
|
@ -636,6 +637,11 @@ namespace Maki
|
|||
DiscordRole role = roles.Find(x => x.Id == dRole.Id && x.Server.Id == sRole.Guild);
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -668,7 +674,7 @@ namespace Maki
|
|||
private void ShardManager_OnMessageCreate(GatewayShard shard, Message message)
|
||||
{
|
||||
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);
|
||||
messages.Add(msg);
|
||||
OnMessageCreate?.Invoke(msg);
|
||||
|
@ -727,7 +733,8 @@ namespace Maki
|
|||
break;
|
||||
|
||||
case @"away":
|
||||
member.User.Status = DiscordUserStatus.Away;
|
||||
case @"idle":
|
||||
member.User.Status = DiscordUserStatus.Idle;
|
||||
break;
|
||||
|
||||
case @"dnd":
|
||||
|
|
|
@ -37,40 +37,8 @@ namespace Maki
|
|||
UserLimit = channel.UserLimit ?? 0;
|
||||
Server = server;
|
||||
}
|
||||
|
||||
public DiscordMessage Send(string text)
|
||||
{
|
||||
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)
|
||||
|
||||
public DiscordMessage Send(string text = "", DiscordEmbed embed = null)
|
||||
{
|
||||
RestResponse<Message> msg = client.RestClient.Request<Message>(
|
||||
RestRequestMethod.POST,
|
||||
|
@ -78,7 +46,7 @@ namespace Maki
|
|||
new MessageCreate
|
||||
{
|
||||
Text = text,
|
||||
Embed = embed.ToStruct(),
|
||||
Embed = embed?.ToStruct(),
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Maki
|
|||
public readonly DiscordServer Server;
|
||||
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 string Nickname { get; internal set; }
|
||||
|
@ -38,10 +38,7 @@ namespace Maki
|
|||
roles.AddRange(member.Roles);
|
||||
}
|
||||
|
||||
public bool HasRole(ulong id)
|
||||
{
|
||||
return roles.Contains(id);
|
||||
}
|
||||
public bool HasRole(ulong id) => roles.Contains(id);
|
||||
|
||||
public void AddRoles(params DiscordRole[] roles)
|
||||
{
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace Maki
|
|||
public DiscordPermission Perms { get; internal set; }
|
||||
public bool IsHoisted { get; internal set; }
|
||||
public bool IsMentionable { get; internal set; }
|
||||
public int Position { get; internal set; }
|
||||
|
||||
public override string ToString() => $@"<@&{Id}>";
|
||||
|
||||
|
@ -27,6 +28,7 @@ namespace Maki
|
|||
Perms = (DiscordPermission)role.Permissions;
|
||||
IsHoisted = role.IsHoisted == true;
|
||||
IsMentionable = role.IsMentionable == true;
|
||||
Position = role.Position ?? 0;
|
||||
Server = server;
|
||||
Colour = new DiscordColour(role.Colour ?? uint.MinValue);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
{
|
||||
Online,
|
||||
Offline,
|
||||
Away,
|
||||
Idle,
|
||||
DoNotDisturb,
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue