Add Extension Methods
This commit is contained in:
parent
c99784b9dc
commit
949dae6561
@ -283,7 +283,7 @@ namespace PluralKit.Bot
|
|||||||
|
|
||||||
// Fetch information about the guild early, as we need it for the logger cleanup
|
// Fetch information about the guild early, as we need it for the logger cleanup
|
||||||
GuildConfig cachedGuild = default;
|
GuildConfig cachedGuild = default;
|
||||||
if (msg.Channel.Type == ChannelType.Text) await _cache.GetGuildDataCached(msg.Channel.GuildId);
|
if (msg.Channel.Type == ChannelType.Text) cachedGuild = await _cache.GetGuildDataCached(msg.Channel.GuildId);
|
||||||
|
|
||||||
// Pass guild bot/WH messages onto the logger cleanup service, but otherwise ignore
|
// Pass guild bot/WH messages onto the logger cleanup service, but otherwise ignore
|
||||||
if (msg.Author.IsBot && msg.Channel.Type == ChannelType.Text)
|
if (msg.Author.IsBot && msg.Channel.Type == ChannelType.Text)
|
||||||
|
@ -61,7 +61,7 @@ namespace PluralKit.Bot
|
|||||||
if (target.System != ctx.System.Id) throw Errors.NotOwnMemberError;
|
if (target.System != ctx.System.Id) throw Errors.NotOwnMemberError;
|
||||||
else if (user != null)
|
else if (user != null)
|
||||||
{
|
{
|
||||||
if (user.AvatarUrl == user.DefaultAvatarUrl) throw Errors.UserHasNoAvatar; //TODO: is this necessary?
|
if (!user.HasAvatar()) throw Errors.UserHasNoAvatar; //TODO: is this necessary?
|
||||||
target.AvatarUrl = user.GetAvatarUrl(ImageFormat.Png, size: 256);
|
target.AvatarUrl = user.GetAvatarUrl(ImageFormat.Png, size: 256);
|
||||||
|
|
||||||
await _data.SaveMember(target);
|
await _data.SaveMember(target);
|
||||||
@ -131,7 +131,7 @@ namespace PluralKit.Bot
|
|||||||
|
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
if (user.AvatarUrl == user.DefaultAvatarUrl) throw Errors.UserHasNoAvatar;
|
if (!user.HasAvatar()) throw Errors.UserHasNoAvatar;
|
||||||
guildData.AvatarUrl = user.GetAvatarUrl(ImageFormat.Png, size: 256);
|
guildData.AvatarUrl = user.GetAvatarUrl(ImageFormat.Png, size: 256);
|
||||||
await _data.SetMemberGuildSettings(target, ctx.Guild.Id, guildData);
|
await _data.SetMemberGuildSettings(target, ctx.Guild.Id, guildData);
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ namespace PluralKit.Bot
|
|||||||
var member = await ctx.MatchUser();
|
var member = await ctx.MatchUser();
|
||||||
if (member != null)
|
if (member != null)
|
||||||
{
|
{
|
||||||
if (member.AvatarUrl == member.DefaultAvatarUrl) throw Errors.UserHasNoAvatar;
|
if (!member.HasAvatar()) throw Errors.UserHasNoAvatar;
|
||||||
ctx.System.AvatarUrl = member.GetAvatarUrl(ImageFormat.Png, size: 256);
|
ctx.System.AvatarUrl = member.GetAvatarUrl(ImageFormat.Png, size: 256);
|
||||||
await _data.SaveSystem(ctx.System);
|
await _data.SaveSystem(ctx.System);
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using DSharpPlus;
|
using DSharpPlus;
|
||||||
|
using DSharpPlus.Entities;
|
||||||
|
|
||||||
using System.Net.WebSockets;
|
using System.Net.WebSockets;
|
||||||
|
|
||||||
@ -19,5 +20,10 @@ namespace PluralKit.Bot
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool HasAvatar(this DiscordUser user)
|
||||||
|
{
|
||||||
|
return user.AvatarUrl != user.DefaultAvatarUrl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user