-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/qqguild'
- Loading branch information
Showing
8 changed files
with
1,189 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ | |
"@satorijs/satori": "^3.0.0-alpha.1" | ||
}, | ||
"dependencies": { | ||
"@qq-guild-sdk/core": "^2.2.2", | ||
"qface": "^1.4.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import { Quester } from '@satorijs/satori' | ||
import * as QQGuild from './types' | ||
|
||
export class Internal { | ||
constructor(private http: Quester) { } | ||
|
||
async getMe() { | ||
return this.http.get<QQGuild.User>('/users/@me') | ||
} | ||
|
||
/** https://bot.q.qq.com/wiki/develop/api/openapi/dms/post_dms.html */ | ||
async createDMS(recipient_id: string, source_guild_id: string) { | ||
return this.http.post<QQGuild.DMS>('/users/@me/dms', { | ||
recipient_id, source_guild_id, | ||
}) | ||
} | ||
|
||
async getMessage(channelId: string, messageId: string) { | ||
const { message } = await this.http.get<{ | ||
message: QQGuild.Message | ||
}>(`/channels/${channelId}/messages/${messageId}`) | ||
return message | ||
} | ||
|
||
async getGuilds(params?: Partial<{ | ||
before: string | ||
after: string | ||
limit: number | ||
}>) { | ||
return this.http.get<QQGuild.Guild[]>('/users/@me/guilds', { | ||
params, | ||
}) | ||
} | ||
|
||
async getGuild(guild_id: string) { | ||
return this.http.get<QQGuild.Guild>(`/guilds/${guild_id}`) | ||
} | ||
|
||
async getChannels(guild_id: string) { | ||
return this.http.get<QQGuild.Channel[]>(`/guilds/${guild_id}/channels`) | ||
} | ||
|
||
async getChannel(channel_id: string) { | ||
return this.http.get<QQGuild.Channel>(`/channels/${channel_id}`) | ||
} | ||
|
||
async getGuildMembers(guild_id: string, params?: Partial<{ | ||
after: string | ||
limit: number | ||
}>) { | ||
return this.http.get<QQGuild.Member[]>(`/guilds/${guild_id}/members`, { params }) | ||
} | ||
|
||
async getGuildMember(guild_id: string, user_id: string) { | ||
return this.http.get<QQGuild.Member>(`/guilds/${guild_id}/members/${user_id}`) | ||
} | ||
|
||
async deleteGuildMember(guild_id: string, user_id: string) { | ||
return this.http.delete(`/guilds/${guild_id}/members/${user_id}`) | ||
} | ||
|
||
async getGuildRoles(guild_id: string) { | ||
return this.http.get<QQGuild.Role[]>(`/guilds/${guild_id}/roles`) | ||
} | ||
|
||
async muteGuildMember(guild_id: string, user_id: string, duration: number) { | ||
return this.http.patch(`/guilds/${guild_id}/members/${user_id}/mute`, { | ||
mute_seconds: duration / 1000, | ||
}) | ||
} | ||
|
||
async getReactions(channel_id: string, message_id: string, type: string, id: string, params?: Partial<{ | ||
cookie: string | ||
limit: number | ||
}>) { | ||
return this.http.get<{ | ||
cookie: string | ||
is_end: boolean | ||
users: Pick<QQGuild.User, 'id' | 'username' | 'avatar'>[] | ||
}>(`/channels/${channel_id}/messages/${message_id}/reactions/${type}/${id}`, { | ||
params, | ||
}) | ||
} | ||
|
||
async createReaction(channel_id: string, message_id: string, type: string, id: string) { | ||
return this.http.put(`/channels/${channel_id}/messages/${message_id}/reactions/${type}/${id}`) | ||
} | ||
|
||
async deleteReaction(channel_id: string, message_id: string, type: string, id: string) { | ||
return this.http.delete(`/channels/${channel_id}/messages/${message_id}/reactions/${type}/${id}`) | ||
} | ||
|
||
async deleteMessage(channel_id: string, message_id: string) { | ||
return this.http.delete(`/channels/${channel_id}/messages/${message_id}`) | ||
} | ||
|
||
async deleteDM(guild_id: string, message_id: string) { | ||
// guild_id 是 createDMS 之后的 id | ||
return this.http.delete(`/dms/${guild_id}/messages/${message_id}`) | ||
} | ||
} |
Oops, something went wrong.