@alemonjs/kook 2.1.5 → 2.1.6
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/LICENSE +21 -0
- package/lib/config.d.ts +1 -1
- package/lib/config.js +6 -3
- package/lib/core/config.js +3 -1
- package/lib/index.js +270 -0
- package/lib/sdk/api.d.ts +78 -0
- package/lib/sdk/api.js +153 -0
- package/lib/sdk/wss.js +0 -1
- package/package.json +4 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013-present, Yuxi (Evan) You
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIdED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/lib/config.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export type Options = {
|
|
|
6
6
|
hideUnsupported?: boolean | number;
|
|
7
7
|
};
|
|
8
8
|
export declare const getKOOKConfig: () => Options;
|
|
9
|
-
export declare const getMaster: (UserId: string) => readonly [
|
|
9
|
+
export declare const getMaster: (UserId: string) => readonly [any, string];
|
package/lib/config.js
CHANGED
|
@@ -6,14 +6,17 @@ const getKOOKConfig = () => {
|
|
|
6
6
|
return value[platform] || {};
|
|
7
7
|
};
|
|
8
8
|
const getMaster = (UserId) => {
|
|
9
|
+
const values = getConfigValue() || {};
|
|
10
|
+
const mainMasterKey = values.master_key || [];
|
|
11
|
+
const mainMasterId = values.master_id || [];
|
|
9
12
|
const config = getKOOKConfig();
|
|
10
|
-
const
|
|
11
|
-
const
|
|
13
|
+
const masterKey = config.master_key || [];
|
|
14
|
+
const masterId = config.master_id || [];
|
|
12
15
|
const UserKey = useUserHashKey({
|
|
13
16
|
Platform: platform,
|
|
14
17
|
UserId: UserId
|
|
15
18
|
});
|
|
16
|
-
const is =
|
|
19
|
+
const is = mainMasterKey.includes(UserKey) || mainMasterId.includes(UserId) || masterKey.includes(UserKey) || masterId.includes(UserId);
|
|
17
20
|
return [is, UserKey];
|
|
18
21
|
};
|
|
19
22
|
|
package/lib/core/config.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -610,6 +610,276 @@ const main = () => {
|
|
|
610
610
|
const res = await api.use.mention(event);
|
|
611
611
|
consume([createResult(ResultCode.Ok, '请求完成', res)]);
|
|
612
612
|
}
|
|
613
|
+
else if (data.action === 'me.info') {
|
|
614
|
+
const res = await client
|
|
615
|
+
.userMe()
|
|
616
|
+
.then(r => {
|
|
617
|
+
const d = r?.data ?? r;
|
|
618
|
+
const [isMaster, UserKey] = getMaster(String(d?.id));
|
|
619
|
+
return createResult(ResultCode.Ok, data.action, {
|
|
620
|
+
UserId: String(d?.id),
|
|
621
|
+
UserName: d?.username,
|
|
622
|
+
UserAvatar: d?.avatar ?? '',
|
|
623
|
+
IsBot: true,
|
|
624
|
+
IsMaster: isMaster,
|
|
625
|
+
UserKey
|
|
626
|
+
});
|
|
627
|
+
})
|
|
628
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
629
|
+
consume([res]);
|
|
630
|
+
}
|
|
631
|
+
else if (data.action === 'message.delete') {
|
|
632
|
+
const messageId = data.payload.MessageId;
|
|
633
|
+
const res = await client
|
|
634
|
+
.messageDelete(messageId)
|
|
635
|
+
.then(r => createResult(ResultCode.Ok, data.action, r))
|
|
636
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
637
|
+
consume([res]);
|
|
638
|
+
}
|
|
639
|
+
else if (data.action === 'message.edit') {
|
|
640
|
+
const messageId = data.payload.MessageId;
|
|
641
|
+
const format = data.payload.params?.format;
|
|
642
|
+
const content = format?.map(i => i.value).join('') ?? '';
|
|
643
|
+
const res = await client
|
|
644
|
+
.messageUpdate({ msg_id: messageId, content })
|
|
645
|
+
.then(r => createResult(ResultCode.Ok, data.action, r))
|
|
646
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
647
|
+
consume([res]);
|
|
648
|
+
}
|
|
649
|
+
else if (data.action === 'reaction.add') {
|
|
650
|
+
const res = await client
|
|
651
|
+
.messageAddReaction({ msg_id: data.payload.MessageId, emoji: data.payload.EmojiId })
|
|
652
|
+
.then(r => createResult(ResultCode.Ok, data.action, r))
|
|
653
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
654
|
+
consume([res]);
|
|
655
|
+
}
|
|
656
|
+
else if (data.action === 'reaction.remove') {
|
|
657
|
+
const res = await client
|
|
658
|
+
.messageDeleteReaction({ msg_id: data.payload.MessageId, emoji: data.payload.EmojiId, user_id: '' })
|
|
659
|
+
.then(r => createResult(ResultCode.Ok, data.action, r))
|
|
660
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
661
|
+
consume([res]);
|
|
662
|
+
}
|
|
663
|
+
else if (data.action === 'member.info') {
|
|
664
|
+
const guildId = data.payload.params?.guildId ?? data.payload.GuildId;
|
|
665
|
+
const userId = data.payload.params?.userId ?? data.payload.UserId;
|
|
666
|
+
const res = await client
|
|
667
|
+
.userView(guildId, userId)
|
|
668
|
+
.then(r => createResult(ResultCode.Ok, data.action, r?.data ?? r))
|
|
669
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
670
|
+
consume([res]);
|
|
671
|
+
}
|
|
672
|
+
else if (data.action === 'member.list') {
|
|
673
|
+
const guildId = data.payload.GuildId;
|
|
674
|
+
const res = await client
|
|
675
|
+
.guildUserList(guildId)
|
|
676
|
+
.then(r => createResult(ResultCode.Ok, data.action, r?.data ?? r))
|
|
677
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
678
|
+
consume([res]);
|
|
679
|
+
}
|
|
680
|
+
else if (data.action === 'member.kick') {
|
|
681
|
+
const res = await client
|
|
682
|
+
.guildKickout(data.payload.GuildId, data.payload.UserId)
|
|
683
|
+
.then(r => createResult(ResultCode.Ok, data.action, r))
|
|
684
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
685
|
+
consume([res]);
|
|
686
|
+
}
|
|
687
|
+
else if (data.action === 'member.ban') {
|
|
688
|
+
const res = await client
|
|
689
|
+
.blacklistCreate({ guild_id: data.payload.GuildId, target_id: data.payload.UserId, remark: data.payload.params?.reason })
|
|
690
|
+
.then(r => createResult(ResultCode.Ok, data.action, r))
|
|
691
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
692
|
+
consume([res]);
|
|
693
|
+
}
|
|
694
|
+
else if (data.action === 'member.unban') {
|
|
695
|
+
const res = await client
|
|
696
|
+
.blacklistDelete({ guild_id: data.payload.GuildId, target_id: data.payload.UserId })
|
|
697
|
+
.then(r => createResult(ResultCode.Ok, data.action, r))
|
|
698
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
699
|
+
consume([res]);
|
|
700
|
+
}
|
|
701
|
+
else if (data.action === 'member.mute') {
|
|
702
|
+
const duration = data.payload.params?.duration ?? 0;
|
|
703
|
+
if (duration > 0) {
|
|
704
|
+
const res = await client
|
|
705
|
+
.guildMuteCreate(data.payload.GuildId, data.payload.UserId, 1)
|
|
706
|
+
.then(r => createResult(ResultCode.Ok, data.action, r))
|
|
707
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
708
|
+
consume([res]);
|
|
709
|
+
}
|
|
710
|
+
else {
|
|
711
|
+
const res = await client
|
|
712
|
+
.guildMuteDelete(data.payload.GuildId, data.payload.UserId, 1)
|
|
713
|
+
.then(r => createResult(ResultCode.Ok, data.action, r))
|
|
714
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
715
|
+
consume([res]);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
else if (data.action === 'member.card') {
|
|
719
|
+
const res = await client
|
|
720
|
+
.guildNickname(data.payload.GuildId, data.payload.params?.card ?? '', data.payload.UserId)
|
|
721
|
+
.then(r => createResult(ResultCode.Ok, data.action, r))
|
|
722
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
723
|
+
consume([res]);
|
|
724
|
+
}
|
|
725
|
+
else if (data.action === 'guild.info') {
|
|
726
|
+
const res = await client
|
|
727
|
+
.guildView(data.payload.GuildId)
|
|
728
|
+
.then(r => createResult(ResultCode.Ok, data.action, r?.data ?? r))
|
|
729
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
730
|
+
consume([res]);
|
|
731
|
+
}
|
|
732
|
+
else if (data.action === 'guild.list') {
|
|
733
|
+
const res = await client
|
|
734
|
+
.guildList()
|
|
735
|
+
.then(r => createResult(ResultCode.Ok, data.action, r?.data ?? r))
|
|
736
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
737
|
+
consume([res]);
|
|
738
|
+
}
|
|
739
|
+
else if (data.action === 'me.guilds') {
|
|
740
|
+
const res = await client
|
|
741
|
+
.guildList()
|
|
742
|
+
.then(r => createResult(ResultCode.Ok, data.action, r?.data ?? r))
|
|
743
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
744
|
+
consume([res]);
|
|
745
|
+
}
|
|
746
|
+
else if (data.action === 'channel.info') {
|
|
747
|
+
const res = await client
|
|
748
|
+
.channelView(data.payload.ChannelId)
|
|
749
|
+
.then(r => createResult(ResultCode.Ok, data.action, r?.data ?? r))
|
|
750
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
751
|
+
consume([res]);
|
|
752
|
+
}
|
|
753
|
+
else if (data.action === 'channel.list') {
|
|
754
|
+
const res = await client
|
|
755
|
+
.channelList(data.payload.GuildId)
|
|
756
|
+
.then(r => createResult(ResultCode.Ok, data.action, r?.data ?? r))
|
|
757
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
758
|
+
consume([res]);
|
|
759
|
+
}
|
|
760
|
+
else if (data.action === 'channel.create') {
|
|
761
|
+
const params = data.payload.params;
|
|
762
|
+
const res = await client
|
|
763
|
+
.channelCreate({ guild_id: data.payload.GuildId, name: params.name, type: params.type ? Number(params.type) : 1, parent_id: params.parentId })
|
|
764
|
+
.then(r => createResult(ResultCode.Ok, data.action, r?.data ?? r))
|
|
765
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
766
|
+
consume([res]);
|
|
767
|
+
}
|
|
768
|
+
else if (data.action === 'channel.update') {
|
|
769
|
+
const params = data.payload.params;
|
|
770
|
+
const res = await client
|
|
771
|
+
.channelUpdate({ channel_id: data.payload.ChannelId, name: params.name, topic: params.topic })
|
|
772
|
+
.then(r => createResult(ResultCode.Ok, data.action, r?.data ?? r))
|
|
773
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
774
|
+
consume([res]);
|
|
775
|
+
}
|
|
776
|
+
else if (data.action === 'channel.delete') {
|
|
777
|
+
const res = await client
|
|
778
|
+
.channelDelete(data.payload.ChannelId)
|
|
779
|
+
.then(r => createResult(ResultCode.Ok, data.action, r))
|
|
780
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
781
|
+
consume([res]);
|
|
782
|
+
}
|
|
783
|
+
else if (data.action === 'role.list') {
|
|
784
|
+
const res = await client
|
|
785
|
+
.guildRoleList(data.payload.GuildId)
|
|
786
|
+
.then(r => createResult(ResultCode.Ok, data.action, r?.data ?? r))
|
|
787
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
788
|
+
consume([res]);
|
|
789
|
+
}
|
|
790
|
+
else if (data.action === 'role.create') {
|
|
791
|
+
const params = data.payload.params;
|
|
792
|
+
const res = await client
|
|
793
|
+
.guildRoleCreate({ guild_id: data.payload.GuildId, name: params.name })
|
|
794
|
+
.then(r => createResult(ResultCode.Ok, data.action, r?.data ?? r))
|
|
795
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
796
|
+
consume([res]);
|
|
797
|
+
}
|
|
798
|
+
else if (data.action === 'role.update') {
|
|
799
|
+
const params = data.payload.params;
|
|
800
|
+
const res = await client
|
|
801
|
+
.guildRoleUpdate({ guild_id: data.payload.GuildId, role_id: Number(data.payload.RoleId), name: params.name, color: params.color })
|
|
802
|
+
.then(r => createResult(ResultCode.Ok, data.action, r?.data ?? r))
|
|
803
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
804
|
+
consume([res]);
|
|
805
|
+
}
|
|
806
|
+
else if (data.action === 'role.delete') {
|
|
807
|
+
const res = await client
|
|
808
|
+
.guildRoleDelete({ guild_id: data.payload.GuildId, role_id: Number(data.payload.RoleId) })
|
|
809
|
+
.then(r => createResult(ResultCode.Ok, data.action, r))
|
|
810
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
811
|
+
consume([res]);
|
|
812
|
+
}
|
|
813
|
+
else if (data.action === 'role.assign') {
|
|
814
|
+
const res = await client
|
|
815
|
+
.guildRoleGrant({ guild_id: data.payload.GuildId, user_id: data.payload.UserId, role_id: Number(data.payload.RoleId) })
|
|
816
|
+
.then(r => createResult(ResultCode.Ok, data.action, r))
|
|
817
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
818
|
+
consume([res]);
|
|
819
|
+
}
|
|
820
|
+
else if (data.action === 'role.remove') {
|
|
821
|
+
const res = await client
|
|
822
|
+
.guildRoleRevoke({ guild_id: data.payload.GuildId, user_id: data.payload.UserId, role_id: Number(data.payload.RoleId) })
|
|
823
|
+
.then(r => createResult(ResultCode.Ok, data.action, r))
|
|
824
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
825
|
+
consume([res]);
|
|
826
|
+
}
|
|
827
|
+
else if (data.action === 'message.get') {
|
|
828
|
+
const res = await client
|
|
829
|
+
.messageView(data.payload.MessageId)
|
|
830
|
+
.then(r => createResult(ResultCode.Ok, data.action, r?.data ?? r))
|
|
831
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
832
|
+
consume([res]);
|
|
833
|
+
}
|
|
834
|
+
else if (data.action === 'guild.leave') {
|
|
835
|
+
const res = await client
|
|
836
|
+
.guildLeave(data.payload.GuildId)
|
|
837
|
+
.then(r => createResult(ResultCode.Ok, data.action, r))
|
|
838
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
839
|
+
consume([res]);
|
|
840
|
+
}
|
|
841
|
+
else if (data.action === 'user.info') {
|
|
842
|
+
const res = await client
|
|
843
|
+
.userView(data.payload.GuildId ?? '', data.payload.UserId)
|
|
844
|
+
.then(r => createResult(ResultCode.Ok, data.action, r?.data ?? r))
|
|
845
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
846
|
+
consume([res]);
|
|
847
|
+
}
|
|
848
|
+
else if (data.action === 'media.upload') {
|
|
849
|
+
const params = data.payload.params;
|
|
850
|
+
const fileData = params?.url ?? params?.data;
|
|
851
|
+
if (!fileData) {
|
|
852
|
+
consume([createResult(ResultCode.FailParams, 'Missing url or data', null)]);
|
|
853
|
+
}
|
|
854
|
+
else {
|
|
855
|
+
const res = await client
|
|
856
|
+
.postImage(fileData, params?.name)
|
|
857
|
+
.then(r => createResult(ResultCode.Ok, data.action, r))
|
|
858
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
859
|
+
consume([res]);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
else if (data.action === 'history.list') {
|
|
863
|
+
const res = await client
|
|
864
|
+
.messageList(data.payload.ChannelId, { page_size: data.payload.params?.limit })
|
|
865
|
+
.then(r => createResult(ResultCode.Ok, data.action, r?.data ?? r))
|
|
866
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
867
|
+
consume([res]);
|
|
868
|
+
}
|
|
869
|
+
else if (data.action === 'reaction.list') {
|
|
870
|
+
const res = await client
|
|
871
|
+
.messageReactionList({ msg_id: data.payload.MessageId, emoji: data.payload.EmojiId })
|
|
872
|
+
.then(r => createResult(ResultCode.Ok, data.action, r?.data ?? r))
|
|
873
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
874
|
+
consume([res]);
|
|
875
|
+
}
|
|
876
|
+
else if (data.action === 'member.search') {
|
|
877
|
+
const res = await client
|
|
878
|
+
.guildUserList(data.payload.GuildId, { search: data.payload.params?.keyword, page_size: data.payload.params?.limit })
|
|
879
|
+
.then(r => createResult(ResultCode.Ok, data.action, r?.data ?? r))
|
|
880
|
+
.catch(err => createResult(ResultCode.Fail, data.action, err));
|
|
881
|
+
consume([res]);
|
|
882
|
+
}
|
|
613
883
|
else {
|
|
614
884
|
consume([createResult(ResultCode.Fail, '未知请求,请尝试升级版本', null)]);
|
|
615
885
|
}
|
package/lib/sdk/api.d.ts
CHANGED
|
@@ -79,6 +79,12 @@ export declare class KOOKAPI {
|
|
|
79
79
|
message: string;
|
|
80
80
|
data: any[];
|
|
81
81
|
}>;
|
|
82
|
+
messageList(target_id: string, params?: {
|
|
83
|
+
msg_id?: string;
|
|
84
|
+
pin?: number;
|
|
85
|
+
flag?: string;
|
|
86
|
+
page_size?: number;
|
|
87
|
+
}): Promise<any>;
|
|
82
88
|
messageAddReaction(data: {
|
|
83
89
|
msg_id: string;
|
|
84
90
|
emoji: string;
|
|
@@ -157,4 +163,76 @@ export declare class KOOKAPI {
|
|
|
157
163
|
message: string;
|
|
158
164
|
data: any;
|
|
159
165
|
}>;
|
|
166
|
+
guildList(): Promise<any>;
|
|
167
|
+
guildView(guild_id: string): Promise<any>;
|
|
168
|
+
guildUserList(guild_id: string, params?: {
|
|
169
|
+
channel_id?: string;
|
|
170
|
+
search?: string;
|
|
171
|
+
role_id?: number;
|
|
172
|
+
mobile_verified?: number;
|
|
173
|
+
active_time?: number;
|
|
174
|
+
joined_at?: number;
|
|
175
|
+
page?: number;
|
|
176
|
+
page_size?: number;
|
|
177
|
+
}): Promise<any>;
|
|
178
|
+
guildLeave(guild_id: string): Promise<any>;
|
|
179
|
+
guildNickname(guild_id: string, nickname: string, user_id?: string): Promise<any>;
|
|
180
|
+
guildMuteCreate(guild_id: string, user_id: string, type: 1 | 2): Promise<any>;
|
|
181
|
+
guildMuteDelete(guild_id: string, user_id: string, type: 1 | 2): Promise<any>;
|
|
182
|
+
messageView(msg_id: string): Promise<any>;
|
|
183
|
+
channelList(guild_id: string): Promise<any>;
|
|
184
|
+
channelView(channel_id: string): Promise<any>;
|
|
185
|
+
channelCreate(data: {
|
|
186
|
+
guild_id: string;
|
|
187
|
+
name: string;
|
|
188
|
+
type?: number;
|
|
189
|
+
parent_id?: string;
|
|
190
|
+
limit_amount?: number;
|
|
191
|
+
voice_quality?: string;
|
|
192
|
+
}): Promise<any>;
|
|
193
|
+
channelUpdate(data: {
|
|
194
|
+
channel_id: string;
|
|
195
|
+
name?: string;
|
|
196
|
+
topic?: string;
|
|
197
|
+
slow_mode?: number;
|
|
198
|
+
}): Promise<any>;
|
|
199
|
+
channelDelete(channel_id: string): Promise<any>;
|
|
200
|
+
guildRoleList(guild_id: string): Promise<any>;
|
|
201
|
+
guildRoleCreate(data: {
|
|
202
|
+
guild_id: string;
|
|
203
|
+
name?: string;
|
|
204
|
+
}): Promise<any>;
|
|
205
|
+
guildRoleUpdate(data: {
|
|
206
|
+
guild_id: string;
|
|
207
|
+
role_id: number;
|
|
208
|
+
name?: string;
|
|
209
|
+
color?: number;
|
|
210
|
+
hoist?: 0 | 1;
|
|
211
|
+
mentionable?: 0 | 1;
|
|
212
|
+
permissions?: number;
|
|
213
|
+
}): Promise<any>;
|
|
214
|
+
guildRoleDelete(data: {
|
|
215
|
+
guild_id: string;
|
|
216
|
+
role_id: number;
|
|
217
|
+
}): Promise<any>;
|
|
218
|
+
guildRoleGrant(data: {
|
|
219
|
+
guild_id: string;
|
|
220
|
+
user_id: string;
|
|
221
|
+
role_id: number;
|
|
222
|
+
}): Promise<any>;
|
|
223
|
+
guildRoleRevoke(data: {
|
|
224
|
+
guild_id: string;
|
|
225
|
+
user_id: string;
|
|
226
|
+
role_id: number;
|
|
227
|
+
}): Promise<any>;
|
|
228
|
+
blacklistCreate(data: {
|
|
229
|
+
guild_id: string;
|
|
230
|
+
target_id: string;
|
|
231
|
+
remark?: string;
|
|
232
|
+
del_msg_days?: number;
|
|
233
|
+
}): Promise<any>;
|
|
234
|
+
blacklistDelete(data: {
|
|
235
|
+
guild_id: string;
|
|
236
|
+
target_id: string;
|
|
237
|
+
}): Promise<any>;
|
|
160
238
|
}
|
package/lib/sdk/api.js
CHANGED
|
@@ -107,6 +107,13 @@ class KOOKAPI {
|
|
|
107
107
|
data
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
+
messageList(target_id, params) {
|
|
111
|
+
return this.service({
|
|
112
|
+
method: 'get',
|
|
113
|
+
url: ApiEnum.MessageList,
|
|
114
|
+
params: { target_id, ...params }
|
|
115
|
+
});
|
|
116
|
+
}
|
|
110
117
|
messageAddReaction(data) {
|
|
111
118
|
return this.service({
|
|
112
119
|
method: 'post',
|
|
@@ -158,6 +165,152 @@ class KOOKAPI {
|
|
|
158
165
|
}
|
|
159
166
|
});
|
|
160
167
|
}
|
|
168
|
+
guildList() {
|
|
169
|
+
return this.service({
|
|
170
|
+
method: 'get',
|
|
171
|
+
url: ApiEnum.GuildList
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
guildView(guild_id) {
|
|
175
|
+
return this.service({
|
|
176
|
+
method: 'get',
|
|
177
|
+
url: ApiEnum.GuildView,
|
|
178
|
+
params: { guild_id }
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
guildUserList(guild_id, params) {
|
|
182
|
+
return this.service({
|
|
183
|
+
method: 'get',
|
|
184
|
+
url: ApiEnum.GuildUserList,
|
|
185
|
+
params: { guild_id, ...params }
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
guildLeave(guild_id) {
|
|
189
|
+
return this.service({
|
|
190
|
+
method: 'post',
|
|
191
|
+
url: ApiEnum.GuildLeave,
|
|
192
|
+
data: { guild_id }
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
guildNickname(guild_id, nickname, user_id) {
|
|
196
|
+
return this.service({
|
|
197
|
+
method: 'post',
|
|
198
|
+
url: ApiEnum.GuildNickname,
|
|
199
|
+
data: { guild_id, nickname, ...(user_id ? { user_id } : {}) }
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
guildMuteCreate(guild_id, user_id, type) {
|
|
203
|
+
return this.service({
|
|
204
|
+
method: 'post',
|
|
205
|
+
url: ApiEnum.GuildMuteCreate,
|
|
206
|
+
data: { guild_id, user_id, type }
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
guildMuteDelete(guild_id, user_id, type) {
|
|
210
|
+
return this.service({
|
|
211
|
+
method: 'post',
|
|
212
|
+
url: ApiEnum.GuildMuteDelete,
|
|
213
|
+
data: { guild_id, user_id, type }
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
messageView(msg_id) {
|
|
217
|
+
return this.service({
|
|
218
|
+
method: 'get',
|
|
219
|
+
url: ApiEnum.MessageView,
|
|
220
|
+
params: { msg_id }
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
channelList(guild_id) {
|
|
224
|
+
return this.service({
|
|
225
|
+
method: 'get',
|
|
226
|
+
url: ApiEnum.ChannelList,
|
|
227
|
+
params: { guild_id }
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
channelView(channel_id) {
|
|
231
|
+
return this.service({
|
|
232
|
+
method: 'get',
|
|
233
|
+
url: ApiEnum.ChannelView,
|
|
234
|
+
params: { target_id: channel_id }
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
channelCreate(data) {
|
|
238
|
+
return this.service({
|
|
239
|
+
method: 'post',
|
|
240
|
+
url: ApiEnum.ChannelCreate,
|
|
241
|
+
data
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
channelUpdate(data) {
|
|
245
|
+
return this.service({
|
|
246
|
+
method: 'post',
|
|
247
|
+
url: ApiEnum.ChannelUpdate,
|
|
248
|
+
data
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
channelDelete(channel_id) {
|
|
252
|
+
return this.service({
|
|
253
|
+
method: 'post',
|
|
254
|
+
url: ApiEnum.ChannelDelete,
|
|
255
|
+
data: { channel_id }
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
guildRoleList(guild_id) {
|
|
259
|
+
return this.service({
|
|
260
|
+
method: 'get',
|
|
261
|
+
url: ApiEnum.GuildRoleList,
|
|
262
|
+
params: { guild_id }
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
guildRoleCreate(data) {
|
|
266
|
+
return this.service({
|
|
267
|
+
method: 'post',
|
|
268
|
+
url: ApiEnum.GuildRoleCreate,
|
|
269
|
+
data
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
guildRoleUpdate(data) {
|
|
273
|
+
return this.service({
|
|
274
|
+
method: 'post',
|
|
275
|
+
url: ApiEnum.GuildRoleUpdate,
|
|
276
|
+
data
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
guildRoleDelete(data) {
|
|
280
|
+
return this.service({
|
|
281
|
+
method: 'post',
|
|
282
|
+
url: ApiEnum.GuildRoleDelete,
|
|
283
|
+
data
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
guildRoleGrant(data) {
|
|
287
|
+
return this.service({
|
|
288
|
+
method: 'post',
|
|
289
|
+
url: ApiEnum.GuildRoleGrant,
|
|
290
|
+
data
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
guildRoleRevoke(data) {
|
|
294
|
+
return this.service({
|
|
295
|
+
method: 'post',
|
|
296
|
+
url: ApiEnum.GuildRoleRevoke,
|
|
297
|
+
data
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
blacklistCreate(data) {
|
|
301
|
+
return this.service({
|
|
302
|
+
method: 'post',
|
|
303
|
+
url: ApiEnum.BlacklistCreate,
|
|
304
|
+
data
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
blacklistDelete(data) {
|
|
308
|
+
return this.service({
|
|
309
|
+
method: 'post',
|
|
310
|
+
url: ApiEnum.BlacklistDelete,
|
|
311
|
+
data
|
|
312
|
+
});
|
|
313
|
+
}
|
|
161
314
|
}
|
|
162
315
|
|
|
163
316
|
export { API_URL, KOOKAPI };
|
package/lib/sdk/wss.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alemonjs/kook",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.6",
|
|
4
4
|
"description": "kook platform connection",
|
|
5
5
|
"author": "lemonade",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,5 +58,6 @@
|
|
|
58
58
|
"repository": {
|
|
59
59
|
"type": "git",
|
|
60
60
|
"url": "https://github.com/lemonade-lab/alemonjs.git"
|
|
61
|
-
}
|
|
62
|
-
|
|
61
|
+
},
|
|
62
|
+
"gitHead": "743b70375f728a1584ae149bbadcd04378540ade"
|
|
63
|
+
}
|