diff options
author | 2022-07-05 11:23:40 -0400 | |
---|---|---|
committer | 2022-07-05 09:26:58 -0700 | |
commit | 4a927e09b7cb3c22560599184c675bb185535f60 (patch) | |
tree | 8666d315b2d389a9cf9ace02e2c9b7ed83abeadb /examples/discord-interactions/run.js | |
parent | a577e3507fadc5822e060ee3a8894d4d60b45e49 (diff) | |
download | bun-4a927e09b7cb3c22560599184c675bb185535f60.tar.gz bun-4a927e09b7cb3c22560599184c675bb185535f60.tar.zst bun-4a927e09b7cb3c22560599184c675bb185535f60.zip |
discord interactions template
Diffstat (limited to 'examples/discord-interactions/run.js')
-rw-r--r-- | examples/discord-interactions/run.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/discord-interactions/run.js b/examples/discord-interactions/run.js new file mode 100644 index 000000000..749a039d6 --- /dev/null +++ b/examples/discord-interactions/run.js @@ -0,0 +1,21 @@ +// polyfill v8 and node (TODO: fix in bun) +import './polyfill.js'; + +import path from 'node:path'; +import { BunServer, BunSlashCreator } from './bun_shim/index.js'; + +const client = new BunSlashCreator({ + token: process.env.DISCORD_BOT_TOKEN, + publicKey: process.env.DISCORD_PUBLIC_KEY, + applicationID: process.env.DISCORD_APP_ID, +}); + +// client.on('debug', console.log); +client.on('error', console.error); + +client.withServer(new BunServer()); +client.registerCommandsIn(path.join(__dirname, 'commands')).syncCommands(); + +await client.server.listen(1337); + +// client.server.stop(); // stop server
\ No newline at end of file |