Skip to content

Commit 8f988e3

Browse files
author
James
committed
Merge branch 'main' of https://github.com/Dispy-inc/Dispy
2 parents aaf11c2 + ee2e003 commit 8f988e3

File tree

7 files changed

+112
-26
lines changed

7 files changed

+112
-26
lines changed

docs/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ Dispy lets bot developers focus on their ideas and the structure of their bots i
2626
***
2727

2828
* Getting Started
29-
* [**Introduction**](documentation/readme/introduction.md): Installation and importation
30-
* [**Setup your bot on discord**](documentation/readme/setup-your-bot-on-discord.md): Getting your bot token and invite link
29+
* [Introduction](documentation/readme/introduction.md): Installation and importation
30+
* [Setup your bot on discord](documentation/readme/setup-your-bot-on-discord.md): Getting your bot token and invite link
31+
* [Examples](documentation/examples.md): Get familiarize with Dispy
3132
* Contribute
3233
* [Adding an API function](informations/contribute/adding-an-api-function.md): Learn how to add any missing functions to Dispy
33-
* Versions ([changelogs](informations/changelogs/))
34+
* Versions ([Changelogs](informations/changelogs/))
3435
* [0.1.0.7](informations/changelogs/0.1.0.7.md) (Work in progress)
3536
* [0.1.0.6](informations/changelogs/0.1.0.6.md)
3637
* [0.1.0.5](informations/changelogs/0.1.0.5.md)
3738
* [0.1.0](informations/changelogs/0.1.0.md)
3839
* [0.0.1](informations/changelogs/0.0.1.md)
3940
* [Roadmap](informations/roadmap.md): See the progression of Dispy
41+
* [Support](informations/support.md): Know if your project can be made using Dispy

docs/SUMMARY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
* [Getting started](README.md)
66
* [Installation](documentation/readme/introduction.md)
77
* [Create a bot](documentation/readme/setup-your-bot-on-discord.md)
8-
* [Support](documentation/support.md)
98
* [Functions](documentation/functions/README.md)
109
* [\*](documentation/functions/undefined.md)
1110
* [Message](documentation/functions/message.md)
1211
* [Events](documentation/events/README.md)
1312
* [Supported Events](documentation/events/supported-events.md)
1413
* [Courses](documentation/wiki/README.md)
1514
* [Ready print](documentation/wiki/ready-print.md)
15+
* [Examples](documentation/examples.md)
1616

1717
## Informations
1818

@@ -25,3 +25,4 @@
2525
* [0.1.0](informations/changelogs/0.1.0.md)
2626
* [0.0.1](informations/changelogs/0.0.1.md)
2727
* [Roadmap](informations/roadmap.md)
28+
* [Support](informations/support.md)

docs/documentation/examples.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
icon: copy
3+
---
4+
5+
# Examples
6+
7+
***
8+
9+
{% hint style="danger" %}
10+
These examples assume that you have the **Message Content** privileged intent enabled. Follow step 4 on the [Create a bot](readme/setup-your-bot-on-discord.md) guide.
11+
{% endhint %}
12+
13+
### Base Template
14+
15+
This is how the base code of your bot should like, but I recommend hiding the token better.
16+
17+
```python
18+
from dispy import Bot
19+
20+
token = 'your_token'
21+
bot = Bot(token)
22+
23+
@bot.once('READY')
24+
def on_ready():
25+
print('READY')
26+
27+
bot.run()
28+
```
29+
30+
### Help Command
31+
32+
To test your command, simply send `!help` in a channel that the bot has access to.
33+
34+
```python
35+
from dispy import Bot
36+
from dispy.types import (
37+
Message,
38+
User
39+
)
40+
41+
token = 'your_token'
42+
bot = Bot(token)
43+
44+
@bot.once('READY')
45+
def on_ready():
46+
print('READY')
47+
48+
@bot.on('MESSAGE_CREATE')
49+
def on_message(msg: Message, user: User):
50+
if msg.content == '!help':
51+
msg.reply('My commands are:\n- !help - List the commands')
52+
53+
bot.run()
54+
```
55+
56+
### Embed Example
57+
58+
This is a basic example of the embed functionality, to see your embed, simply send `!help` in a channel that the bot has access to.
59+
60+
```python
61+
from dispy import Bot, EmbedBuilder
62+
from dispy.types import (
63+
Message,
64+
User
65+
)
66+
67+
token = 'your_token'
68+
bot = Bot(token)
69+
70+
@bot.once('READY')
71+
def on_ready():
72+
print('READY')
73+
74+
@bot.on('MESSAGE_CREATE')
75+
def on_message(msg: Message, user: User):
76+
if msg.content == '!help':
77+
helpCommand = (EmbedBuilder()
78+
.setTitle('Commands List')
79+
.setColor('blue')
80+
.addField('!help', 'List the commands')
81+
)
82+
msg.reply(embeds=helpCommand)
83+
84+
bot.run()
85+
```
86+

docs/documentation/wiki/ready-print.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ This page is under construction!
2323

2424
Print when the bot is online on discord. Don't forgot to replace 'your\_token' with your actual token.
2525

26-
```python
27-
from dispy import Bot
28-
26+
<pre class="language-python"><code class="lang-python"><strong>from dispy import Bot
27+
</strong>
2928
token = 'your_token'
3029
bot = Bot(token)
3130

@@ -34,4 +33,4 @@ def on_ready(msg):
3433
print('READY')
3534

3635
bot.run()
37-
```
36+
</code></pre>

