Skip to content

Commit

Permalink
Merge branch 'feat(create-robo)-no-credential-feature-' of https://gi…
Browse files Browse the repository at this point in the history
…thub.com/Wave-Play/robo.js into feat(create-robo)-no-credential-feature-
  • Loading branch information
Nazeofel committed Jun 3, 2024
2 parents b3ae1a1 + a1513f1 commit 07c7989
Show file tree
Hide file tree
Showing 21 changed files with 67 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"linked": [],
"access": "restricted",
"baseBranch": "main",
"ignore": ["@robojs/ai", "@robojs/ai-voice"]
"ignore": ["@robojs/ai-voice"]
}
5 changes: 5 additions & 0 deletions .changeset/lemon-gifts-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@robojs/sync': patch
---

patch: better support for non-tunneled localhost
12 changes: 4 additions & 8 deletions .github/workflows/publish-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,17 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- uses: pnpm/action-setup@v2.2.4
- uses: pnpm/action-setup@v4
with:
version: 8.6.11

- name: Read Node.js version to install from `.nvmrc`
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
id: nvm

- name: Install required Node.js version
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
cache: 'pnpm'
node-version: '${{ steps.nvm.outputs.NVMRC }}'
node-version: 20
registry-url: 'https://registry.npmjs.org'

- name: PNPM install
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,17 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- uses: pnpm/action-setup@v2.2.4
- uses: pnpm/action-setup@v4
with:
version: 8.6.11

- name: Read Node.js version to install from `.nvmrc`
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
id: nvm

- name: Install required Node.js version
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
cache: 'pnpm'
node-version: '${{ steps.nvm.outputs.NVMRC }}'
node-version: 20
registry-url: 'https://registry.npmjs.org'

# https://github.com/pnpm/pnpm/issues/1801
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/discord-bots/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Code for `playStatus.js`:
<TabItem value="js" label="Javascript">

