@satorijs/adapter-discord 3.9.2 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/bot.d.ts CHANGED
@@ -20,10 +20,12 @@ export declare class DiscordBot extends Bot<DiscordBot.Config> {
20
20
  getMessage(channelId: string, messageId: string): Promise<Universal.Message>;
21
21
  getMessageList(channelId: string, before?: string): Promise<{
22
22
  data: Universal.Message[];
23
+ next: string;
23
24
  }>;
24
25
  getUser(userId: string): Promise<Universal.User>;
25
- getGuildMemberList(guildId: string): Promise<{
26
+ getGuildMemberList(guildId: string, after?: string): Promise<{
26
27
  data: Universal.User[];
28
+ next: string;
27
29
  }>;
28
30
  getChannel(channelId: string): Promise<Universal.Channel>;
29
31
  getGuildMember(guildId: string, userId: string): Promise<{
@@ -36,15 +38,25 @@ export declare class DiscordBot extends Bot<DiscordBot.Config> {
36
38
  }>;
37
39
  kickGuildMember(guildId: string, userId: string): Promise<void>;
38
40
  getGuild(guildId: string): Promise<Universal.Guild>;
39
- getGuildList(): Promise<Universal.Guild[]>;
40
- getChannelList(guildId: string): Promise<Universal.Channel[]>;
41
+ getGuildList(after?: string): Promise<{
42
+ data: Universal.Guild[];
43
+ next: string;
44
+ }>;
45
+ getChannelList(guildId: string): Promise<{
46
+ data: Universal.Channel[];
47
+ }>;
41
48
  createReaction(channelId: string, messageId: string, emoji: string): Promise<void>;
42
49
  deleteReaction(channelId: string, messageId: string, emoji: string, userId?: string): Promise<void>;
43
50
  clearReaction(channelId: string, messageId: string, emoji?: string): Promise<void>;
44
- getReactions(channelId: string, messageId: string, emoji: string): Promise<Universal.User[]>;
51
+ getReactionList(channelId: string, messageId: string, emoji: string, after?: string): Promise<{
52
+ data: Universal.User[];
53
+ next: string;
54
+ }>;
45
55
  setGuildMemberRole(guildId: string, userId: string, roleId: string): Promise<void>;
46
56
  unsetGuildMemberRole(guildId: string, userId: string, roleId: string): Promise<void>;
47
- getGuildRoles(guildId: string): Promise<Universal.Role[]>;
57
+ getGuildRoleList(guildId: string): Promise<{
58
+ data: Universal.Role[];
59
+ }>;
48
60
  createGuildRole(guildId: string, data: Partial<Universal.Role>): Promise<string>;
49
61
  modifyGuildRole(guildId: string, roleId: string, data: Partial<Universal.Role>): Promise<void>;
50
62
  deleteGuildRole(guildId: string, roleId: string): Promise<void>;
@@ -54,6 +66,7 @@ export declare class DiscordBot extends Bot<DiscordBot.Config> {
54
66
  export declare namespace DiscordBot {
55
67
  interface Config extends Bot.Config, Quester.Config, DiscordMessageEncoder.Config, WsClient.Config {
56
68
  token: string;
69
+ slash?: boolean;
57
70
  }
58
71
  const Config: Schema<Config>;
59
72
  }
package/lib/index.js CHANGED
@@ -1196,10 +1196,14 @@ var decodeUser = /* @__PURE__ */ __name((user) => ({
1196
1196
  isBot: user.bot || false
1197
1197
  }), "decodeUser");
1198
1198
  var decodeGuild = /* @__PURE__ */ __name((data) => ({
1199
+ id: data.id,
1200
+ name: data.name,
1199
1201
  guildId: data.id,
1200
1202
  guildName: data.name
1201
1203
  }), "decodeGuild");
1202
1204
  var decodeChannel = /* @__PURE__ */ __name((data) => ({
1205
+ id: data.id,
1206
+ name: data.name,
1203
1207
  channelId: data.id,
1204
1208
  channelName: data.name
1205
1209
  }), "decodeChannel");
@@ -1994,16 +1998,20 @@ var _DiscordBot = class _DiscordBot extends import_satori5.Bot {
1994
1998
  return await decodeMessage(this, data);
1995
1999
  }
1996
2000
  async getMessageList(channelId, before) {
1997
- const data = await this.internal.getChannelMessages(channelId, { before, limit: 100 });
1998
- return { data: await Promise.all(data.reverse().map((data2) => decodeMessage(this, data2, {}, false))) };
2001
+ var _a;
2002
+ const messages = await this.internal.getChannelMessages(channelId, { before, limit: 100 });
2003
+ const data = await Promise.all(messages.reverse().map((data2) => decodeMessage(this, data2, {}, false)));
2004
+ return { data, next: (_a = data[0]) == null ? void 0 : _a.messageId };
1999
2005
  }
2000
2006
  async getUser(userId) {
2001
2007
  const data = await this.internal.getUser(userId);
2002
2008
  return decodeUser(data);
2003
2009
  }
2004
- async getGuildMemberList(guildId) {
2005
- const data = await this.internal.listGuildMembers(guildId);
2006
- return { data: data.map((v) => decodeUser(v.user)) };
2010
+ async getGuildMemberList(guildId, after) {
2011
+ var _a;
2012
+ const users = await this.internal.listGuildMembers(guildId, { after, limit: 1e3 });
2013
+ const data = users.map((v) => decodeUser(v.user));
2014
+ return { data, next: (_a = data[999]) == null ? void 0 : _a.userId };
2007
2015
  }
2008
2016
  async getChannel(channelId) {
2009
2017
  const data = await this.internal.getChannel(channelId);
@@ -2023,13 +2031,15 @@ var _DiscordBot = class _DiscordBot extends import_satori5.Bot {
2023
2031
  const data = await this.internal.getGuild(guildId);
2024
2032
  return decodeGuild(data);
2025
2033
  }
2026
- async getGuildList() {
2027
- const data = await this.internal.getCurrentUserGuilds();
2028
- return data.map(decodeGuild);
2034
+ async getGuildList(after) {
2035
+ var _a;
2036
+ const guilds = await this.internal.getCurrentUserGuilds({ after, limit: 200 });
2037
+ const data = guilds.map(decodeGuild);
2038
+ return { data, next: (_a = data[199]) == null ? void 0 : _a.id };
2029
2039
  }
2030
2040
  async getChannelList(guildId) {
2031
- const data = await this.internal.getGuildChannels(guildId);
2032
- return data.map(decodeChannel);
2041
+ const channels = await this.internal.getGuildChannels(guildId);
2042
+ return { data: channels.map(decodeChannel) };
2033
2043
  }
2034
2044
  createReaction(channelId, messageId, emoji) {
2035
2045
  return this.internal.createReaction(channelId, messageId, emoji);
@@ -2048,9 +2058,10 @@ var _DiscordBot = class _DiscordBot extends import_satori5.Bot {
2048
2058
  return this.internal.deleteAllReactionsForEmoji(channelId, messageId, emoji);
2049
2059
  }
2050
2060
  }
2051
- async getReactions(channelId, messageId, emoji) {
2052
- const data = await this.internal.getReactions(channelId, messageId, emoji);
2053
- return data.map(decodeUser);
2061
+ async getReactionList(channelId, messageId, emoji, after) {
2062
+ var _a;
2063
+ const data = await this.internal.getReactions(channelId, messageId, emoji, { after, limit: 100 });
2064
+ return { data: data.map(decodeUser), next: (_a = data[99]) == null ? void 0 : _a.id };
2054
2065
  }
2055
2066
  setGuildMemberRole(guildId, userId, roleId) {
2056
2067
  return this.internal.addGuildMemberRole(guildId, userId, roleId);
@@ -2058,9 +2069,9 @@ var _DiscordBot = class _DiscordBot extends import_satori5.Bot {
2058
2069
  unsetGuildMemberRole(guildId, userId, roleId) {
2059
2070
  return this.internal.removeGuildMemberRole(guildId, userId, roleId);
2060
2071
  }
2061
- async getGuildRoles(guildId) {
2072
+ async getGuildRoleList(guildId) {
2062
2073
  const data = await this.internal.getGuildRoles(guildId);
2063
- return data.map(decodeRole);
2074
+ return { data: data.map(decodeRole) };
2064
2075
  }
2065
2076
  async createGuildRole(guildId, data) {
2066
2077
  const role = await this.internal.createGuildRole(guildId, encodeRole(data));
@@ -2079,6 +2090,8 @@ var _DiscordBot = class _DiscordBot extends import_satori5.Bot {
2079
2090
  return this.sendMessage(channel.id, content, null, options);
2080
2091
  }
2081
2092
  async updateCommands(commands) {
2093
+ if (!this.config.slash)
2094
+ return;
2082
2095
  this.commands = commands;
2083
2096
  const local = Object.fromEntries(commands.map((cmd) => [cmd.name, cmd]));
2084
2097
  const remote = Object.fromEntries((await this.internal.getGlobalApplicationCommands(this.selfId, { with_localizations: true })).filter((cmd) => cmd.type === ApplicationCommand2.Type.CHAT_INPUT).map((cmd) => [cmd.name, cmd]));
@@ -2135,6 +2148,9 @@ __name(shapeEqual, "shapeEqual");
2135
2148
  import_satori5.Schema.object({
2136
2149
  token: import_satori5.Schema.string().description("机器人的用户令牌。").role("secret").required()
2137
2150
  }),
2151
+ import_satori5.Schema.object({
2152
+ slash: import_satori5.Schema.boolean().description("是否启用斜线指令。").default(true)
2153
+ }).description("功能设置"),
2138
2154
  WsClient.Config,
2139
2155
  DiscordMessageEncoder.Config,
2140
2156
  import_satori5.Quester.createConfig("https://discord.com/api/v10")