Skip to content

Commit

Permalink
feat(discord): support endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Apr 25, 2021
1 parent d5a5e67 commit 1646d9c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/adapter-discord/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export class DiscordBot extends Bot<'discord'> {

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 endpoint = discord.endpoint || 'https://discord.com/api/v8'
const url = `${endpoint}${path}`
const headers: Record<string, any> = {
Authorization: `Bot ${this.token}`,
}
Expand Down
10 changes: 5 additions & 5 deletions packages/adapter-discord/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Adapter } from 'koishi-core'
import { AxiosRequestConfig } from 'axios'
import { DiscordBot } from './bot'
import WsClient from './ws'
import * as dc from './types'
import * as DC from './types'
export * from './bot'
export * as dc from './types'

interface DiscordOptions extends Adapter.WsClientOptions {
endpoint?: string
axiosConfig?: AxiosRequestConfig
}

Expand All @@ -15,11 +15,11 @@ declare module 'koishi-core' {
discord?: DiscordOptions
}

interface Session {
interface Session {
discord?: {
mentions: dc.User[];
mentions: DC.User[]
// eslint-disable-next-line camelcase
webhook_id?: dc.snowflake
webhook_id?: DC.snowflake
flags: number
}
}
Expand Down

0 comments on commit 1646d9c

Please sign in to comment.