# 通过自动化授予徽章

**URL:** https://meta.discourse.org/t/grant-badges-through-automation/232715
**Category:** Feature
**Tags:** badges, automation
**Created:** [2022年五月3日 18:07 UTC](https://meta.discourse.org/t/grant-badges-through-automation/232715 "2022-05-03T18:07:51Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Carolina](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/carolina/32/249909_2.png) [@Carolina](https://meta.discourse.org/u/Carolina)
#### Post date: [2022年五月3日 18:07 UTC](https://meta.discourse.org/t/grant-badges-through-automation/232715/1 "2022-05-03T18:07:51Z")

</div>

您好！是否有计划将徽章授予添加到可用脚本列表中？

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [2022年五月5日 10:12 UTC](https://meta.discourse.org/t/grant-badges-through-automation/232715/2 "2022-05-05T10:12:32Z")

</div>

嗨 @Carolina，很棒的主意，我将很快实现它 👍

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [2022年五月5日 15:07 UTC](https://meta.discourse.org/t/grant-badges-through-automation/232715/3 "2022-05-05T15:07:47Z")

</div>

我已完成拉取请求，目前正在等待审核：

> <https://github.com/discourse/discourse-automation/pull/109>
>
> This trigger needs a \`badge\` as required field and accepts an optional \`only\_on\_…first\_grant\` field. ATM it’s usable for: \`send\_pms\` and \`zapier\_webhook\` scripts.

请注意，这需要一个更新的 Discourse 实例才能正常工作，因为我在处理此问题时发现了一个关于徽章授予者的错误：

> <https://github.com/discourse/discourse/commit/81580e559c3806df6143c86610f51253809372c7>
>
> This bug was causing double events to be fired as :user\_badge\_granted is already… called when a \`user\_badge\` is created. More over the signature of the block in the UserBadge code is \`badge\_id, user\_id\` not \`badge, user\_id\`.

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [2024年一月26日 22:33 UTC](https://meta.discourse.org/t/grant-badges-through-automation/232715/6 "2024-01-26T22:33:15Z")

</div>



---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [2024年一月29日 10:04 UTC](https://meta.discourse.org/t/grant-badges-through-automation/232715/7 "2024-01-29T10:04:11Z")

</div>



---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [2024年一月29日 10:09 UTC](https://meta.discourse.org/t/grant-badges-through-automation/232715/8 "2024-01-29T10:09:31Z")

</div>

我认为此主题的原始请求是能够通过自动化授予徽章，而不是将徽章的授予作为触发器。

目前，这是通过[自定义触发徽章 SQL](https://meta.discourse.org/t/create-triggered-custom-badge-queries/19336)完成的，但这并非在所有托管选项上都可用。
