mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-25 23:18:56 -07:00
44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
using CSharpDiscordWebhook.Objects;
|
|
using System.Drawing;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace RadicadeServer.Radicade.Discord.Templates
|
|
{
|
|
public class WebhookImageUpload : IWebhookTemplate
|
|
{
|
|
public static async Task Send(string image, string username, string displayName, string profileImage, string? roomName = null) { await RadicadeWebhook.SendMessage(Construct(image,username,displayName,profileImage,roomName!)); }
|
|
|
|
public static MessageBuilder Construct(params object[] args)
|
|
{
|
|
if (args.Length < 4) {
|
|
throw new ArgumentException("you FUCKER i expected: image, username, display name, profile image (and probably room name)");
|
|
}
|
|
|
|
string image = (string)args[0];
|
|
string username = (string)args[1];
|
|
string displayName = (string)args[2];
|
|
string profileImage = (string)args[3];
|
|
string? roomName = (args.Length >= 5) ? (string)args[4] : null;
|
|
|
|
return new MessageBuilder
|
|
{
|
|
Embeds = [
|
|
new EmbedBuilder {
|
|
Author = new EmbedAuthorBuilder {
|
|
Name = $"@{username}",
|
|
IconUrl = profileImage + "?width=256&cropSquare=1"
|
|
},
|
|
Color = Color.LimeGreen,
|
|
Description = (roomName == null) ? $"{displayName} just uploaded an image!" : $"{displayName} just uploaded an image in **{roomName}**!",
|
|
Title = $"New image uploaded by {displayName}!",
|
|
Image = new EmbedMediaBuilder {
|
|
Url = image,
|
|
Width = 768
|
|
}
|
|
}
|
|
]
|
|
};
|
|
}
|
|
}
|
|
}
|