pip install bridgecord
Check SDK Starter Guide to understand how it works.
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 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. You can toggle this option by bridge.is_debugging = True
. Note that this option is enabled by default.
# 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:
bridge.update_current_activity()
You can also set how much time is left:
bridge.set_timestamps_end(1678357800)
You can detect if user change avatar or discord name:
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 and user object.
Output result:
onyx1a
3440
c240d87788e9e93464872ac80f047568
https://cdn.discordapp.com/avatars/1052579421875339284/c240d87788e9e93464872ac80f047568.jpg
False
1052579421875339284
Read more about user avatar here.
You can set many callbacks for one action:
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:
bridge.on_current_user_update_disconnect(token1)
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: