Skip to content

Latest commit

 

History

History
399 lines (280 loc) · 27.9 KB

README.md

File metadata and controls

399 lines (280 loc) · 27.9 KB

Messages

(messages)

Overview

Available Operations

get

Example Usage

import { Discord } from "@speakeasy-sdks/discord";

const discord = new Discord({
  botToken: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await discord.messages.get({
    channelId: "<value>",
    messageId: "<value>",
  });

  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { DiscordCore } from "@speakeasy-sdks/discord/core.js";
import { messagesGet } from "@speakeasy-sdks/discord/funcs/messagesGet.js";

// Use `DiscordCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const discord = new DiscordCore({
  botToken: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await messagesGet(discord, {
    channelId: "<value>",
    messageId: "<value>",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.GetMessageRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.MessageResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse 4XX application/json
errors.SDKError 4xx-5xx /

delete

Example Usage

import { Discord } from "@speakeasy-sdks/discord";

const discord = new Discord({
  botToken: "<YOUR_API_KEY_HERE>",
});

async function run() {
  await discord.messages.delete({
    channelId: "<value>",
    messageId: "<value>",
  });

  
}

run();

Standalone function

The standalone function version of this method:

import { DiscordCore } from "@speakeasy-sdks/discord/core.js";
import { messagesDelete } from "@speakeasy-sdks/discord/funcs/messagesDelete.js";

// Use `DiscordCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const discord = new DiscordCore({
  botToken: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await messagesDelete(discord, {
    channelId: "<value>",
    messageId: "<value>",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  
}

run();

Parameters

Parameter Type Required Description
request operations.DeleteMessageRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<void>

Errors

Error Object Status Code Content Type
errors.ErrorResponse 4XX application/json
errors.SDKError 4xx-5xx /

update

Example Usage

import { Discord } from "@speakeasy-sdks/discord";

const discord = new Discord({
  botToken: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await discord.messages.update({
    channelId: "<value>",
    messageId: "<value>",
    messageEditRequestPartial: {},
  });

  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { DiscordCore } from "@speakeasy-sdks/discord/core.js";
import { messagesUpdate } from "@speakeasy-sdks/discord/funcs/messagesUpdate.js";

// Use `DiscordCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const discord = new DiscordCore({
  botToken: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await messagesUpdate(discord, {
    channelId: "<value>",
    messageId: "<value>",
    messageEditRequestPartial: {},
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.UpdateMessageRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.MessageResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse 4XX application/json
errors.SDKError 4xx-5xx /

list

Example Usage

import { Discord } from "@speakeasy-sdks/discord";

const discord = new Discord({
  botToken: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await discord.messages.list({
    channelId: "<value>",
  });

  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { DiscordCore } from "@speakeasy-sdks/discord/core.js";
import { messagesList } from "@speakeasy-sdks/discord/funcs/messagesList.js";

// Use `DiscordCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const discord = new DiscordCore({
  botToken: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await messagesList(discord, {
    channelId: "<value>",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.ListMessagesRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.MessageResponse[]>

Errors

Error Object Status Code Content Type
errors.ErrorResponse 4XX application/json
errors.SDKError 4xx-5xx /

create

Example Usage

import { Discord } from "@speakeasy-sdks/discord";

const discord = new Discord({
  botToken: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await discord.messages.create({
    channelId: "<value>",
    messageCreateRequest: {},
  });

  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { DiscordCore } from "@speakeasy-sdks/discord/core.js";
import { messagesCreate } from "@speakeasy-sdks/discord/funcs/messagesCreate.js";

// Use `DiscordCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const discord = new DiscordCore({
  botToken: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await messagesCreate(discord, {
    channelId: "<value>",
    messageCreateRequest: {},
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.CreateMessageRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.MessageResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse 4XX application/json
errors.SDKError 4xx-5xx /