mirror of
				https://gitlab.com/Kwoth/nadekobot.git
				synced 2025-11-04 00:34:26 -05:00 
			
		
		
		
	Added image attachment support for .ea if you omit imageUrl
This commit is contained in:
		@@ -286,7 +286,7 @@ namespace NadekoBot.Modules.Utility
 | 
			
		||||
        [RequireContext(ContextType.Guild)]
 | 
			
		||||
        [RequireBotPermission(GuildPermission.ManageEmojis)]
 | 
			
		||||
        [RequireUserPermission(GuildPermission.ManageEmojis)]
 | 
			
		||||
        [Priority(0)]
 | 
			
		||||
        [Priority(2)]
 | 
			
		||||
        public Task EmojiAdd(string name, Emote emote)
 | 
			
		||||
            => EmojiAdd(name, emote.Url);
 | 
			
		||||
        
 | 
			
		||||
@@ -294,6 +294,7 @@ namespace NadekoBot.Modules.Utility
 | 
			
		||||
        [RequireContext(ContextType.Guild)]
 | 
			
		||||
        [RequireBotPermission(GuildPermission.ManageEmojis)]
 | 
			
		||||
        [RequireUserPermission(GuildPermission.ManageEmojis)]
 | 
			
		||||
        [Priority(1)]
 | 
			
		||||
        public Task EmojiAdd(Emote emote)
 | 
			
		||||
            => EmojiAdd(emote.Name, emote.Url);
 | 
			
		||||
        
 | 
			
		||||
@@ -301,9 +302,16 @@ namespace NadekoBot.Modules.Utility
 | 
			
		||||
        [RequireContext(ContextType.Guild)]
 | 
			
		||||
        [RequireBotPermission(GuildPermission.ManageEmojis)]
 | 
			
		||||
        [RequireUserPermission(GuildPermission.ManageEmojis)]
 | 
			
		||||
        public async Task EmojiAdd(string name, string url)
 | 
			
		||||
        [Priority(0)]
 | 
			
		||||
        public async Task EmojiAdd(string name, string url = null)
 | 
			
		||||
        {
 | 
			
		||||
            name = name.Trim(':');
 | 
			
		||||
 | 
			
		||||
            url ??= ctx.Message.Attachments.FirstOrDefault()?.Url;
 | 
			
		||||
 | 
			
		||||
            if (url is null)
 | 
			
		||||
                return;
 | 
			
		||||
            
 | 
			
		||||
            using var http = _httpFactory.CreateClient();
 | 
			
		||||
            var res = await http.GetAsync(url, HttpCompletionOption.ResponseHeadersRead);
 | 
			
		||||
            if (!res.IsImage() || res.GetImageSize() is null or > 262_144)
 | 
			
		||||
 
 | 
			
		||||
@@ -1200,6 +1200,7 @@ emojiadd:
 | 
			
		||||
    Adds the specified emoji to this server.
 | 
			
		||||
    You can specify a name before the emoji to add it under a different name.
 | 
			
		||||
    You can specify a name followed by an image link to add a new emoji from an image.
 | 
			
		||||
    You can omit imageUrl and instead upload the image as an attachment. 
 | 
			
		||||
    Image size has to be below 256KB.
 | 
			
		||||
  args:
 | 
			
		||||
    - ":someonesCustomEmoji:"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user