This is a library for interfacing with bag
programmatically! This is useful if you want to build cool stuff with bag
, not just in the Slack but outside of Slack too. No ideas? Here are some:
bag
universeGetting started is pretty easy! All you have to do is install @hackclub/bag
and start playing around with it. For a good intro to building a Slack bot, but more generally how to get started, check out Building a store bot and the quick run through below.
Go to the Hack Club Slack, and run /bot
to create a app. You'll get asked a few questions:
By default, your app only has READ permissions, which means it can read any data that's public. Here's a quick reference of all the permissions:
There are most likely gaps in this permission model, but if a creator is abusing apps, then we'll have to revoke their app token.
After you create an app, you'll receive a message like this:
orpheus' store created, your app ID is 12 and your app token is 1ffdfdee-9c29-4893-b010-5927d2b940c4. (Don't share it with anyone unless they're also working on the app!) Your app can: read public inventory items.
To edit your app/request a permission level, run /bot orpheus' store.
You'll need the app ID and token to be able to use your app.
To view a app, simply run /bot <name>
. If you created the app, you'll also have access to some other options:
To request a permission, click on Edit > Select a permission level, and you can request a permission level that we'll approve first. (It'll be fast, I promise!)
Create a folder and run the following inside:
npm init -y
npm i @hackclub/bag dotenv
Create two files, .env
and index.js
. In .env
:
BAG_APP_ID=<your app ID>
BAG_APP_KEY=<your app key>
Here's some boilerplate index.js
code:
const { App } = require('@hackclub/bag')
require('dotenv').config()
async function main() {
const app = await App.connect({
appId: Number(process.env.BAG_APP_ID),
key: process.env.BAG_APP_TOKEN
})
console.log(app)
}
main()
Have fun and be hacky!