def __init__(self, instance_id): self.instance_id = instance_id os.environ["DISCORD_INSTANCE_ID"] = str(self.instance_id) self.discord = dsdk.Discord(application_id, dsdk.CreateFlags.default) self.network_manager = self.discord.get_network_manager() self.network_manager.on_route_update = self.on_route_update self.network_manager.on_message = self.on_message self.peer_id = self.network_manager.get_peer_id()
import random import time import discordsdk as dsdk # we get the application id from a file with open("application_id.txt", "r") as file: application_id = int(file.read()) # we create the discord instance app = dsdk.Discord(application_id, dsdk.CreateFlags.default) relationship_manager = app.get_relationship_manager() # events def on_refresh(): print("[on_refresh]") # we filter friends relationship_manager.filter( lambda relationship: relationship.type == dsdk.RelationshipType.friend) # we get how many friends we have!! friend_count = relationship_manager.count() friends = [] print(f"You have {friend_count} friends!") for n in range(friend_count): # we get the friend at index n friend = relationship_manager.get_at(n)