-
Notifications
You must be signed in to change notification settings - Fork 16
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
Discord webhooks #39
Conversation
WorkshopToolCommon/DiscordWebhook.cs
Outdated
string m_changelog; | ||
|
||
//it is a small payload | ||
static readonly string s_payload = @"{{""embeds"":[ {{""author"": {{""name"": ""{0}""}}, ""title"": ""{1}"", ""description"": ""{2}""}} ]}}"; |
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.
Static members are just prefixed with a single underscore _
, not s_
.
Though, I appreciate the attention to the code style. 👍
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.
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>")] |
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.
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?
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.
Ah no- I will move that elsewhere as it should only POST to the webhook when a file was changed
WorkshopToolCommon/GameBase.cs
Outdated
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)); |
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.
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.
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}""}} ]}}"; |
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.
I missed this the first time, strings are immutable, so this should be const instead.
Not an issue though.
Added a discord webhook interface