Skip to content
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

Merged
merged 11 commits into from
Aug 9, 2020
Merged

Added Embed functionality #1

merged 11 commits into from
Aug 9, 2020

Conversation

xiluisx
Copy link
Collaborator

@xiluisx xiluisx commented Aug 9, 2020

Plz check my pull request Mr.G.

@ggggg ggggg self-requested a review August 9, 2020 03:59
GHooks/settings.json Outdated Show resolved Hide resolved
GHooks/settings.json Outdated Show resolved Hide resolved
GHooks/settings.json Outdated Show resolved Hide resolved
src/Webhooks/Core.cs Outdated Show resolved Hide resolved
src/Webhooks/Events/OnGlobalChatMessage.cs Outdated Show resolved Hide resolved
Comment on lines 14 to 19
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);
Copy link
Owner

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
          }
}

src/Webhooks/Events/OnLeave.cs Outdated Show resolved Hide resolved
Comment on lines 12 to 28
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);
Copy link
Owner

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

src/Webhooks/Events/OnLogin.cs Outdated Show resolved Hide resolved
src/Webhooks/Properties/AssemblyInfo.cs Outdated Show resolved Hide resolved
@ggggg
Copy link
Owner

ggggg commented Aug 9, 2020

You tested everything?
Because idk if the settings json can have embed as a type.

@xiluisx xiluisx requested a review from ggggg August 9, 2020 19:18
Comment on lines +64 to +67
EventsHandler.Add(customEvent.Event, new Action<ShPlayer, string>((player, eventName) =>
{
if (player.svPlayer.HasPermission("webhook." + eventName))
{
Copy link
Owner

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.

src/Webhooks/EmbedCrafter.cs Outdated Show resolved Hide resolved
@ggggg ggggg self-requested a review August 9, 2020 21:45
@xiluisx
Copy link
Collaborator Author

xiluisx commented Aug 9, 2020

accept now?

@ggggg ggggg merged commit f373fb7 into ggggg:master Aug 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants