Skip to content

Commit

Permalink
chore(template): music player proxy example
Browse files Browse the repository at this point in the history
  • Loading branch information
Pkmmte committed Jun 17, 2024
1 parent dfc4180 commit 2cd1c4f
Show file tree
Hide file tree
Showing 23 changed files with 3,491 additions and 0 deletions.
30 changes: 30 additions & 0 deletions templates/discord-activities/music-player-proxy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# robo.js
.robo/*

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env
.env*.local

# typescript
*.tsbuildinfo
.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
printWidth: 120,
semi: false,
singleQuote: true,
trailingComma: 'none',
tabWidth: 2,
useTabs: true
}
110 changes: 110 additions & 0 deletions templates/discord-activities/music-player-proxy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<p align="center">✨ <strong>Generated with <a href="https://roboplay.dev/create-robo">create-robo</a> magic!</strong> ✨</p>

---

# Hiya, discord-activity-proxy 🌈

Welcome to your fresh **[Robo.js](https://github.com/Wave-Play/robo)** project!

Build, deploy, and maintain your Discord activities with ease. With Robo.js as your guide, you'll experience a seamless, [file-based setup](https://docs.roboplay.dev/docs/basics/overview#the-robojs-file-structure), an [integrated database](https://docs.roboplay.dev/docs/basics/flashcore), [TypeScript support](https://docs.roboplay.dev/docs/advanced/typescript), and a multitude of [plugin-powered skills](https://docs.roboplay.dev/docs/advanced/plugins) to unlock along the way.

Ready to embark on this adventure?

[📖 **Tutorial:** Creating a Discord Activity in seconds](https://dev.to/waveplay/how-to-build-a-discord-activity-easily-with-robojs-5bng)

[📚 **Documentation:** Getting started](https://docs.roboplay.dev/docs/getting-started)

[🚀 **Community:** Join our Discord server](https://roboplay.dev/discord)

## Running 🏃‍♂️

Run development mode with:

```bash
npm run dev
```

Your Robo refreshes with every change. 🔄

A free Cloudflare tunnel is included for easy testing. You can copy and paste it into activity's URL mapping to test things out.

> **Psst...** Check out the [deployment instructions](#deployment) to keep your Robo online 24/7.
## App Development 🛠️

You can find your client-side code in the `/src/app` folder. This is where you can build your web app using React, Vue, or any other front-end framework.

Things are powered by Vite under the hood, so you get the latest ES modules, hot module reloading, and more! ⚡

Try editing the `main` file to get started! (`Activity.tsx` if you're using React)

**** [📚 **Documentation:** App development](https://docs.roboplay.dev/docs/app/overview)

#### Authenticating

The React template makes it easy to authenticate your activity with Discord. The `<DiscordProvider>` components in `App.tsx` accepts `authenticate` and `scope` props.

```tsx
<DiscordContextProvider authenticate scope={['identify', 'guilds']}>
<Activity />
</DiscordContextProvider>
```

You can then get the SDK and other goodies from the `useDiscordSdk` hook!

## Backend Development 🛠️

Your server-side code is located in the `/src/api` folder. This is where you can build your API, webhooks, and other fancy server-side features.

This backend is powered by the [**Server Plugin**](https://github.com/Wave-Play/robo.js/tree/main/packages/plugin-api) - a powerful Robo plugin that creates an manages a Node `http` server for you. If you install Fastify, the server will automatically switch to it for better performance!

Everything Robo is file-based, so you can create new routes by making new files in the `/src/api` directory. The file's name becomes the route's path. For example, let's try making a new route at `/health` by creating a new file named `health.js`:

```js
export default () => {
return { status: 'ok' }
}
```

Easy, right? Check out the [**Server Plugin documentation**](https://github.com/Wave-Play/robo.js/tree/main/packages/plugin-api) for more info!

## Folder Structure 📁

While the `api` and `app` folders are reserved for your server and client-side code, you are free to create anything else in the `/src` directory!

Folders only become reserved when you install a plugin that uses them. For example, bot functionality uses the `commands` and `events` folders.

## Plugins 🔌

This Robo boasts an intuitive plugin system that grants new capabilities instantly!

```bash
npx robo add @robojs/ai
```

> Swap out [`@robojs/ai`](https://github.com/Wave-Play/robo.js/tree/main/packages/plugin-ai) with your chosen plugin's package name
With that, your Robo automatically equips itself with all the features the plugin offers. Want to revert? Simply use [`robo remove`](https://docs.roboplay.dev/docs/advanced/command-line#plugins) to uninstall any plugin.

**** [📚 **Documentation:** Installing plugins](https://docs.roboplay.dev/docs/advanced/plugins#installing-plugins)

Crafting something unique in your Robo project? You can turn your innovations into plugins, be it specific functionalities or your entire Robo. Share your genius with the world!

**** [📚 **Documentation:** Creating plugins](https://docs.roboplay.dev/docs/advanced/plugins#creating-plugins)

## Deployment 🚀

Run the `deploy` command to automatically deploy to **[RoboPlay](https://roboplay.dev)** once you're ready to keep your robo online 24/7.

```bash
npm run deploy
```

**** [🚀 **RoboPlay:** Hosting your Robo](https://docs.roboplay.dev/docs/hosting)

You can also self-host your robo anywhere that supports Node. Just make sure to run `build` followed by `start`:

```bash
npm run build
npm start
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
cors: true
}
15 changes: 15 additions & 0 deletions templates/discord-activities/music-player-proxy/config/robo.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// @ts-check

/**
* @type {import('robo.js').Config}
**/
export default {
experimental: {
disableBot: true
},
plugins: [],
type: 'robo',
watcher: {
ignore: ['src/app', 'src/components', 'src/hooks']
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()]
})
9 changes: 9 additions & 0 deletions templates/discord-activities/music-player-proxy/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export {}
declare global {
namespace NodeJS {
interface ProcessEnv {
DISCORD_CLIENT_ID: string
DISCORD_CLIENT_SECRET: string
}
}
}
5 changes: 5 additions & 0 deletions templates/discord-activities/music-player-proxy/example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DISCORD_CLIENT_ID=""
VITE_DISCORD_CLIENT_ID=""
DISCORD_CLIENT_SECRET=""
NODE_OPTIONS="--enable-source-maps"
PORT="3000"
13 changes: 13 additions & 0 deletions templates/discord-activities/music-player-proxy/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hello, World | Powered by Robo.js</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/app/index.tsx"></script>
</body>
</html>
Loading

0 comments on commit 2cd1c4f

Please sign in to comment.