Skip to content

Commit

Permalink
fix(discord): use axiosConfig in bot.sendEmbedMessage (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
dragon-fish committed Apr 2, 2021
1 parent 0f95246 commit 679e8e0
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions packages/adapter-discord/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class DiscordBot extends Bot<'discord'> {
_ping: NodeJS.Timeout
_sessionId: string = ''

async request<T = any>(method: Method, path: string, data?: any): Promise<T> {
async request<T = any>(method: Method, path: string, data?: any, exHeaders?: any): Promise<T> {
const { axiosConfig, discord = {} } = this.app.options
const url = `https://discord.com/api/v8${path}`
const headers: Record<string, any> = {
Expand All @@ -27,7 +27,7 @@ export class DiscordBot extends Bot<'discord'> {
...discord.axiosConfig,
method,
url,
headers,
headers: { ...headers, ...exHeaders },
data,
})
return response.data
Expand All @@ -43,16 +43,7 @@ export class DiscordBot extends Bot<'discord'> {
const type = await FileType.fromBuffer(fileBuffer)
fd.append('file', fileBuffer, 'file.' + type.ext)
fd.append('payload_json', JSON.stringify(payload_json))
const headers: Record<string, any> = {
Authorization: `Bot ${this.token}`,
}
const response = await axios({
method: 'post',
url: 'https://discord.com/api/v8' + requestUrl,
headers: { ...headers, ...fd.getHeaders() },
data: fd,
})
return response.data
return this.request('POST', requestUrl, fd, fd.getHeaders())
}

private parseQuote(chain: segment.Chain) {
Expand Down

0 comments on commit 679e8e0

Please sign in to comment.