-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Embed functionality #1
Conversation
src/Webhooks/Events/OnLeave.cs
Outdated
foreach (var em in Core.Instance.Settings.Server.PlayerLeaveEmbed) | ||
{ | ||
leaveEmb.Add(new Embed { Title = string.Format(em.Title, player.username), Description = string.Format(em.Description, player.username) }); | ||
} | ||
Core.Instance.joinWebhook.Send(string.Format(Core.Instance.Settings.Server.PlayerLeaveFormat, player.username), player.username, | ||
embeds: Core.Instance.Settings.Server.PlayerLeaveUseEmbed? leaveEmb:null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this is a lot of duplicate code, maybe we would have it in a function that takes in the embed settings and returns it back:
public List<Embed> CreateAllEmbeds(List<Embed> embeds) {
var emb = new List<Embed>();
foreach (var em in Core.Instance.Settings.Server.PlayerLeaveEmbed)
{
emb.Add(new Embed { Title = string.Format(em.Title, player.username), Description = string.Format(em.Description, player.username) }); // add more things to format and make docs on what each mean in the json
}
}
List<Embed> commandsEmb = new List<Embed>(); | ||
List<Embed> localEmb = new List<Embed>(); | ||
|
||
foreach (var em in Core.Instance.Settings.Chat.CommandsEmbed) | ||
{ | ||
commandsEmb.Add(new Embed { Title = string.Format(em.Title, message, player.username), Description = string.Format(em.Description, message, player.username) }); | ||
} | ||
foreach (var em in Core.Instance.Settings.Chat.LocalEmbed) | ||
{ | ||
localEmb.Add(new Embed { Title = string.Format(em.Title, message, player.username), Description = string.Format(em.Description, message, player.username) }); | ||
} | ||
if (message.StartsWith("/")) | ||
{ | ||
Core.Instance.commandWebhook.Send(string.Format(Core.Instance.Settings.Chat.CommandsLogFormat, message, player.username), player.username); | ||
Core.Instance.commandWebhook.Send(string.Format(Core.Instance.Settings.Chat.CommandsLogFormat, message, player.username), player.username,embeds: Core.Instance.Settings.Chat.CommandsUseEmbed?commandsEmb:null); | ||
return; | ||
} | ||
Core.Instance.localWebhook.Send(string.Format(Core.Instance.Settings.Chat.LocalFormat, message, player.username), player.username); | ||
Core.Instance.localWebhook.Send(string.Format(Core.Instance.Settings.Chat.LocalFormat, message, player.username), player.username,embeds: Core.Instance.Settings.Chat.LocalUseEmbed?localEmb:null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be:
if (message.StartsWith("/"))
{
foreach (var em in Core.Instance.Settings.Chat.CommandsEmbed)
{
commandsEmb.Add(new Embed { Title = string.Format(em.Title, message, player.username), Description = string.Format(em.Description, message, player.username) });
}
Core.Instance.commandWebhook.Send(string.Format(Core.Instance.Settings.Chat.CommandsLogFormat, message, player.username), player.username,embeds: Core.Instance.Settings.Chat.CommandsUseEmbed?commandsEmb:null);
return;
}
foreach (var em in Core.Instance.Settings.Chat.LocalEmbed)
{
localEmb.Add(new Embed { Title = string.Format(em.Title, message, player.username), Description = string.Format(em.Description, message, player.username) });
}
Core.Instance.localWebhook.Send(string.Format(Core.Instance.Settings.Chat.LocalFormat, message, player.username), player.username,embeds: Core.Instance.Settings.Chat.LocalUseEmbed?localEmb:null);
I guess
You tested everything? |
Co-authored-by: Ido <[email protected]>
Co-authored-by: Ido <[email protected]>
Co-authored-by: Ido <[email protected]>
Co-authored-by: Ido <[email protected]>
Co-authored-by: Ido <[email protected]>
sure, why not Co-authored-by: Ido <[email protected]>
Co-authored-by: Ido <[email protected]>
EventsHandler.Add(customEvent.Event, new Action<ShPlayer, string>((player, eventName) => | ||
{ | ||
if (player.svPlayer.HasPermission("webhook." + eventName)) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might wanna add embeds to that soon... not urgent though.
accept now? |
Plz check my pull request Mr.G.