Skip to content

Commit

Permalink
merge discord.sc
Browse files Browse the repository at this point in the history
  • Loading branch information
Sup2point0 authored Mar 4, 2024
1 parent dea7183 commit 4bfba36
Show file tree
Hide file tree
Showing 16 changed files with 865 additions and 0 deletions.
3 changes: 3 additions & 0 deletions discord/disflux/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `disflux`

All Discord-related errors.
43 changes: 43 additions & 0 deletions discord/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# discord.sc 1.2

An endorsed supcode extension for interacting with the [Discord API](https://discord.com/developers/docs), specifically for creating bots.


## Subextensions

### [`slash`](slash)
Slash commands implementation and functionality.


## Intrinsics

### [`disflux`](disflux)
Discord-specific errors.


## Quick Specimen
Here’s a quick showcase of a simple Discord bot:

```coffee
spec code { ver = 5.6 | syn = utinax | sty = stan }

activate discord { ver = 1.2 }

create discord.bot('demo') [token = discord.token('dQw4w9WgXcQ')] {
create discord.command 'sup' {
define demo.sup(ctx) {
ctx.reply("sup")
}
}
}

demo.start()
```

Many more examples can be found in [specimens](specimens).


## Syntax
discord.sc encourages an object-oriented syntax style, although supports various others too.

Throughout this repository all code blocks will use CoffeeScript syntax highlighting, which is highly flexible and perfect for adding contrast, while not (significantly) disrupting or detracting from any semantics of the code.
3 changes: 3 additions & 0 deletions discord/slash/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `slash`

A subextension implementing slash command functionality.
60 changes: 60 additions & 0 deletions discord/slash/structs/option.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# `option`

A slash command option.

```coffee
struct 'option' {
str 'name'
str 'description'
type, pool, dict 'options'
var 'default'
bool 'autocomplete'
bool 'required'

num 'min'
num 'max'
}
```


<br>


## Properties

| property | aliases | type | description |
| :------- | :------ | :--- | :---------- |
| `name` | | `str` | The displayed name of the option. |
| `description` | `desc` | `str` | The description of the option. |
| `options` | `choices` | `type`, `pool`, `dict` | The collection of options that can be selected. |
| `default` | | `slot`, variable | The option selected by default. |
| `autocomplete` | `autofill`, `auto` | `bool` | |
| `required` | `req` | `bool` | |
| `min` | | `num` | |
| `max` | | `num` | |


<br>


## Functions

| function | output | description |
| :------- | :----- | :---------- |
| [`create`](create) | [`slash.option`](#option) | Creates a slash option. |

### `create`
Creates a slash option.

```coffee
func[evo] create(ctx) [
| name = default
| description = none
| options = none
| default = none
| autocomplete = false
| required = true
| min = none
| max = none
]
```
9 changes: 9 additions & 0 deletions discord/source/colour.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# `colour`

A collection of Discord-specific colours.

```coffee
class 'col', 'color', 'colour' {
'blurple' = 0x5865f2
}
```
22 changes: 22 additions & 0 deletions discord/source/functions/mention.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## `mention`
Mentions a particular Discord component.

```coffee
func 'mention'(object 'target' = none) {

}
```

### Inputs
| input | default | type | description |
| :---- | :------ | :--- | :---------- |
| `object` | `self`

### Example
```coffee
set 'channel' = discord.channel(...)
set 'ping' = discord.mention(discord.user(...))
set 'message' = "sup `ping`, you’re in `mention(channel)`­­"

channel.send(message)
```
55 changes: 55 additions & 0 deletions discord/source/functions/send.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
## `send`
Sends a message to a channel.

```coffee
func discord.channel.send(str 'content' = none) [
| react = none
| stickers = none
| attach = none
| embed = none
| embeds = none
| view = none
| views = none
| delete = 0.0
]
```

### Inputs
| input | aliases | type | description |
| :---- | :------ | :--- | :---------- |
| `react` | `reactions` | [`discord.(emoji)s`](emoji.md) | Reaction(s) to add. |
| `sticker` | `stickers` | [`discord.(sticker)s`](sticker.md) | Sticker(s) to add. |
| `attach` | `attachments` | [`discord.(asset)s`](asset.md) | Attachment(s) to upload. |
| `embed` | `embeds` | [`discord.(embed)s`](embed.md) | Embed(s) to add. |
| `view` | `views` | [`discord.(view)s`](view.md) | View(s) to add. |
| `delete` | `delete_after` | `float`, `datix.time`, `datix.date`, `datix.datetime` | The duration after which to delete the message. |

### Example
```coffee
discord.channel(...).send("sup") [
| attach = sys.file('sup.svg')
| embed = discord.embed() [...] {...}
| view = discord.view() [...] {...}
]
```

<br>
---
<br>

## `reply`
Replies to a message.

```coffee
func discord.message.reply(str 'content' = none) [
| mention = false
| react = none
| stickers = none
| attach = none
| embed = none
| embeds = none
| view = none
| views = none
| delete = 0.0
]
```
53 changes: 53 additions & 0 deletions discord/source/structs/bot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# `bot`

A Discord bot.

```coffee
struct 'bot' {
discord.id 'token' = none
pool[none | default | all] 'intents' = slot(default)
str 'prefix' = ""
}
```

<br>

# Properties

| property | aliases | type | description |
| :------- | :------ | :--- | :---------- |
| `token` | `key` | `discord.token` | API key of the bot. |
| `intents` | | `slot` | Intents the bot will be subscribed to. |
| `prefix` | `command_prefix` | `(str)s` | Prefix that precedes all commands. |

<br>

# Functions

| function | output | description |
| :------- | :----- | :---------- |
| [`create`](#create) | [`bot`](#bot) | Creates a bot. |
| [`start`](#start) | `none` | Starts the bot. |


## `create`
Creates a bot.

```coffee
evo func create [
| token = none
| intents = default
]
```

### Inputs
| input | aliases | type | description |
| :---- | :------ | :--- | :---------- |


## `start`
Starts the bot.

```coffee
evo func start() []
```
Loading

0 comments on commit 4bfba36

Please sign in to comment.