diff --git a/packages/axios/src/index.ts b/packages/axios/src/index.ts index 799a8ebc..426b7cf0 100644 --- a/packages/axios/src/index.ts +++ b/packages/axios/src/index.ts @@ -72,7 +72,7 @@ export class Quester { return this('PATCH', url, { ...config, data }) } - async head(url: string, config?: AxiosRequestConfig): Promise> { + async head(url: string, config?: AxiosRequestConfig): Promise> { const response = await this.axios(url, { ...config, method: 'HEAD' }) return response.headers } diff --git a/packages/core/src/bot.ts b/packages/core/src/bot.ts index f7d472e0..45e4f96e 100644 --- a/packages/core/src/bot.ts +++ b/packages/core/src/bot.ts @@ -120,6 +120,10 @@ export abstract class Bot { const { MessageEncoder } = this.constructor as typeof Bot return new MessageEncoder(this, channelId, null, options).send(content) } + + async supports(name: string, session: Partial = {}) { + return !!this[Universal.Methods[name]] + } } export namespace Bot { diff --git a/packages/core/src/universal.ts b/packages/core/src/universal.ts index a8e1dcce..fd0dab4a 100644 --- a/packages/core/src/universal.ts +++ b/packages/core/src/universal.ts @@ -3,6 +3,31 @@ import { SendOptions } from './session' import { Dict } from 'cosmokit' export namespace Universal { + export const Methods = { + 'message.get': 'getMessage', + 'message.list': 'getMessageList', + 'message.update': 'editMessage', + 'message.delete': 'deleteMessage', + 'reaction.create': 'createReaction', + 'reaction.delete': 'deleteReaction', + 'reaction.clear': 'clearReaction', + 'reaction.list': 'getReactions', + 'guild.get': 'getGuild', + 'guild.list': 'getGuildList', + 'guild.member.get': 'getGuildMember', + 'guild.member.list': 'getGuildMemberList', + 'guild.member.kick': 'kickGuildMember', + 'guild.member.mute': 'muteGuildMember', + 'guild.member.role': 'setGuildMemberRole', + 'guild.role.list': 'getGuildRoles', + 'guild.role.create': 'createGuildRole', + 'guild.role.update': 'modifyGuildRole', + 'guild.role.delete': 'deleteGuildRole', + 'channel.get': 'getChannel', + 'channel.list': 'getChannelList', + 'channel.mute': 'muteChannel', + } + export interface Methods { // message sendMessage(channelId: string, content: segment.Fragment, guildId?: string, options?: SendOptions): Promise