我想制作一個不和諧的機器人,它根據用戶從不和諧的輸入創建問題。知道我會怎么做嗎?我正在使用 JavaScript 并希望將其集成到現有機器人中。謝謝!
uj5u.com熱心網友回復:
您可以從LeagueSandbox/IssueBot(Typescript) 中獲取想法,這確實會產生問題。
它確實使用npmjs.com/package/github-api,來自github-tools/github
export class IssueCommand extends Command {
execute() {
if(!this.args) {
return
}
let issueBody = ISSUE_TEMPLATE
.replace("{PLACEHOLDER}", this.args[2] || "_No content_")
.replace("{CHANNEL}", this.message.channel.name)
.replace("{USER}", this.message.author.username)
Bot.gitHub.api.issues.create({
owner: config.githubName,
repo: this.args[0],
title: this.args[1],
body: <any>issueBody // Typings for the `github` package are incorrect, so we have to cast to any here.
},
(error, response) => this.handleGithubResponse(error, response)
)
}
handleGithubResponse(error, response) {
if(error) {
let formattedError = JSON.stringify(error, null, 4)
let reply = ERROR_TEMPLATE.replace('{PLACEHOLDER}', formattedError)
this.message.reply(reply)
return
}
let reply = SUCCESS_TEMPLATE.replace('{PLACEHOLDER}', response.html_url)
this.message.reply(reply)
}
}
您必須在 Discord 應用程式中設定該機器人。
uj5u.com熱心網友回復:
也許請參閱創建問題的 GitHub API 檔案
您可能需要為它創建一個應用程式。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/361844.html
標籤:javascript github
上一篇:如何僅保留目錄樹中葉子的路徑?