```javascript title="src/events/ready/playStatus.js"
export default (_, _, client) => {
export default (client) => {
client.user.setActivity('with code')
}
```
Expand All @@ -59,7 +59,7 @@ export default (_, _, client) => {
```typescript title="src/events/ready/playStatus.ts"
import type { Client } from 'discord.js'

export default (_, _, client: Client) => {
export default (client: Client) => {
client.user.setActivity('with code')
}
```
Expand Down
6 changes: 6 additions & 0 deletions packages/create-robo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# create-robo

## 0.12.3

### Patch Changes

- d9419e3: feat(create-robo): `--no-creds` option

## 0.12.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/create-robo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-robo",
"version": "0.12.2",
"version": "0.12.3",
"private": false,
"description": "Launch epic projects instantly with Robo.js — effortless, powerful, complete!",
"engines": {
Expand Down
3 changes: 1 addition & 2 deletions packages/create-robo/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ new Command('create-robo <projectName>')
// Ask the user for their Discord credentials (token and client ID) and store them for later use
// Skip this step if the user is creating a plugin
//

if (!robo.isPlugin && !options.creds) {
if (!robo.isPlugin && options.noCreds) {
logger.debug(`Asking for Discord credentials...`)
await robo.askForDiscordCredentials()
}
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-ai-voice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"peerDependencies": {
"@discordjs/voice": "^0.16.0",
"@robojs/ai": "^0.5.3",
"@robojs/ai": "^0.5.4",
"robo.js": "^0.10.9"
},
"peerDependenciesMeta": {
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-ai/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @roboplay/plugin-ai

## 0.5.4

### Patch Changes

- 99eb54a: patch: support for newer server plugin versions

## 0.5.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-ai/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@robojs/ai",
"description": "Transform your Robo into a personalized AI chatbot! Supports Discord command execution.",
"version": "0.5.3",
"version": "0.5.4",
"private": false,
"type": "module",
"main": ".robo/build/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-ai/src/api/ai/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ interface ApiChatResponse {
message: string
}

export default (req: RoboRequest<ApiChatRequest>): Promise<ApiChatResponse> => {
export default (req: RoboRequest): Promise<ApiChatResponse> => {
return new Promise((resolve, reject) => {
const run = async () => {
const { messages } = req.body
const { messages } = (await req.json()) as ApiChatRequest
if (!messages?.length) {
return reject('No message provided')
}
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-sync/src/core/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ function setupSyncState() {
}

isRunning.current = true
const websocket = new WebSocket(`wss://${location.host}/sync`)
const wsProtocol = location.protocol === 'http:' ? 'ws' : 'wss'
const websocket = new WebSocket(`${wsProtocol}://${location.host}/sync`)

websocket.onopen = () => {
console.log('Connection established at', new Date().toISOString())
Expand Down
16 changes: 8 additions & 8 deletions templates/starter-app-js-react/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions templates/starter-app-js-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
},
"dependencies": {
"@discord/embedded-app-sdk": "^1.1.2",
"@robojs/server": "^0.4.2",
"@robojs/server": "^0.5.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"robo.js": "^0.10.4"
"robo.js": "^0.10.9"
},
"devDependencies": {
"@vitejs/plugin-react-swc": "^3.6.0",
Expand Down
4 changes: 3 additions & 1 deletion templates/starter-app-js-react/src/api/token.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default async (req) => {
const { code } = await req.json()

// Exchange the code for an access_token
const response = await fetch(`https://discord.com/api/oauth2/token`, {
method: 'POST',
Expand All @@ -9,7 +11,7 @@ export default async (req) => {
client_id: process.env.VITE_DISCORD_CLIENT_ID,
client_secret: process.env.DISCORD_CLIENT_SECRET,
grant_type: 'authorization_code',
code: req.body.code
code: code
})
})
const { access_token } = await response.json()
Expand Down
4 changes: 2 additions & 2 deletions templates/starter-app-js-react/src/hooks/useDiscordSdk.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export async function authenticateSdk(options) {
}

export function useDiscordSdkSetup(options) {
const { authenticate } = options ?? {}
const { authenticate, scope } = options ?? {}
const [accessToken, setAccessToken] = useState(null)
const [session, setSession] = useState(null)
const [error, setError] = useState(null)
Expand All @@ -159,7 +159,7 @@ export function useDiscordSdkSetup(options) {

if (authenticate) {
setStatus('authenticating')
const { accessToken, auth } = await authenticateSdk()
const { accessToken, auth } = await authenticateSdk({ scope })
setAccessToken(accessToken)
setSession(auth)
}
Expand Down
16 changes: 8 additions & 8 deletions templates/starter-app-ts-react/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions templates/starter-app-ts-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
},
"dependencies": {
"@discord/embedded-app-sdk": "^1.1.2",
"@robojs/server": "^0.4.2",
"@robojs/server": "^0.5.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"robo.js": "^0.10.4"
"robo.js": "^0.10.9"
},
"devDependencies": {
"@swc/core": "^1.4.15",
Expand Down
6 changes: 4 additions & 2 deletions templates/starter-app-ts-react/src/api/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ interface RequestBody {
code: string
}

export default async (req: RoboRequest<RequestBody>) => {
export default async (req: RoboRequest) => {
const { code } = await req.json() as RequestBody

// Exchange the code for an access_token
const response = await fetch(`https://discord.com/api/oauth2/token`, {
method: 'POST',
Expand All @@ -15,7 +17,7 @@ export default async (req: RoboRequest<RequestBody>) => {
client_id: process.env.VITE_DISCORD_CLIENT_ID!,
client_secret: process.env.DISCORD_CLIENT_SECRET!,
grant_type: 'authorization_code',
code: req.body.code
code: code
})
})
const { access_token } = await response.json()
Expand Down
4 changes: 2 additions & 2 deletions templates/starter-app-ts-react/src/hooks/useDiscordSdk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ interface UseDiscordSdkSetupOptions {
}

export function useDiscordSdkSetup(options?: UseDiscordSdkSetupOptions) {
const { authenticate } = options ?? {}
const { authenticate, scope } = options ?? {}
const [accessToken, setAccessToken] = useState<string | null>(null)
const [session, setSession] = useState<DiscordSession | null>(null)
const [error, setError] = useState<string | null>(null)
Expand All @@ -185,7 +185,7 @@ export function useDiscordSdkSetup(options?: UseDiscordSdkSetupOptions) {

if (authenticate) {
setStatus('authenticating')
const { accessToken, auth } = await authenticateSdk()
const { accessToken, auth } = await authenticateSdk({ scope })
setAccessToken(accessToken)
setSession(auth)
}
Expand Down

0 comments on commit 07c7989

Please sign in to comment.