Improve Discord Add/Delete embeds
This commit is contained in:
parent
14bea16aef
commit
7511d4a60f
|
@ -252,16 +252,29 @@ namespace NzbDrone.Core.Notifications.Discord
|
||||||
{
|
{
|
||||||
var series = deleteMessage.Series;
|
var series = deleteMessage.Series;
|
||||||
var episodes = deleteMessage.EpisodeFile.Episodes;
|
var episodes = deleteMessage.EpisodeFile.Episodes;
|
||||||
|
var deletedFile = deleteMessage.EpisodeFile.Path;
|
||||||
|
var reason = deleteMessage.Reason;
|
||||||
|
|
||||||
var attachments = new List<Embed>
|
var embed = new Embed
|
||||||
{
|
{
|
||||||
new Embed
|
Author = new DiscordAuthor
|
||||||
{
|
{
|
||||||
Title = GetTitle(series, episodes)
|
Name = Settings.Author.IsNullOrWhiteSpace() ? Environment.MachineName : Settings.Author,
|
||||||
}
|
IconUrl = "https://raw.githubusercontent.com/Sonarr/Sonarr/develop/Logo/256.png"
|
||||||
};
|
},
|
||||||
|
Url = $"http://thetvdb.com/?tab=series&id={series.TvdbId}",
|
||||||
|
Title = GetTitle(series, episodes),
|
||||||
|
Description = "Episode Deleted",
|
||||||
|
Color = (int)DiscordColors.Danger,
|
||||||
|
Fields = new List<DiscordField>
|
||||||
|
{
|
||||||
|
new DiscordField { Name = "Reason", Value = reason.ToString() },
|
||||||
|
new DiscordField { Name = "File name", Value = string.Format("```{0}```", deletedFile) }
|
||||||
|
},
|
||||||
|
Timestamp = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"),
|
||||||
|
};
|
||||||
|
|
||||||
var payload = CreatePayload("Episode Deleted", attachments);
|
var payload = CreatePayload(null, new List<Embed> { embed });
|
||||||
|
|
||||||
_proxy.SendPayload(payload, Settings);
|
_proxy.SendPayload(payload, Settings);
|
||||||
}
|
}
|
||||||
|
@ -269,17 +282,37 @@ namespace NzbDrone.Core.Notifications.Discord
|
||||||
public override void OnSeriesAdd(SeriesAddMessage message)
|
public override void OnSeriesAdd(SeriesAddMessage message)
|
||||||
{
|
{
|
||||||
var series = message.Series;
|
var series = message.Series;
|
||||||
|
var embed = new Embed
|
||||||
|
{
|
||||||
|
Author = new DiscordAuthor
|
||||||
|
{
|
||||||
|
Name = Settings.Author.IsNullOrWhiteSpace() ? Environment.MachineName : Settings.Author,
|
||||||
|
IconUrl = "https://raw.githubusercontent.com/Sonarr/Sonarr/develop/Logo/256.png"
|
||||||
|
},
|
||||||
|
Url = $"http://thetvdb.com/?tab=series&id={series.TvdbId}",
|
||||||
|
Title = series.Title,
|
||||||
|
Description = "Series Added",
|
||||||
|
Color = (int)DiscordColors.Success,
|
||||||
|
Fields = new List<DiscordField> { new DiscordField { Name = "Links", Value = GetLinksString(series) } }
|
||||||
|
};
|
||||||
|
|
||||||
var attachments = new List<Embed>
|
if (Settings.ImportFields.Contains((int)DiscordImportFieldType.Poster))
|
||||||
{
|
{
|
||||||
new Embed
|
embed.Thumbnail = new DiscordImage
|
||||||
{
|
{
|
||||||
Title = series.Title,
|
Url = series.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Poster)?.RemoteUrl
|
||||||
Description = message.Message
|
};
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
var payload = CreatePayload("Series Added", attachments);
|
if (Settings.ImportFields.Contains((int)DiscordImportFieldType.Fanart))
|
||||||
|
{
|
||||||
|
embed.Image = new DiscordImage
|
||||||
|
{
|
||||||
|
Url = series.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Fanart)?.RemoteUrl
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var payload = CreatePayload(null, new List<Embed> { embed });
|
||||||
|
|
||||||
_proxy.SendPayload(payload, Settings);
|
_proxy.SendPayload(payload, Settings);
|
||||||
}
|
}
|
||||||
|
@ -288,16 +321,37 @@ namespace NzbDrone.Core.Notifications.Discord
|
||||||
{
|
{
|
||||||
var series = deleteMessage.Series;
|
var series = deleteMessage.Series;
|
||||||
|
|
||||||
var attachments = new List<Embed>
|
var embed = new Embed
|
||||||
{
|
{
|
||||||
new Embed
|
Author = new DiscordAuthor
|
||||||
{
|
{
|
||||||
Title = series.Title,
|
Name = Settings.Author.IsNullOrWhiteSpace() ? Environment.MachineName : Settings.Author,
|
||||||
Description = deleteMessage.DeletedFilesMessage
|
IconUrl = "https://raw.githubusercontent.com/Sonarr/Sonarr/develop/Logo/256.png"
|
||||||
}
|
},
|
||||||
};
|
Url = $"http://thetvdb.com/?tab=series&id={series.TvdbId}",
|
||||||
|
Title = series.Title,
|
||||||
|
Description = deleteMessage.DeletedFilesMessage,
|
||||||
|
Color = (int)DiscordColors.Danger,
|
||||||
|
Fields = new List<DiscordField> { new DiscordField { Name = "Links", Value = GetLinksString(series) } }
|
||||||
|
};
|
||||||
|
|
||||||
var payload = CreatePayload("Series Deleted", attachments);
|
if (Settings.ImportFields.Contains((int)DiscordImportFieldType.Poster))
|
||||||
|
{
|
||||||
|
embed.Thumbnail = new DiscordImage
|
||||||
|
{
|
||||||
|
Url = series.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Poster)?.RemoteUrl
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Settings.ImportFields.Contains((int)DiscordImportFieldType.Fanart))
|
||||||
|
{
|
||||||
|
embed.Image = new DiscordImage
|
||||||
|
{
|
||||||
|
Url = series.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Fanart)?.RemoteUrl
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var payload = CreatePayload(null, new List<Embed> { embed });
|
||||||
|
|
||||||
_proxy.SendPayload(payload, Settings);
|
_proxy.SendPayload(payload, Settings);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue