Example bots
Whole bots built with MeoCord, what each one shows and where the Guide teaches it, and how to run one.
Before this
The MeoCord examples repository holds whole bots, each created as a new app and grown from there. The Guide's examples show one piece at a time; a bot shows the pieces working together, with its tests. Every bot is tested on each change and daily, with the meocord version its lockfile pins and with the newest release, so a release that breaks one shows up there first.
Feedback
A feedback form a server's staff approve or reject. /feedback opens a form, once every five minutes for each member.
A submitted form is posted to a review channel with Approve and Reject buttons, which only members with the
staff role can use. A verdict marks the post, removes its buttons, and tells the author by direct message.
- A slash command that opens a modal, and the modal's fields arriving in the handler's params, in
feedback.controller.ts. See Modals. - A cooldown of five minutes per member, in
feedback.controller.ts. See Cooldowns. - Buttons routed by a typed custom ID,
feedback/{id:int}/approve, inreview.controller.ts. See Typed params. - A guard on a whole controller that denies with a reason, in
staff.guard.tsandreview.controller.ts. See Where guards apply and Refusing a call. @Defer, which acknowledges a click and locks the post until the verdict is in, inreview.controller.ts. See @Defer.- Answers through
respond(), and aUserErrorshown only to the user who clicked, infeedback.service.ts. See Answering with respond() and Exception filters and UserError. - A presenter that draws MeoCord's own loading and error views in the theme's colours, in
app.presenter.ts. See Drawing a view and Reading the theme. - Tests of the whole app through
MeoCordTestingModule.fromAppanddispatch, with mock members, infeedback.spec.ts. See Testing the whole app.
Besides its token, the bot needs a staff role, and a channel for reviews where it has View Channel, Send Messages and
Embed Links, since each review is posted as an embed. Their IDs go in .env as STAFF_ROLE_ID and
FEEDBACK_CHANNEL_ID, and the bot stops as it starts if either is missing or isn't an ID. Feedback is kept in memory,
so a restart forgets it, and a review button left from before the restart says the feedback is gone.
Running a bot
Every bot runs the same way, on Node.js 22.13 or later. It needs a bot token from the
Discord Developer Portal, and the bot invited to a server with the bot
and applications.commands scopes.
git clone https://github.com/meocord/examples.git
cd examples/feedback
npm ci
cp .env.example .env
npm run start:devSet DISCORD_TOKEN and the bot's own settings in .env, which git ignores; never commit a token.
The token and the test server covers .env and
DEV_GUILD_ID. npm run start:dev watches the code, rebuilding and restarting the bot on each change. npm test
runs the bot's tests with mock interactions, with no Discord connection or token, and npm run build:prod followed by
npm start runs it as it runs in production.