Added IWebhookUser and MessageSource
This commit is contained in:
@@ -37,11 +37,8 @@ namespace Discord
|
||||
public static async Task InvokeAsync(this AsyncEvent<Func<Task>> eventHandler)
|
||||
{
|
||||
var subscribers = eventHandler.Subscriptions;
|
||||
if (subscribers.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < subscribers.Count; i++)
|
||||
await subscribers[i].Invoke().ConfigureAwait(false);
|
||||
}
|
||||
for (int i = 0; i < subscribers.Count; i++)
|
||||
await subscribers[i].Invoke().ConfigureAwait(false);
|
||||
}
|
||||
public static async Task InvokeAsync<T>(this AsyncEvent<Func<T, Task>> eventHandler, T arg)
|
||||
{
|
||||
|
||||
@@ -51,5 +51,9 @@ namespace Discord
|
||||
{
|
||||
public static Optional<T> Create<T>() => Optional<T>.Unspecified;
|
||||
public static Optional<T> Create<T>(T value) => new Optional<T>(value);
|
||||
|
||||
public static T? ToNullable<T>(this Optional<T> val)
|
||||
where T : struct
|
||||
=> val.IsSpecified ? val.Value : (T?)null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,12 +86,16 @@ namespace Discord
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void UnsetBit(ref ulong value, byte bit) => value &= ~(1U << bit);
|
||||
|
||||
public static ChannelPermissions ToChannelPerms(IGuildChannel channel, ulong guildPermissions)
|
||||
=> new ChannelPermissions(guildPermissions & ChannelPermissions.All(channel).RawValue);
|
||||
public static ulong ResolveGuild(IGuild guild, IGuildUser user)
|
||||
{
|
||||
ulong resolvedPermissions = 0;
|
||||
|
||||
if (user.Id == guild.OwnerId)
|
||||
resolvedPermissions = GuildPermissions.All.RawValue; //Owners always have all permissions
|
||||
else if (user.IsWebhook)
|
||||
resolvedPermissions = GuildPermissions.Webhook.RawValue;
|
||||
else
|
||||
{
|
||||
foreach (var roleId in user.RoleIds)
|
||||
|
||||
Reference in New Issue
Block a user