This is the new version of my Interaction API designed for automating Discord slash commands in JavaScript, rebuilt from the ground up. This version is made to be less confusing and more reliable than the previous version, completely abandoning all librar
npm install interaction-apinpm i interaction-api
const API = require("interaction-api")
js
const API = require("interaction-api")
API.cache({"type":2,"application_id":"1157319244829167667","guild_id":"1157315096872235139","channel_id":"1157315096872235142","session_id":"e835fdb99370bab56ff3f4dda56e286e","data":{"version":"1157322861548159058","id":"1157322861548159057","name":"test","type":1,"options":[],"application_command":{"id":"1157322861548159057","application_id":"1157319244829167667","version":"1157322861548159058","default_member_permissions":null,"type":1,"nsfw":false,"name":"test","description":"A slash command for testing.","dm_permission":true,"contexts":null,"integration_types":[0]},"attachments":[]},"nonce":"1157332087028580352"})
//Returns: "713fc855-f83d-46a9-8035-4205fd38f9a9"
`
Stores slash command data in your cache for future usage. This function will return a unique key upon execution that can be used with functions API.remove() and API.post(). If the data given already exists in the cache, the returned value will be the same as the original key for that data. To obtain slash command data, follow these steps:
1. Open Discord in your web browser and sign into your account.
2. Open DevTools (ctrl+shift+i on Windows) and navigate to the Network tab, then type "interactions" into the filter bar.
3. Execute the slash command you wish to automate, then select the newly created item in the network panel and navigate to the payload section.
4. As you can see in the screenshot above, there is a JSON array in this window that is labeled as payload_json. Simply copy this JSON array and you will have your slash command data.
#### API.remove(key)
`js
const API = require("interaction-api")
API.remove("713fc855-f83d-46a9-8035-4205fd38f9a9")
//Returns: "Interaction removed from cache."
`
Removes slash command data from the cache via its key. This function will always return "Interaction removed from cache.", even when the key provided is invalid.
#### API.post(user_token, channel_id, key)
`js
const API = require("interaction-api")
await API.post("MTE1NzMxNDY1Mjg3MTU5ODEyMQ.GAwFsd.4goE630DTEY2t_sgS5FNK5eJwAFiaXl9kacaGA", "1157315096872235142", "1cc661c2-93de-4e81-b0d8-1527b6b9beba")
//Returns a promise.
`
Automates a cached slash command via its key. This function is asynchronous, so make sure to use await inside of an asynchronous scope. Upon execution, this function will return a promise containing details about the response given from Discord's API. Most of the time, you won't need this information.
#### API.clear()
`js
const API = require("interaction-api")
API.clear()
//Returns: "Cache cleared."
``