Skip to content

Commit

Permalink
feat: add trigger typing endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkaroid committed May 18, 2022
1 parent 7c01cbb commit 476dc9e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion index.ts
@@ -1,4 +1,4 @@
import { get, post, put, loop, remove, reply, create } from "./src/utils";
import { get, post, put, loop, remove, reply, create, rateLimit } from "./src/utils";
import c from "./src/const";

class Jalter {
Expand All @@ -13,9 +13,11 @@ class Jalter {
this.base = c.endpoint.baseurl;
this.auth = { "authorization": token };

/*
get(`${this.base}/users/@me`, this.auth).then(res => {
if (res.statusCode !== 200) throw new Error(c.error.invalidToken);
});
*/
}

/**
Expand Down Expand Up @@ -213,6 +215,24 @@ class Jalter {
});
}

/**
* Trigger Typing Indicator
* @param {string} channelId the channel id
* @returns 204 empty response on success
* @example
* ```js
* jalter.startTyping("974918359500075041").then((res) => { console.log("startTyping", res); });
* ```
* https://discord.com/developers/docs/resources/channel#trigger-typing-indicator
*/
async typingMessage(channelId: string, timeout = 3000): Promise<void> {
const endpoint = `${this.base}/channels/${channelId}/typing`;
await post(endpoint, "", this.auth).then(res => {
return res.body as object;
});
await rateLimit(timeout);
}

/**
* Reply to a message
* @param {string} channelId the channel id
Expand Down

0 comments on commit 476dc9e

Please sign in to comment.