bridgecord-0.4.0
توضیحات
Discord Game SDK implementation
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | bridgecord-0.4.0 |
| نام | bridgecord |
| نسخه کتابخانه | 0.4.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | onyx1a |
| ایمیل نویسنده | onyx1anis@gmail.com |
| آدرس صفحه اصلی | https://github.com/onyx1a/BridgeCord |
| آدرس اینترنتی | https://pypi.org/project/bridgecord/ |
| مجوز | MIT |
# BridgeCord
[](https://github.com/onyx1a/BridgeCord/actions/workflows/pip.yml)
[](https://pypi.org/project/bridgecord/)
[](https://github.com/onyx1a/BridgeCord/blob/main/LICENSE)
[](https://pypi.org/project/bridgecord/)
[](https://pypi.org/project/bridgecord/)
```
pip install bridgecord
```
Check [SDK Starter Guide](https://discord.com/developers/docs/game-sdk/sdk-starter-guide) to understand how it works.
---
### Example
```python
import bridgecord as bc
bridge = bc.Instance(debugging=False)
bridge.init(clientID=CLIENT_ID)
bridge.activity_info.details = "Hello, Python"
bridge.activity_info.state = "In game"
bridge.activity_info.large_image = "dreampyavatar"
bridge.set_timestamps_start(int(time.time()))
bridge.update_current_activity()
while True:
bridge.run_callbacks()
```
[]()
`bridge.run_callbacks()` should be [always](https://discord.com/developers/docs/game-sdk/discord#runcallbacks) running.
If you set `debugging=False`, you will not receive some messages in the console. For example, by calling a method that triggers `UpdateActivity`, you will receive a message containing the [result code](https://discord.com/developers/docs/game-sdk/discord#data-models-result-enum). You can toggle this option by `bridge.is_debugging = True`. Note that this option is enabled by default.
---
### Activity
```python
# Set text, which display on user hovers over large image
bridge.activity_info.large_text = "Large text"
# Set small image, which displayed in right bottom corner
bridge.activity_info.small_image = "dreampy1"
# Set text, which display on user hovers over small image
bridge.activity_info.small_text = "Small text"
```
If you editing any activity info (except timestamps), you should update activity:
```python
bridge.update_current_activity()
```
You can also set how much time is left:
```python
bridge.set_timestamps_end(1678357800)
```
[]()
---
### Update user profile
You can detect if user change avatar or discord name:
```python
def test_callback() -> None:
ret, user = bridge.current_user()
if ret == 0:
print(user.username)
print(user.discriminator)
print(user.avatar_hash)
print(user.get_avatar_url("jpg"))
print(user.is_bot)
print(user.id)
bridge.on_current_user_update_connect(test_callback)
```
In this example, `current_user()`returned [result code](https://discord.com/developers/docs/game-sdk/discord#data-models-result-enum) and user object.
Output result:
```
onyx1a
3440
c240d87788e9e93464872ac80f047568
https://cdn.discordapp.com/avatars/1052579421875339284/c240d87788e9e93464872ac80f047568.jpg
False
1052579421875339284
```
Read more about user avatar [here](https://discord.com/developers/docs/reference#image-formatting-image-base-url).
---
### Callbacks
You can set many callbacks for one action:
```python
token1 = bridge.on_current_user_update_connect(test_callback1)
token2 = bridge.on_current_user_update_connect(test_callback2)
```
Tokens are needed in order to disable unnecessary callback:
```python
bridge.on_current_user_update_disconnect(token1)
```
---
### Party info:
```python
bridge.edit_party_info(cur_size=1, max_size=4, id="test", secret="secret", is_private=True)
```
[]()
This feature allows other users to see the button "Ask to Join", when clicked, will send the user an invitation:
[]()
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.7 | Python |
نحوه نصب
نصب پکیج whl bridgecord-0.4.0:
pip install bridgecord-0.4.0.whl
نصب پکیج tar.gz bridgecord-0.4.0:
pip install bridgecord-0.4.0.tar.gz