forked from benawad/dogehouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request benawad#2752 from TheOtterlord/staging
[KEBAB] add example to create bot
- Loading branch information
Showing
11 changed files
with
10,212 additions
and
22,155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# An example bot | ||
1. Put your access- and refresh-token in `.env` (`DOGEHOUSE_TOKEN`, `DOGEHOUSE_REFRESH_TOKEN`) | ||
1. Put your bot's api key in `.env` as `DOGEHOUSE_API_KEY` | ||
2. Build the API package: `$ yarn` and `$ yarn build` in kebab's root directory | ||
3. Build the example: `$ npm i` and `$ npm run build` | ||
4. `$ npm start` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# An script to create a bot account | ||
1. Put your access and refresh-token in `.env` (`DOGEHOUSE_TOKEN`, `DOGEHOUSE_REFRESH_TOKEN`) | ||
2. Choose your bot's username and place it in `.env` as `DOGEHOUSE_BOT_NAME` | ||
3. Build the API package: `$ yarn` and `$ yarn build` in kebab's root directory | ||
4. Build the example: `$ npm i` and `$ npm run build` | ||
5. `$ npm start` | ||
6. Save the api key printed to the screen in a safe place to later use with your bot. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "create-bot", | ||
"private": true, | ||
"scripts": { | ||
"build": "tsc", | ||
"start": "node build/index.js" | ||
}, | ||
"dependencies": { | ||
"@dogehouse/kebab": "file:../..", | ||
"@types/node": "^14.14.35" | ||
}, | ||
"devDependencies": { | ||
"dotenv": "^8.2.0", | ||
"typescript": "^4.2.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require("dotenv").config(); | ||
|
||
import { raw, wrap } from "@dogehouse/kebab"; | ||
|
||
const main = async () => { | ||
try { | ||
const wrapper = wrap(await raw.connect( | ||
process.env.DOGEHOUSE_TOKEN!, | ||
process.env.DOGEHOUSE_REFRESH_TOKEN!, | ||
{ | ||
onConnectionTaken: () => { | ||
console.error("\nAnother client has taken the connection"); | ||
process.exit(); | ||
} | ||
} | ||
)); | ||
|
||
wrapper.mutation.userCreateBot(process.env.DOGEHOUSE_BOT_NAME!).then(res => { | ||
console.log(res) | ||
}).catch(err => { | ||
console.error(err) | ||
}) | ||
} catch (e) { | ||
if (e.code === 4001) console.error("invalid token!"); | ||
console.error(e) | ||
} | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "commonjs", | ||
"outDir": "./build", | ||
"strict": true, | ||
"lib": ["DOM", "ES6"], | ||
"esModuleInterop": true, | ||
"skipLibCheck": true | ||
}, | ||
"include": ["src"], | ||
"exclude": ["node_modules"] | ||
} |
Oops, something went wrong.