-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98492ee
commit 53026d1
Showing
13 changed files
with
726 additions
and
6 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 |
---|---|---|
|
@@ -3,4 +3,5 @@ dist | |
.turbo | ||
.pnpm-store | ||
.env | ||
./docs | ||
./docs | ||
wrangler.toml |
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
"biomejs", | ||
"Buape", | ||
"carbonjs", | ||
"Cloudo", | ||
"hono", | ||
"Rocko", | ||
"whatwg" | ||
|
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,3 @@ | ||
# Cloudo | ||
|
||
Cloudo is our test bot that runs on CF workers, to test that Carbon functions correctly. |
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,18 @@ | ||
{ | ||
"name": "cloudo", | ||
"version": "0.0.0", | ||
"type": "module", | ||
"main": "./dist/src/index.js", | ||
"scripts": { | ||
"build": "wrangler deploy", | ||
"dev": "wrangler deploy && wrangler tail" | ||
}, | ||
"dependencies": { | ||
"@buape/carbon": "workspace:*" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@cloudflare/workers-types": "^4.20240502.0", | ||
"wrangler": "3.53.1" | ||
} | ||
} |
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,11 @@ | ||
import { Command, type CommandInteraction } from "@buape/carbon" | ||
|
||
export default class PingCommand extends Command { | ||
name = "ping" | ||
description = "A simple ping command" | ||
defer = true | ||
|
||
async run(interaction: CommandInteraction) { | ||
interaction.reply({ content: "Pong <:caughtIn4k:1145473115703496816>" }) | ||
} | ||
} |
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,38 @@ | ||
import { | ||
Button, | ||
type ButtonInteraction, | ||
ButtonStyle, | ||
Command, | ||
type CommandInteraction, | ||
LinkButton, | ||
Row | ||
} from "@buape/carbon" | ||
|
||
export default class ButtonCommand extends Command { | ||
name = "button" | ||
description = "A simple command with a button!" | ||
defer = true | ||
|
||
async run(interaction: CommandInteraction) { | ||
interaction.reply({ | ||
content: "Pong <:caughtIn4k:1145473115703496816>", | ||
components: [new Row([new PingButton(), new Link()])] | ||
}) | ||
} | ||
} | ||
|
||
class PingButton extends Button { | ||
customId = "ping" | ||
label = "Ping" | ||
style = ButtonStyle.Primary as typeof Button.prototype.style | ||
|
||
async run(interaction: ButtonInteraction) { | ||
interaction.reply({ content: "OMG YOU CLICKED THE BUTTON" }) | ||
} | ||
} | ||
|
||
class Link extends LinkButton { | ||
label = "Link" | ||
style = ButtonStyle.Link as typeof Button.prototype.style | ||
url = "https://google.com" | ||
} |
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,27 @@ | ||
import { | ||
type APIApplicationCommandBasicOption, | ||
ApplicationCommandOptionType, | ||
Command, | ||
type CommandInteraction | ||
} from "@buape/carbon" | ||
|
||
export default class Options extends Command { | ||
name = "options" | ||
description = "Options test" | ||
defer = true | ||
|
||
options: APIApplicationCommandBasicOption[] = [ | ||
{ | ||
name: "str", | ||
type: ApplicationCommandOptionType.String, | ||
description: "DESCRIPTION", | ||
required: true | ||
} | ||
] | ||
|
||
async run(interaction: CommandInteraction) { | ||
interaction.reply({ | ||
content: `${interaction.options.str}` | ||
}) | ||
} | ||
} |
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,32 @@ | ||
import type { ExecutionContext } from "@cloudflare/workers-types/2023-07-01" | ||
import { Client, ClientMode } from "@buape/carbon" | ||
|
||
import ButtonCommand from "./commands/testing/button.js" | ||
import Options from "./commands/testing/options.js" | ||
import PingCommand from "./commands/ping.js" | ||
|
||
type Env = { | ||
CLIENT_ID: string | ||
PUBLIC_KEY: string | ||
DISCORD_TOKEN: string | ||
} | ||
|
||
export default { | ||
async fetch(request: Request, env: Env, ctx: ExecutionContext) { | ||
const client = new Client( | ||
{ | ||
clientId: env.CLIENT_ID, | ||
publicKey: env.PUBLIC_KEY, | ||
token: env.DISCORD_TOKEN, | ||
mode: ClientMode.CloudflareWorkers | ||
}, | ||
[new ButtonCommand(), new Options(), new PingCommand()] | ||
) | ||
if (request.url.endsWith("/deploy")) { | ||
await client.deployCommands() | ||
return new Response("Deployed commands") | ||
} | ||
ctx.waitUntil(client.router.fetch(request)) | ||
return new Response("OK") | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"include": ["src/**/*.ts", "src/*.ts"], | ||
"compilerOptions": { | ||
"outDir": "./dist", | ||
"rootDir": ".", | ||
"types": ["@cloudflare/workers-types"] | ||
} | ||
} |
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,8 @@ | ||
name = "carbon-test" | ||
main = "src/index.ts" | ||
compatibility_date = "2023-03-20" | ||
|
||
[vars] | ||
CLIENT_ID = "" | ||
PUBLIC_KEY = "" | ||
DISCORD_TOKEN = "" |
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
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
Oops, something went wrong.