In-Game Bug Reports
A bug report form inside the game: players type /bugreport, and the report, game log and screenshot go to your pack's own site.
介绍
Report bugs without leaving the game
In-Game Bug Reports gives your modpack a bug report form inside Minecraft. Players type /bugreport (or press a key they pick in Controls), describe what happened, and send it. The end of their game log and their latest screenshot can come along, and they can report anonymously.
- Works for any pack: you set where reports go, what players can pick, and what’s attached.
- No secrets in your pack. The mod has no addresses or keys of its own, and it refuses Discord webhooks and GitHub tokens in its settings, because every player can read that file.
- Free to run: reports can go to your Discord channel through a free Cloudflare Worker (below), or to any website you already have.
- Client only. Servers don’t need it.
Setting it up (for pack authors)
Change the settings in config/ingamebugreports-client.toml (or in game: Mods, In-Game Bug Reports, Config) and ship that file with your pack. Until you do, /bugreport just says bug reports aren’t set up.
Pick one:
- Easiest, no server at all: set
formUrlto any web form, like a Google Form or your GitHub issues page./bugreportopens it in the browser. - The in-game form: set
reportUrlto an HTTPS address that takes the reports, for example the free Cloudflare Worker below. If that address can’t be reached, players are offeredformUrlinstead.
Settings
| Setting | What it does |
|---|---|
reportUrl |
Where the in-game form sends reports (HTTPS). Empty: only formUrl is used. |
formUrl |
A web page with a report form, opened in the browser when there’s no reportUrl or it can’t be reached. |
packName, packVersion |
Shown on the form and sent with each report, so you know which build it came from. |
types |
What players can send, like ["Bug report", "Suggestion"]. Empty: no choice. |
categories |
What a report is about, picked from a list, like ["Crash", "Quests", "Other"]. Empty: no list. |
allowAnonymous |
Shows "Report anonymously": their name is left out of the report and its log. |
attachLog |
Sends the end of logs/latest.log (up to 512 KB). |
allowScreenshot |
Offers to attach their latest screenshot (F2). |
minLength |
The fewest characters a description needs. |
command |
The chat command (default bugreport). |
Free report receiver: a Cloudflare Worker that posts to Discord
Your Discord webhook stays in Cloudflare, where players can’t see it. Cloudflare’s free plan allows 100,000 requests a day.
- Discord: in your bug channel’s settings, open Integrations, then Webhooks, then New Webhook, and click Copy Webhook URL.
- Cloudflare (free account at dash.cloudflare.com): go to Workers & Pages, click Create, then "Start with Hello World", name it (for example
my-pack-bugs) and click Deploy. - Click Edit code, replace everything with the script below, and click Deploy.
- In the Worker’s Settings, under Variables and Secrets, click Add: type Secret, name
DISCORD_WEBHOOK, and paste your webhook as the value. Click Deploy. - Optional: add a Text variable
PACKwith yourpackName, so the Worker only takes your pack’s reports. - Put the Worker’s address (it ends in
.workers.dev) inreportUrl.
// In-Game Bug Reports: a free report receiver (Cloudflare Worker).
// It takes the mod's reports and posts each one to your Discord channel, with the game log and the
// screenshot. Your Discord webhook stays in the Worker's settings (DISCORD_WEBHOOK), so players
// never see it. Optional setting PACK: only take reports whose pack name matches.
export default {
async fetch(request, env) {
if (request.method !== "POST") return answer({ error: "This address takes bug reports from the game." }, 405);
if (!env.DISCORD_WEBHOOK) return answer({ error: "This report site isn't set up yet." }, 500);
if (Number(request.headers.get("Content-Length") || 0) > 4 * 1024 * 1024) return answer({ error: "That report is too big." }, 413);
let form;
try {
form = await request.formData();
} catch (e) {
return answer({ error: "That isn't a bug report." }, 400);
}
const field = (name, max) => String(form.get(name) ?? "").trim().slice(0, max);
const note = field("note", 4000);
if (!note) return answer({ error: "Please describe what happened." }, 400);
if (env.PACK && field("pack", 100) !== env.PACK) return answer({ error: "This site takes reports for another pack." }, 403);
const id = Date.now().toString(36).slice(-6) + Math.random().toString(36).slice(2, 5);
const who = form.get("anon") === "1" ? "Anonymous" : field("player", 60) || "someone";
const info = [["Pack", "pack"], ["Version", "version"], ["About", "category"]]
.map(([label, name]) => field(name, 100) && `${label}: ${field(name, 100)}`).filter(Boolean).join(" · ");
const head = `**${field("kind", 40) || "Bug report"}** from **${who}** (#${id})\n${info ? info + "\n" : ""}`;
const out = new FormData();
// allowed_mentions: a report can't ping @everyone or anyone else.
out.append("payload_json", JSON.stringify({ content: (head + note).slice(0, 2000), allowed_mentions: { parse: [] } }));
const log = form.get("log"), shot = form.get("screen");
if (log && typeof log === "object" && log.size) out.append("files[0]", log.slice(Math.max(0, log.size - 512 * 1024)), "log.txt");
if (shot && typeof shot === "object" && shot.size && shot.size <= 2 * 1024 * 1024) out.append("files[1]", shot, "screen.jpg");
const sent = await fetch(env.DISCORD_WEBHOOK, { method: "POST", body: out });
if (!sent.ok) return answer({ error: "The report couldn't be delivered. Please try again later." }, 502);
return answer({ ok: true, id });
},
};
function answer(body, status = 200) {
return new Response(JSON.stringify(body), { status, headers: { "Content-Type": "application/json" } });
}
Using your own website
The mod sends a normal web form (multipart/form-data) to reportUrl with these fields: note, kind, category, where, version, pack, player, anon (1 when anonymous) and the files log (log.txt) and screen (screen.jpg). Answer with JSON: {"id": "..."} when it worked, or {"error": "..."}, which the player sees.
Limits
One report a minute per player. Logs up to 512 KB, screenshots under 2 MB (made smaller to fit).
MIT licence.
常见问题
In-Game Bug Reports 支持哪些 Minecraft 版本?
In-Game Bug Reports 支持 Minecraft Java 版 1.21.1,可用的加载器:NeoForge。下载时注意选择和你游戏版本一致的文件。
In-Game Bug Reports 怎么安装?
先用 PCL2 或 HMCL 启动器安装对应版本的 NeoForge,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。
评论
登录后评论和评分