Keep the slash command list in one module, and test that `/help` and the registered commands match
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- nodejs, typescript
Hướng nghiên cứu
Start by copying scripts/register-commands.mjs and printing JSON.stringify(commands, null, 2) with and without LINK_PREVIEW=1 to snapshot current output. Then extract lines 23-107 into slashCommands(vars, { preview }) in a new scripts/commands.ts, reading vars the way test/config.test.ts (line 9) reads wrangler.jsonc, and compare against helpReply in src/messages.ts (line 377) and runCommand in src/commands.ts (line 28). Write test/commands.test.ts covering parity, descriptions, dispatch and Discord limits, modelled on test/help.test.ts. Done when the diff against the snapshot is empty, deleting a helpReply line fails a test, and npm run typecheck plus npm test pass.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
The slash commands are written down in three places that have to agree:
scripts/register-commands.mjs(lines 23 to 107) builds what Discord shows: names, descriptions, options and choiceshelpReplyinsrc/messages.ts(line 377) types the names and descriptions out againrunCommandinsrc/commands.ts(line 28) handles them, and the comment at the top of that file says "keep the two in sync"
They match today, but nothing checks it. The register script builds the list and sends it to Discord in the same file, at the top level, so a test can't get at the list without making the request. A new command or a reworded description can drift apart, and nobody notices until someone reads /help in the server.
What to do
- Move the list into a function a test can import, for example
slashCommands(vars, { preview })inscripts/commands.ts, built from the samewrangler.jsoncvars.register-commands.mjsthen only reads the config, calls it and sends the result. It already imports./jsonc.ts, so a.tsimport works there. - Add tests, for example in a new
test/commands.test.ts, that check:- with
LINKINGon and off, the registered names and the/helpnames are the same and in the same order - each
/helpdescription is the registered description with a period at the end (they all are today) runCommandanswers every registered name with something other than "I don't know that command."- Discord's limits: names match
^[-_a-z0-9]{1,32}$, command and option descriptions are 1 to 100 characters, and required options come before optional ones
- with
Where to look
scripts/register-commands.mjsandscripts/jsonc.tstest/config.test.ts(line 9) readswrangler.jsoncthe same way the script doestest/help.test.tsfor how/helpis checked now
Acceptance criteria
-
npm run registersends the same JSON as before for ourwrangler.jsonc - The tests above, which fail if a command is missing from
/helpor a description changes in only one place -
npm run typecheckandnpm testpass
How to test
Before changing anything, make a local copy of the script that prints JSON.stringify(commands, null, 2) instead of sending it (with and without LINK_PREVIEW=1), and save the output. Do the same after the change and diff the two. You don't need a Discord token for this. Then break things on purpose: drop a line from helpReply, or change one description in the new module only, and check that a test fails each time.
Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off develop, and open your PR against develop with Closes #154 in the description.
- Ngôn ngữ chính
- TypeScript
- Star
- 0
- Fork
- 1
- Merge trung bình
- 2 giờ 38 phút
- Pull request đã merge (30 ngày)
- 73
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của codercops/discord-bot
-
`/leaderboard`, the page and the share image say "be the first" for a program that hasn't startedĐang mởbug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
codercops/discord-bot#152 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
codercops/discord-bot#108 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement help wanted
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 74/100
codercops/discord-bot#153 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Contributing to discord-bot: start hereCó thể làm lại được @sank8-2 đã nhận 21 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 15/100
codercops/discord-bot#15 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của codercops/discord-bot
Issue tương tự
-
Out of order / duplicate key error shows the key bytes as decimal or UTF-8, not hexCó thể đã có người làm @bardrop đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
-
bug i18n
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
endora-commerce/endora-commerce#1315 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Two stored artist rows are not act names: "DJS" from a Renate floor heading and "Stevie Cox -"Đang mởarea:data-quality importer size:S
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
enorm-labs/event-junkie#5136 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
fix(scripts): set-device-owner.ps1 fails to parse on Windows PowerShell 5.1 (UTF-8 without BOM)Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
WenyuChiou/agent-board#1518 ·
Maintainer thường phản hồi trong vòng 1 ngày