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

Discord webhooks #39

Merged
merged 7 commits into from
Sep 11, 2021
Merged

Discord webhooks #39

merged 7 commits into from
Sep 11, 2021

Conversation

Math0424
Copy link
Contributor

Added a discord webhook interface

string m_changelog;

//it is a small payload
static readonly string s_payload = @"{{""embeds"":[ {{""author"": {{""name"": ""{0}""}}, ""title"": ""{1}"", ""description"": ""{2}""}} ]}}";
Copy link
Owner

@Gwindalmir Gwindalmir Sep 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static members are just prefixed with a single underscore _, not s_.
Though, I appreciate the attention to the code style. 👍

Copy link
Owner

@Gwindalmir Gwindalmir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build failed, and given the error, I think you forgot to commit WorkshopToolCommon/WorkshopToolCommon.projitems.

Aside from that, I see some leftover changes that aren't related, such as in the project files.

@@ -25,6 +25,9 @@ public abstract class PublishVerbBase : UGCOptionBase
[Option("dependencies", HelpText = "Specify dependencies to other mods. Use 0 to remove all.", MetaValue = "<id>")]
public IEnumerable<string> Dependencies { get; set; }

[Option("discord-webhook", HelpText = "A link to a webhook that will publish update notes", MetaValue = "<url>")]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new code isn't released yet, so I want to make sure the understanding is clear.
PublishVerbBase matches both the push verb (uploading a mod), and changing metadata of a mod, without a content change (such as adding tags).

Is the intention of this to support discord web hooks even if the content of the mod hasn't changed?

Copy link
Contributor Author

@Math0424 Math0424 Sep 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah no- I will move that elsewhere as it should only POST to the webhook when a file was changed

if (hook.Call(options.DiscordWebhookUrl, out string error))
MySandboxGame.Log.WriteLineAndConsole("Sent payload to discord webhook");
else
MySandboxGame.Log.WriteLineAndConsole(string.Format("Discord webhook error: {0}", error));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend changing this to MySandboxGame.Log.WriteLineError, or, since the publish already happened anyway and can't be reversed, MySandboxGame.Log.WriteLineWarning.
Those are extension methods I added which will colorize the message appropriately.

@Gwindalmir
Copy link
Owner

Gwindalmir commented Sep 11, 2021

Oh, I just noticed, good practice is you should create a branch on your own fork to submit the PR against, otherwise if you make a commit to master again in the future, this PR will be updated, even if it's not related.

@Math0424
Copy link
Contributor Author

Oh, I just noticed, good practice is you should create a branch on your own fork to submit the PR against, otherwise if you make a commit to master again in the future, this PR will be updated, even if it's not related.

I will make a point of doing that in the future, thank you

string m_changelog;

//it is a small payload
static readonly string _payload = @"{{""embeds"":[ {{""author"": {{""name"": ""{0}""}}, ""title"": ""{1}"", ""description"": ""{2}""}} ]}}";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this the first time, strings are immutable, so this should be const instead.
Not an issue though.

@Gwindalmir Gwindalmir merged commit de50852 into Gwindalmir:master Sep 11, 2021
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