Archived
0
0
Fork 0

fix: forgot about message content & its post not get

This commit is contained in:
Daryl Ronningen 2021-07-06 16:02:36 -05:00
parent 26638b00d5
commit d574281127
Signed by: Daryl Ronningen
GPG key ID: FD23F0C934A5EC6B
2 changed files with 17 additions and 8 deletions

View file

@ -1,6 +1,7 @@
import { ApiClient } from './apiClient'; import { ApiClient } from './apiClient';
import type { Client } from '../client/client'; import type { Client } from '../client/client';
import type { IApiCreateMessage } from '../utils/types';
export class ApiHelper { export class ApiHelper {
public apiClient: ApiClient; public apiClient: ApiClient;
@ -15,10 +16,11 @@ export class ApiHelper {
this.apiClient = new ApiClient(this.client, this._token); this.apiClient = new ApiClient(this.client, this._token);
} }
public createMessage(channelId: string): void { public createMessage(channelId: string, options: IApiCreateMessage): void {
this.apiClient.get({ this.apiClient.post({
path: `/channels/${channelId}/messages`, path: `/channels/${channelId}/messages`,
requireAuth: true, requireAuth: true,
body: options,
}); });
} }
} }

View file

@ -13,6 +13,11 @@ export interface IDefaultOptions {
clientOptions: IClientOptions; clientOptions: IClientOptions;
} }
export interface IFile {
file: Buffer;
name: string;
}
export interface IMakeRequestOptions extends IRequestOptions { export interface IMakeRequestOptions extends IRequestOptions {
method: ApiMethods; method: ApiMethods;
} }
@ -23,17 +28,19 @@ export interface IRequestOptions {
requireAuth?: boolean; requireAuth?: boolean;
body?: unknown; body?: unknown;
headers?: Record<string, string>; headers?: Record<string, string>;
files?: { files?: IFile[];
file: Buffer; }
name: string;
}[]; // Api Rest Request Interfaces
// TODO: Finish this up
export interface IApiCreateMessage {
content: string;
} }
// Enums // Enums
// Type Aliases // Type Aliases
export type ApiMethods = 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT' ; export type ApiMethods = 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT' ;
export type Primitives = string | number | boolean | bigint | symbol | undefined | null;
// eslint-disable-next-line @typescript-eslint/ban-types // eslint-disable-next-line @typescript-eslint/ban-types
export type Builtin = Primitives | Function | Date | Error | RegExp; export type Builtin = Primitives | Function | Date | Error | RegExp;
export type DeepRequired<T> = T extends Builtin export type DeepRequired<T> = T extends Builtin
@ -56,4 +63,4 @@ export type DeepRequired<T> = T extends Builtin
: T extends {} : T extends {}
? { [K in keyof T]-?: DeepRequired<T[K]> } ? { [K in keyof T]-?: DeepRequired<T[K]> }
: NonNullable<T>; : NonNullable<T>;
export type Primitives = string | number | boolean | bigint | symbol | undefined | null;