Attributes
Includes Deno configuration
Repository
Current version released
2 years ago
Versions
- v1.0.0-RCLatest
- v1.0.0-pre-release-11
- v1.0.0-pre-release-10
- v1.0.0-pre-release-9
- v1.0.0-doc-test-1
- v1.0.0-pre-release-8
- 1.0.0-pre-release-7
- v1.0.0-pre-release-6
- v1.0.0-pre-release-5
- v1.0.0-pre-release-4
- v1.0.0-pre-release-3
- v1.0.0-pre-release-2
- v1.0.0-pre-release
- v0.1.1
- v0.1.0
- v0.0.1-alpha.14
- v0.0.1-alpha.13
- v0.0.1-alpha.12
- v0.0.1-alpha.11
- v0.0.1-alpha.9
- v0.0.1-alpha.8
- v0.0.1-alpha.7
- v0.0.1-alpha.6
- v0.0.1-alpha.5
- v0.0.1-alpha.4
- v0.0.1-alpha.4
- v0.0.1-alpha.3
- v0.0.1-alpha.2
tpy
A strongly typed Pylon API client. https://pylon.bot/
The Pylon API does not have a standardized response, meaning there are alot of edge cases and can result sometimes in unexpected responses. Tpy aims to resolve this by providing type safe interaction along with optional specification if you know what to expect. Tpy also provides a predictable interface with documentation on almost all used endpoints.
npm install tpy
import Tpy, {
TpyErrToString,
TypeUtil,
} from 'https://deno.land/x/tpy@v1.0.0-pre-release/mod.ts';
// Or use Node
// import Tpy, { TpyErrToString, TypeUtil } from 'tpy';
const client = new Tpy('My.pYl0N_tOKEn');
const user = await client.getUser().catch((r) => {
throw 'There was an error while fetching the user: ' + TpyErrToString(r);
});
console.log(`User logged in: ${user.displayName}`);
const ws = client.connectSocket(
<TypeUtil.StringifiedNumber> (await client.getGuildInfo('530557949098065930'))
.deployments[0].id,
);
// Dynamically finds the workbench URL to connect to.
await ws.connect();
ws.on('open', (_) => console.log('The Socket has been opened!'));
// Messages are recieved on console events.
ws.on('message', (payload) => console.log(payload.data));
// Typing out the message data is also allowed.
// See expansion below this codeblock to see code that can provide this log format.
type Attachments = {
name: string;
url: string;
}[];
ws.on<[
string,
Attachments,
]>(
'message',
(payload) => {
const Content = payload.data[0];
const Attachments = payload.data[1];
console.log(
`New Message: "${Content}"\n`,
`Attachments:\n`,
...Attachments.map((a) => `${a.name} (${a.url})\n`),
);
},
);
Pylon Code
type Attachments = {
name: string;
url: string;
}[];
discord.on('MESSAGE_CREATE', async (m) => {
let attachments: Attachments = m.attachments.map((v) => {
return { name: v.filename, url: v.proxyUrl };
});
console.log(m.content, attachments);
});
Contributing
Currently, the library is missing some documentation and has some dirty code. If you’d like to contribute, please read the contributing guide before you start working.
Legal
Pylon is a copyright (c) of Uplol Inc., all rights reserved to Uplol.
Tpy is licensed under the MIT License.