ScurryPy Mindset¶
This section will guide you through the flow, setup, and role of each folder in the project.
tl'dr
Inbound payloads are queried; outbound payloads are constructed.
What is a JSON query?¶
JSON payloads received from Discord are wrapped in JsonQuery to support traversal and common operations.
See JsonQuery Examples for more.
Keys Not Found
Keys that are not found return None. Keep an eye out for Omittable fields in event payloads as these fields are NOT always present!
What is a resource?¶
Resources model Discord's resource objects.
Q. How do I send a message?
A: Use the Channel.send endpoint
Endpoints return queries, not resources! Resources and queries are split so you can cache, serialize, and inspect query data without the weight of methods.
What is a Part?¶
Parts model the user's contract with creation endpoints. Use these classes when you want to create something.
Q. How do I create a message?
A: With the MessagePart
Q. How do I respond to an event?
A: Event > Resource > Request. ScurryPy will never do this for you (unless you use scurrypy.ext).
What is a Parameter?¶
Parameters model the user's contract with modifying endpoints. Use these classes when you want to modify something.
Parameters are TypedDicts that are meant to be Unpacked by endpoint functions.
They are constructed via keyword arguments rather than manual instantiation.
What is a context?¶
Contexts are part of the scurrypy.ext module. They group properties associated with the events the addon dispatches.
For example, ApplicationCommandContext contains commonly needed properties from the INTERACTION_CREATE event including bot, event, event data, and various helper properties.