docs/informations/changelogs/0.1.0.7.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Hello! This version is meant to make dispy more intuitive and simple to use. The
88

99
I've made importing the library more clean and more optimized. All the types need to be imported from `dispy.types` as for now and creating a bot is made with `from dispy import Bot`.
1010

11+
And i'm working on slash commands, it will be really cool to use!
12+
1113
### Test It
1214

1315
To install this work in progress version, you need to follow theses commands:
@@ -16,7 +18,7 @@ To install this work in progress version, you need to follow theses commands:
1618
pip install git+https://github.com/Dispy-inc/Dispy.git
1719
```
1820

19-
{% hint style="danger" %}
21+
{% hint style="warning" %}
2022
This is an experimental version, you may encounter bugs.
2123
{% endhint %}
2224

@@ -28,23 +30,22 @@ This is an experimental version, you may encounter bugs.
2830
* Snowflakes (IDs) now are represent as STR and INT, so you can compared them (e.g. is equal) with STR and INT values.
2931
* ISO timestamp are now automatically converted to epoch timestamp, now dispy will only use this kind of timestamp because it is easier to manipulate.
3032
* Added a caching system used by slash commands, it can store informations so it isn't define every executions.
31-
* _<mark style="background-color:orange;">Started working on slash commands.</mark>_
32-
33-
#### Changes
34-
35-
* Importing dispy is now way more clean.
33+
* Added `.getDict()` to the DictWrapper, so you can finally use `json.dumps()`.
3634

3735
**Fix**
3836

3937
* Editing a message now return a message object.
4038
* Fixed an issue with DictWrapper, which made if the debug mode was disable, it will failed if there is an extra field.
41-
* Made tokens and headers attributes private so eval cannot get them (Never use it anyway).
4239

4340
**Removed**
4441

4542
* Pydantic dependency.
4643
* TokenReader() was removed :'(
4744

45+
#### Changes
46+
47+
* Importing dispy is now way more clean.
48+
4849
### How to update my code?
4950

5051
#### Timestamps

docs/informations/contribute/adding-an-api-function.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ If you don't know how to make a pull request (Demand to change the code), you ma
2222

2323
{% stepper %}
2424
{% step %}
25-
#### Research
25+
**Research**
2626

2727
Before you code a new function for Dispy, you need to know exactly how to do it.
2828

2929
In the [documentation](https://discord.com/developers/docs/intro) of discord, you can find every possible API requests, e.g. [Request to create a message](https://discord.com/developers/docs/resources/message#create-message). You will need theses informations to continue.
3030
{% endstep %}
3131

3232
{% step %}
33-
#### Amount
33+
**Amount**
3434

3535
In Dispy, your function can be in multiple place, e.g. to create a message:
3636

@@ -42,15 +42,15 @@ An API function need to be present on types that has the necessary informations
4242
{% endstep %}
4343

4444
{% step %}
45-
#### Where
45+
**Where**
4646

4747
The API function for the bot object are located in **dispy.modules.**_**rest\_api.py**_.
4848

4949
For an object (e.g. Message), they are located in **dispy.types** and the file which contain the definition of the object. If the object doesn't exist, follow this guide[^1].
5050
{% endstep %}
5151

5252
{% step %}
53-
#### Introduction
53+
**Introduction**
5454

5555
If the object doesn't have the `_api = None` argument, you need to add it at the end of all the type definition. With this you can call the \_\_request\_\_ object.
5656

@@ -63,11 +63,11 @@ import asyncio
6363
{% endstep %}
6464

6565
{% step %}
66-
#### Create the Function
66+
**Create the Function**
6767

6868
When creating a function, you need to follow some rules to be sure your pull request will be accepted.
6969

70-
* If the API request return something, it need to has a type object (If it doesn't exist, create it using this guide[^2]) or put 'None' if nothing is returned
70+
* If the API request return something, it need to has a type object (If it doesn't exist, create it using this guide[^1]) or put 'None' if nothing is returned
7171
* It need to be asynchronous.
7272
* It need to be using the internal function of Dispy (`result` & `__request__`)
7373
* The line using \_\_request\_\_ need to have the comment `# no_traceback` at the end.
@@ -102,7 +102,7 @@ def function(self, argument=None, **kwargs) -> result[<Type>]:
102102
3. And `<path>`, you replace by the API path given by the Discord documentation.
103103

104104
{% hint style="danger" %}
105-
If your function need to has an argument called **"embeds"**, you need to define it manually inside your \_asynchronous function and give it inside the **run\_coroutine\_threadsafe**. Don't ask me why, ask asyncio.
105+
Some arguments will need to be passed through **run\_coroutine\_threadsafe**.
106106
{% endhint %}
107107
{% endstep %}
108108

@@ -118,7 +118,3 @@ And you're done! Time to open a pull request
118118
[^1]: There is no guide yet.
119119

120120
Ask the developer :)
121-
122-
[^2]: There is no guide yet.
123-
124-
Ask the developer :)

docs/documentation/support.md renamed to docs/informations/support.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Because dispy is very new, I made a support page so you can know if you can make
1515

1616
* **SEND** | **EDIT** | **DELETE** | **REPLY** Message
1717
* **ADD** | **REMOVE SPECIFIED** Reaction
18+
* **KICK** | **BAN** | **TIMEOUT** User & Member (Can depend on the data)
1819

1920
### Supported Types
2021

0 commit comments

Comments
 (0)