disunity 0.1.8__tar.gz → 0.1.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {disunity-0.1.8 → disunity-0.1.9}/LICENSE +21 -21
- {disunity-0.1.8 → disunity-0.1.9}/PKG-INFO +1 -1
- {disunity-0.1.8 → disunity-0.1.9}/README.md +60 -60
- {disunity-0.1.8 → disunity-0.1.9}/pyproject.toml +29 -29
- {disunity-0.1.8 → disunity-0.1.9}/src/disunity/__init__.py +6 -6
- {disunity-0.1.8 → disunity-0.1.9}/src/disunity/cache.py +41 -41
- {disunity-0.1.8 → disunity-0.1.9}/src/disunity/embed.py +131 -127
- {disunity-0.1.8 → disunity-0.1.9}/src/disunity/errors.py +27 -27
- {disunity-0.1.8 → disunity-0.1.9}/src/disunity/identifiers.py +178 -178
- {disunity-0.1.8 → disunity-0.1.9}/src/disunity/models/__init__.py +15 -16
- {disunity-0.1.8 → disunity-0.1.9}/src/disunity/models/components.py +237 -242
- {disunity-0.1.8 → disunity-0.1.9}/src/disunity/models/context.py +127 -147
- {disunity-0.1.8 → disunity-0.1.9}/src/disunity/models/interaction.py +63 -63
- {disunity-0.1.8 → disunity-0.1.9}/src/disunity/models/member.py +22 -22
- {disunity-0.1.8 → disunity-0.1.9}/src/disunity/models/message.py +128 -129
- {disunity-0.1.8 → disunity-0.1.9}/src/disunity/models/user.py +24 -24
- {disunity-0.1.8 → disunity-0.1.9}/src/disunity/package.py +205 -205
- {disunity-0.1.8 → disunity-0.1.9}/src/disunity/server.py +280 -303
- {disunity-0.1.8 → disunity-0.1.9}/src/disunity/utils.py +42 -42
- {disunity-0.1.8 → disunity-0.1.9}/src/disunity.egg-info/PKG-INFO +1 -1
- {disunity-0.1.8 → disunity-0.1.9}/src/disunity.egg-info/SOURCES.txt +0 -1
- disunity-0.1.8/src/disunity/models/attachment.py +0 -36
- {disunity-0.1.8 → disunity-0.1.9}/setup.cfg +0 -0
- {disunity-0.1.8 → disunity-0.1.9}/src/disunity.egg-info/dependency_links.txt +0 -0
- {disunity-0.1.8 → disunity-0.1.9}/src/disunity.egg-info/top_level.txt +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Duxle
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Duxle
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
# disunity
|
|
2
|
-
|
|
3
|
-
Python framework for Discord interactions using a web server
|
|
4
|
-
|
|
5
|
-
# Installation
|
|
6
|
-
`pip install disunity`
|
|
7
|
-
|
|
8
|
-
# Introduction to Disunity
|
|
9
|
-
```python
|
|
10
|
-
import disunity
|
|
11
|
-
|
|
12
|
-
server = disunity.DisunityServer()
|
|
13
|
-
|
|
14
|
-
if __name__ == '__main__':
|
|
15
|
-
server.run()
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
Using packages
|
|
19
|
-
```python
|
|
20
|
-
import disunity
|
|
21
|
-
import pathlib
|
|
22
|
-
|
|
23
|
-
server = disunity.DisunityServer()
|
|
24
|
-
|
|
25
|
-
@server.before_serving
|
|
26
|
-
def load_packages():
|
|
27
|
-
for package in [f"{f.parent}.{f.stem}" for f in pathlib.Path("packages").glob("*.py")]:
|
|
28
|
-
server.load_package(package)
|
|
29
|
-
|
|
30
|
-
if __name__ == '__main__':
|
|
31
|
-
server.run()
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
# Setting up a package
|
|
36
|
-
|
|
37
|
-
```python
|
|
38
|
-
from disunity import package, utils
|
|
39
|
-
|
|
40
|
-
class FirstPackage(package.Package):
|
|
41
|
-
def __init__(self, app):
|
|
42
|
-
self.app = app
|
|
43
|
-
|
|
44
|
-
@package.Package.command('ping')
|
|
45
|
-
async def ping(self, ctx):
|
|
46
|
-
return await ctx.callback("Pong!")
|
|
47
|
-
|
|
48
|
-
def setup(app):
|
|
49
|
-
app.register_package(FirstPackage(app))
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
# Disclaimer
|
|
54
|
-
|
|
55
|
-
This will require that you already have hosting service for the server to run on as well as a domain to host the server on. If you have neither of these, an alternative would be to host on Heroku using a web application with Gunicorn.
|
|
56
|
-
|
|
57
|
-
# Side note
|
|
58
|
-
|
|
59
|
-
The server will receive interactions to the `/interactions` endpoint of your server. It will look like this: `https://example.com/interactions`. Once you run the server, put the url with the added interactions endpoint into the `interactions` URL on your app located in the Discord developer portal.
|
|
60
|
-
|
|
1
|
+
# disunity
|
|
2
|
+
|
|
3
|
+
Python framework for Discord interactions using a web server
|
|
4
|
+
|
|
5
|
+
# Installation
|
|
6
|
+
`pip install disunity`
|
|
7
|
+
|
|
8
|
+
# Introduction to Disunity
|
|
9
|
+
```python
|
|
10
|
+
import disunity
|
|
11
|
+
|
|
12
|
+
server = disunity.DisunityServer()
|
|
13
|
+
|
|
14
|
+
if __name__ == '__main__':
|
|
15
|
+
server.run()
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Using packages
|
|
19
|
+
```python
|
|
20
|
+
import disunity
|
|
21
|
+
import pathlib
|
|
22
|
+
|
|
23
|
+
server = disunity.DisunityServer()
|
|
24
|
+
|
|
25
|
+
@server.before_serving
|
|
26
|
+
def load_packages():
|
|
27
|
+
for package in [f"{f.parent}.{f.stem}" for f in pathlib.Path("packages").glob("*.py")]:
|
|
28
|
+
server.load_package(package)
|
|
29
|
+
|
|
30
|
+
if __name__ == '__main__':
|
|
31
|
+
server.run()
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
# Setting up a package
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from disunity import package, utils
|
|
39
|
+
|
|
40
|
+
class FirstPackage(package.Package):
|
|
41
|
+
def __init__(self, app):
|
|
42
|
+
self.app = app
|
|
43
|
+
|
|
44
|
+
@package.Package.command('ping')
|
|
45
|
+
async def ping(self, ctx):
|
|
46
|
+
return await ctx.callback("Pong!")
|
|
47
|
+
|
|
48
|
+
def setup(app):
|
|
49
|
+
app.register_package(FirstPackage(app))
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
# Disclaimer
|
|
54
|
+
|
|
55
|
+
This will require that you already have hosting service for the server to run on as well as a domain to host the server on. If you have neither of these, an alternative would be to host on Heroku using a web application with Gunicorn.
|
|
56
|
+
|
|
57
|
+
# Side note
|
|
58
|
+
|
|
59
|
+
The server will receive interactions to the `/interactions` endpoint of your server. It will look like this: `https://example.com/interactions`. Once you run the server, put the url with the added interactions endpoint into the `interactions` URL on your app located in the Discord developer portal.
|
|
60
|
+
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = [
|
|
3
|
-
"setuptools>=61.0",
|
|
4
|
-
"aiohttp>=3.6.0,<3.8.0",
|
|
5
|
-
"PyNaCl>=1.5.0",
|
|
6
|
-
"requests>=2.26.0",
|
|
7
|
-
"quart>=0.17.0"
|
|
8
|
-
]
|
|
9
|
-
build-backend = "setuptools.build_meta"
|
|
10
|
-
|
|
11
|
-
[project]
|
|
12
|
-
name = "disunity"
|
|
13
|
-
version = "0.1.
|
|
14
|
-
authors = [
|
|
15
|
-
{name="Tadeo Murillo"},
|
|
16
|
-
{name=""}
|
|
17
|
-
]
|
|
18
|
-
description = "Python framework for Discord interactions using a web server"
|
|
19
|
-
readme = "README.md"
|
|
20
|
-
requires-python = ">=3.10.0"
|
|
21
|
-
classifiers = [
|
|
22
|
-
"Programming Language :: Python :: 3",
|
|
23
|
-
"License :: OSI Approved :: MIT License",
|
|
24
|
-
"Operating System :: OS Independent"
|
|
25
|
-
]
|
|
26
|
-
|
|
27
|
-
[project.urls]
|
|
28
|
-
"Homepoge" = "https://github.com/murillotadeo/disunity"
|
|
29
|
-
"Bug Tracker" = "https://github.com/murillotadeo/disunity/issues"
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = [
|
|
3
|
+
"setuptools>=61.0",
|
|
4
|
+
"aiohttp>=3.6.0,<3.8.0",
|
|
5
|
+
"PyNaCl>=1.5.0",
|
|
6
|
+
"requests>=2.26.0",
|
|
7
|
+
"quart>=0.17.0"
|
|
8
|
+
]
|
|
9
|
+
build-backend = "setuptools.build_meta"
|
|
10
|
+
|
|
11
|
+
[project]
|
|
12
|
+
name = "disunity"
|
|
13
|
+
version = "0.1.9"
|
|
14
|
+
authors = [
|
|
15
|
+
{name="Tadeo Murillo"},
|
|
16
|
+
{name=""}
|
|
17
|
+
]
|
|
18
|
+
description = "Python framework for Discord interactions using a web server"
|
|
19
|
+
readme = "README.md"
|
|
20
|
+
requires-python = ">=3.10.0"
|
|
21
|
+
classifiers = [
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"License :: OSI Approved :: MIT License",
|
|
24
|
+
"Operating System :: OS Independent"
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
"Homepoge" = "https://github.com/murillotadeo/disunity"
|
|
29
|
+
"Bug Tracker" = "https://github.com/murillotadeo/disunity/issues"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
from . import utils
|
|
2
|
-
from .embed import Embed
|
|
3
|
-
from .identifiers import SubOption
|
|
4
|
-
from .models import Message
|
|
5
|
-
from .package import Package
|
|
6
|
-
from .server import DisunityServer
|
|
1
|
+
from . import utils
|
|
2
|
+
from .embed import Embed
|
|
3
|
+
from .identifiers import SubOption
|
|
4
|
+
from .models import Message
|
|
5
|
+
from .package import Package
|
|
6
|
+
from .server import DisunityServer
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
from .identifiers import (
|
|
2
|
-
Autocomplete,
|
|
3
|
-
CacheableSubCommand,
|
|
4
|
-
Command,
|
|
5
|
-
Component,
|
|
6
|
-
TopLevelSubCommand,
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class ApplicationCache:
|
|
11
|
-
def __init__(self):
|
|
12
|
-
self.commands = dict()
|
|
13
|
-
self.components = dict()
|
|
14
|
-
self.autocompletes = dict()
|
|
15
|
-
|
|
16
|
-
def add_item(
|
|
17
|
-
self, incoming: TopLevelSubCommand | Command | Component | Autocomplete
|
|
18
|
-
):
|
|
19
|
-
if isinstance(incoming, TopLevelSubCommand):
|
|
20
|
-
if "2" not in self.commands:
|
|
21
|
-
self.commands["2"] = {} # Sub commands will always by type 2
|
|
22
|
-
|
|
23
|
-
if incoming.name in self.commands["2"]:
|
|
24
|
-
self.commands["2"][str(incoming.name)].add(incoming)
|
|
25
|
-
else:
|
|
26
|
-
cacheable = CacheableSubCommand(str(incoming.name)).add(incoming)
|
|
27
|
-
self.commands["2"][str(incoming.name)] = cacheable
|
|
28
|
-
|
|
29
|
-
elif isinstance(incoming, Command):
|
|
30
|
-
if str(incoming.command_type) not in self.commands:
|
|
31
|
-
self.commands[str(incoming.command_type)] = {}
|
|
32
|
-
self.commands[str(incoming.command_type)][incoming.name] = incoming
|
|
33
|
-
|
|
34
|
-
elif isinstance(incoming, Component):
|
|
35
|
-
self.components[str(incoming.name)] = incoming
|
|
36
|
-
|
|
37
|
-
elif isinstance(incoming, Autocomplete):
|
|
38
|
-
self.autocompletes[str(incoming.command_name)] = incoming
|
|
39
|
-
|
|
40
|
-
else:
|
|
41
|
-
raise TypeError
|
|
1
|
+
from .identifiers import (
|
|
2
|
+
Autocomplete,
|
|
3
|
+
CacheableSubCommand,
|
|
4
|
+
Command,
|
|
5
|
+
Component,
|
|
6
|
+
TopLevelSubCommand,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ApplicationCache:
|
|
11
|
+
def __init__(self):
|
|
12
|
+
self.commands = dict()
|
|
13
|
+
self.components = dict()
|
|
14
|
+
self.autocompletes = dict()
|
|
15
|
+
|
|
16
|
+
def add_item(
|
|
17
|
+
self, incoming: TopLevelSubCommand | Command | Component | Autocomplete
|
|
18
|
+
):
|
|
19
|
+
if isinstance(incoming, TopLevelSubCommand):
|
|
20
|
+
if "2" not in self.commands:
|
|
21
|
+
self.commands["2"] = {} # Sub commands will always by type 2
|
|
22
|
+
|
|
23
|
+
if incoming.name in self.commands["2"]:
|
|
24
|
+
self.commands["2"][str(incoming.name)].add(incoming)
|
|
25
|
+
else:
|
|
26
|
+
cacheable = CacheableSubCommand(str(incoming.name)).add(incoming)
|
|
27
|
+
self.commands["2"][str(incoming.name)] = cacheable
|
|
28
|
+
|
|
29
|
+
elif isinstance(incoming, Command):
|
|
30
|
+
if str(incoming.command_type) not in self.commands:
|
|
31
|
+
self.commands[str(incoming.command_type)] = {}
|
|
32
|
+
self.commands[str(incoming.command_type)][incoming.name] = incoming
|
|
33
|
+
|
|
34
|
+
elif isinstance(incoming, Component):
|
|
35
|
+
self.components[str(incoming.name)] = incoming
|
|
36
|
+
|
|
37
|
+
elif isinstance(incoming, Autocomplete):
|
|
38
|
+
self.autocompletes[str(incoming.command_name)] = incoming
|
|
39
|
+
|
|
40
|
+
else:
|
|
41
|
+
raise TypeError
|
|
@@ -1,127 +1,131 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class EmptyEmbedError(Exception):
|
|
5
|
-
def __init__(self, message):
|
|
6
|
-
super().__init__(message)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class Embed:
|
|
10
|
-
def __init__(
|
|
11
|
-
self,
|
|
12
|
-
title: None | str = None,
|
|
13
|
-
description: None | str = None,
|
|
14
|
-
color: None | int = None,
|
|
15
|
-
):
|
|
16
|
-
self.__json: dict = {"type": "rich", "color": color}
|
|
17
|
-
|
|
18
|
-
self._title: None | str = title
|
|
19
|
-
self._description: None | str = description
|
|
20
|
-
self._color: None | int = color
|
|
21
|
-
|
|
22
|
-
self.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
@
|
|
30
|
-
def description(self
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
@
|
|
41
|
-
def color(self
|
|
42
|
-
self._color
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
@
|
|
50
|
-
def title(self
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return self
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return self
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return self
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return self
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class EmptyEmbedError(Exception):
|
|
5
|
+
def __init__(self, message):
|
|
6
|
+
super().__init__(message)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Embed:
|
|
10
|
+
def __init__(
|
|
11
|
+
self,
|
|
12
|
+
title: None | str = None,
|
|
13
|
+
description: None | str = None,
|
|
14
|
+
color: None | int = None,
|
|
15
|
+
):
|
|
16
|
+
self.__json: dict = {"type": "rich", "color": color}
|
|
17
|
+
|
|
18
|
+
self._title: None | str = title
|
|
19
|
+
self._description: None | str = description
|
|
20
|
+
self._color: None | int = color
|
|
21
|
+
|
|
22
|
+
if self._title is not None:
|
|
23
|
+
self._title = str(self.title)
|
|
24
|
+
self.__json["title"] = self.title
|
|
25
|
+
|
|
26
|
+
if self._description is not None:
|
|
27
|
+
self.__json["description"] = str(self._description)
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def description(self) -> None | str:
|
|
31
|
+
return self._description
|
|
32
|
+
|
|
33
|
+
@description.setter
|
|
34
|
+
def description(self, value: None | str) -> None:
|
|
35
|
+
if value is not None:
|
|
36
|
+
value = str(value)
|
|
37
|
+
self._description = value
|
|
38
|
+
self.__json["description"] = value
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def color(self) -> None | int:
|
|
42
|
+
return self._color
|
|
43
|
+
|
|
44
|
+
@color.setter
|
|
45
|
+
def color(self, value: None | int) -> None:
|
|
46
|
+
self._color = value
|
|
47
|
+
self.__json["color"] = value
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def title(self) -> None | str:
|
|
51
|
+
return self._title
|
|
52
|
+
|
|
53
|
+
@title.setter
|
|
54
|
+
def title(self, value: None | str) -> None:
|
|
55
|
+
if value is not None:
|
|
56
|
+
value = str(value)
|
|
57
|
+
self._title = value
|
|
58
|
+
self.__json["title"] = value
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def fields(self) -> None | list[dict]:
|
|
62
|
+
return self.__json.get("fields", None)
|
|
63
|
+
|
|
64
|
+
def add_field(self, name: str, value: str, inline: bool = False) -> Embed:
|
|
65
|
+
if not bool(name) or not bool(value):
|
|
66
|
+
raise EmptyEmbedError("Embed field cannot contain an empty value")
|
|
67
|
+
|
|
68
|
+
if "fields" not in self.__json:
|
|
69
|
+
self.__json["fields"] = []
|
|
70
|
+
|
|
71
|
+
self.__json["fields"].append({"name": name, "value": value, "inline": inline})
|
|
72
|
+
return self
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def footer(self) -> None | dict:
|
|
76
|
+
return self.__json.get("footer", None)
|
|
77
|
+
|
|
78
|
+
def set_footer(self, text: None | str = None, icon_url: None | str = None) -> Embed:
|
|
79
|
+
if "footer" not in self.__json:
|
|
80
|
+
self.__json["footer"] = {}
|
|
81
|
+
|
|
82
|
+
if text is not None:
|
|
83
|
+
self.__json["footer"]["text"] = str(text)
|
|
84
|
+
|
|
85
|
+
if icon_url is not None:
|
|
86
|
+
self.__json["footer"]["icon_url"] = str(icon_url)
|
|
87
|
+
|
|
88
|
+
return self
|
|
89
|
+
|
|
90
|
+
@property
|
|
91
|
+
def image(self) -> None | dict:
|
|
92
|
+
return self.__json.get("url", None)
|
|
93
|
+
|
|
94
|
+
def set_image(self, image_url: str) -> Embed:
|
|
95
|
+
if "image" not in self.__json:
|
|
96
|
+
self.__json["image"] = {}
|
|
97
|
+
|
|
98
|
+
self.__json["image"]["url"] = str(image_url)
|
|
99
|
+
return self
|
|
100
|
+
|
|
101
|
+
@property
|
|
102
|
+
def thumbnail(self) -> None | dict:
|
|
103
|
+
return self.__json.get("thumbnail", None)
|
|
104
|
+
|
|
105
|
+
def set_thumbnail(self, thumbnail_url: str) -> Embed:
|
|
106
|
+
if "thumbnail" not in self.__json:
|
|
107
|
+
self.__json["thumbnail"] = {}
|
|
108
|
+
|
|
109
|
+
self.__json["thumbnail"]["url"] = str(thumbnail_url)
|
|
110
|
+
return self
|
|
111
|
+
|
|
112
|
+
@property
|
|
113
|
+
def author(self) -> None | dict:
|
|
114
|
+
return self.__json.get("author", None)
|
|
115
|
+
|
|
116
|
+
def set_author(
|
|
117
|
+
self, name: str, url: None | str = None, icon_url: None | str = None
|
|
118
|
+
) -> Embed:
|
|
119
|
+
if "author" not in self.__json:
|
|
120
|
+
self.__json["author"] = {"name": str(name)}
|
|
121
|
+
|
|
122
|
+
if url is not None:
|
|
123
|
+
self.__json["author"]["url"] = str(url)
|
|
124
|
+
|
|
125
|
+
if icon_url is not None:
|
|
126
|
+
self.__json["author"]["icon_url"] = str(icon_url)
|
|
127
|
+
|
|
128
|
+
return self
|
|
129
|
+
|
|
130
|
+
def as_dict(self) -> dict:
|
|
131
|
+
return self.__json
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
class InvalidMethodUse(Exception):
|
|
2
|
-
def __init__(self, reason):
|
|
3
|
-
super().__init__(reason)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class CommandNotFound(Exception):
|
|
7
|
-
def __init__(self, command):
|
|
8
|
-
super().__init__(f"Command with name {command} could not be found")
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class ComponentNotFound(Exception):
|
|
12
|
-
def __init__(self, component):
|
|
13
|
-
super().__init__(f"No listener for components with name {component} exists")
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class AutocompleteNotFound(Exception):
|
|
17
|
-
def __init__(self, command_name):
|
|
18
|
-
super().__init__(
|
|
19
|
-
f"No listener for autocomplete for command {command_name} exists"
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class HTTPRequestError(Exception):
|
|
24
|
-
def __init__(self, status_code, error_message):
|
|
25
|
-
super().__init__(
|
|
26
|
-
f"HTTP request returned with status {status_code}: {error_message}"
|
|
27
|
-
)
|
|
1
|
+
class InvalidMethodUse(Exception):
|
|
2
|
+
def __init__(self, reason):
|
|
3
|
+
super().__init__(reason)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class CommandNotFound(Exception):
|
|
7
|
+
def __init__(self, command):
|
|
8
|
+
super().__init__(f"Command with name {command} could not be found")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ComponentNotFound(Exception):
|
|
12
|
+
def __init__(self, component):
|
|
13
|
+
super().__init__(f"No listener for components with name {component} exists")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class AutocompleteNotFound(Exception):
|
|
17
|
+
def __init__(self, command_name):
|
|
18
|
+
super().__init__(
|
|
19
|
+
f"No listener for autocomplete for command {command_name} exists"
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class HTTPRequestError(Exception):
|
|
24
|
+
def __init__(self, status_code, error_message):
|
|
25
|
+
super().__init__(
|
|
26
|
+
f"HTTP request returned with status {status_code}: {error_message}"
|
|
27
|
+
)
|