diff --git a/lib/bot.ts b/lib/bot.ts index c277149..73bde7e 100644 --- a/lib/bot.ts +++ b/lib/bot.ts @@ -1,7 +1,7 @@ import { RawData, WebSocket } from 'ws' import { EventEmitter } from 'events' import { Message, MessageResponse } from './types/message.js' -import fetch from 'node-fetch' +import axios from 'axios' import { EvangelineValueError } from './errors.js' const DEFAULT_REST_URL = 'https://eludris.tooty.xyz/' @@ -127,14 +127,11 @@ export class Bot extends EventEmitter { * @private */ private async createMessage(message: Message): Promise { - const response = await fetch(`${this.rest}/messages`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(message) - }) - return response.json() as Promise + const response = axios.post(`${this.rest}/messages`, { + author: this.author, + content: message.content + }).then((v) => v.data) + return await response as MessageResponse } /** diff --git a/package.json b/package.json index bdd6230..f2b0730 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "typescript": "^4.9.3" }, "dependencies": { - "node-fetch": "^3.3.0", + "axios": "^1.2.3", "ws": "^8.11.0" } }