@guildedts/rest
Advanced tools
Comparing version 0.12.0 to 0.13.0
# @guildedts/rest | ||
## 0.13.0 | ||
### Minor Changes | ||
- 88420fe: feat: webhook `username` and `avatar_url` support | ||
- cbcedfb: feat(RESTOptions): add `proxyUrl` | ||
### Patch Changes | ||
- Updated dependencies [88420fe] | ||
- guilded-api-typings@0.12.0 | ||
## 0.12.0 | ||
@@ -4,0 +16,0 @@ |
@@ -22,4 +22,6 @@ "use strict"; | ||
version; | ||
/** The proxy url of the REST API. */ | ||
proxyUrl; | ||
/** The router for the REST API. */ | ||
router = new Router_1.Router(this); | ||
router; | ||
/** @param options The options for the REST manager. */ | ||
@@ -30,7 +32,10 @@ constructor(options) { | ||
this.token = options.token; | ||
this.version = options.version; | ||
this.proxyUrl = options.proxyUrl; | ||
if (!this.proxyUrl) | ||
this.version = options.version; | ||
this.router = new Router_1.Router(this); | ||
} | ||
/** The base URL for the REST API. */ | ||
get baseURL() { | ||
return `https://www.guilded.gg/api/v${this.version}/`; | ||
return this.proxyUrl ? this.proxyUrl : `https://www.guilded.gg/api/v${this.version}/`; | ||
} | ||
@@ -65,3 +70,3 @@ /** | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${this.token}`, | ||
...(this.token ? { Authorization: `Bearer ${this.token}` } : {}), | ||
'User-Agent': `@guildedts/rest@${version} Node.JS@${process.versions.node}`, | ||
@@ -68,0 +73,0 @@ }, |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -6,2 +9,3 @@ exports.WebhookRouter = void 0; | ||
const BaseRouter_1 = require("./BaseRouter"); | ||
const node_fetch_1 = __importDefault(require("node-fetch")); | ||
/** | ||
@@ -35,2 +39,20 @@ * The webhook router for the Guilded REST API. | ||
/** | ||
* Create a webhook message on Guilded. | ||
* @param webhookId The ID of the webhook. | ||
* @param webhookToken The token of the webhook. | ||
* @param payload The payload of the message. | ||
* @example webhooks.send('abc', 'abc', 'Hello world!'); | ||
*/ | ||
async send(webhookId, webhookToken, payload) { | ||
await (0, node_fetch_1.default)(`https://media.guilded.gg${guilded_api_typings_1.Routes.webhookExecute(webhookId, webhookToken)}`, { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify(typeof payload === 'string' | ||
? { content: payload } | ||
: Array.isArray(payload) | ||
? { embeds: payload } | ||
: payload), | ||
}); | ||
} | ||
/** | ||
* Create a webhook on Guilded. | ||
@@ -37,0 +59,0 @@ * @param serverId The ID of the server the webhook belongs to. |
{ | ||
"name": "@guildedts/rest", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"description": "The REST API manager for Guilded.TS.", | ||
@@ -30,3 +30,3 @@ "repository": { | ||
"dependencies": { | ||
"guilded-api-typings": "^0.11.0", | ||
"guilded-api-typings": "^0.12.0", | ||
"node-fetch": "^2.6.7" | ||
@@ -33,0 +33,0 @@ }, |
@@ -14,3 +14,5 @@ /// <reference types="node" /> | ||
/** The version of the REST API. */ | ||
readonly version: number; | ||
readonly version?: number; | ||
/** The proxy url of the REST API. */ | ||
readonly proxyUrl?: string; | ||
/** The router for the REST API. */ | ||
@@ -21,3 +23,3 @@ readonly router: Router; | ||
/** The base URL for the REST API. */ | ||
get baseURL(): `https://www.guilded.gg/api/v${number}/`; | ||
get baseURL(): string; | ||
/** | ||
@@ -100,3 +102,5 @@ * Set the auth token for the REST API. | ||
/** The version of the REST API. */ | ||
version: number; | ||
version?: number; | ||
/** The proxy URL of the REST API. */ | ||
proxyUrl?: string; | ||
/** The interval to wait between retries. */ | ||
@@ -103,0 +107,0 @@ retryInterval?: number; |
@@ -1,2 +0,2 @@ | ||
import { APIWebhook } from 'guilded-api-typings'; | ||
import { APIWebhook, APIWebhookMessagePayloadResolvable } from 'guilded-api-typings'; | ||
import { BaseRouter } from './BaseRouter'; | ||
@@ -25,2 +25,10 @@ /** | ||
/** | ||
* Create a webhook message on Guilded. | ||
* @param webhookId The ID of the webhook. | ||
* @param webhookToken The token of the webhook. | ||
* @param payload The payload of the message. | ||
* @example webhooks.send('abc', 'abc', 'Hello world!'); | ||
*/ | ||
send(webhookId: string, webhookToken: string, payload: APIWebhookMessagePayloadResolvable): Promise<void>; | ||
/** | ||
* Create a webhook on Guilded. | ||
@@ -27,0 +35,0 @@ * @param serverId The ID of the server the webhook belongs to. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
143583
1986
+ Addedguilded-api-typings@0.12.1(transitive)
- Removedguilded-api-typings@0.11.0(transitive)
Updatedguilded-api-typings@^0.12.0