A Discord bot that responds with one of three random pre-programmed messages when a user types /ticket.
main.tsā HTTP endpoint that receives Discord interactions (slash commands) and replies with a random messageregister-command.tsā One-time script that registers the/ticketslash command with Discord
Go to https://discord.com/developers/applications and create a new application.
On the General Information tab, copy the Public Key.
On the Bot tab, copy the Token.
Add these two env vars to this val:
š Add discordBotToken here: https://www.val.town/x/spiderjeremy/Nevermindthisonewillwork/environment-variables?key=discordBotToken
š Add discordPublicKey here: https://www.val.town/x/spiderjeremy/Nevermindthisonewillwork/environment-variables?key=discordPublicKey
On the General Information tab in the Discord Developer Portal, scroll to Interactions Endpoint URL and paste your val's HTTP URL:
https://spiderjeremy--d99e2e9c7cb611f1b7bb1607ee4eb77e.web.val.run
Click Save Changes ā Discord will send a PING to verify the endpoint is alive.
Run register-command.ts once (via the Val Town UI or API) to register the /ticket command.
On the OAuth2 tab, use the URL Generator:
- Select bot scope
- Give it Send Messages permission
- Open the generated URL and add the bot to your server
Type /ticket in any channel your bot can see. You'll get one of three random replies!
Edit the REPLIES array at the top of main.ts:
const REPLIES = [
"š« Thanks for opening a ticket! A team member will be with you shortly.",
"šļø Your ticket has been received! Hang tight while we look into it.",
"š Ticket opened! We'll get back to you as soon as possible.",
];