Skip to content

Commit 9de1629

Browse files
author
alexzxchen
committed
机器人 go sdk 新增查询语音子频道成员的接口
TAPD: --story==873994845
1 parent 099ada8 commit 9de1629

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

examples/apitest/channel_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,17 @@ func TestChannel(t *testing.T) {
5353
}
5454
},
5555
)
56+
t.Run(
57+
"get voice channel member list test", func(t *testing.T) {
58+
testChannelID := "1572139"
59+
members, err := api.ListVoiceChannelMembers(ctx, testChannelID)
60+
if err != nil {
61+
t.Error(err)
62+
}
63+
for _, member := range members {
64+
t.Logf("member%v", member)
65+
}
66+
67+
},
68+
)
5669
}

openapi/iface.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ type ChannelAPI interface {
9797
// CreatePrivateChannel 创建私密子频道
9898
CreatePrivateChannel(ctx context.Context,
9999
guildID string, value *dto.ChannelValueObject, userIds []string) (*dto.Channel, error)
100+
ListVoiceChannelMembers(ctx context.Context, channelID string) ([]*dto.Member, error)
100101
}
101102

102103
// ChannelPermissionsAPI 子频道权限相关接口

openapi/v1/channels.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,18 @@ func (o *openAPI) CreatePrivateChannel(ctx context.Context, guildID string, valu
8787
}
8888
return o.PostChannel(ctx, guildID, value)
8989
}
90+
91+
// ListVoiceChannelMembers 查询语音子频道成员列表
92+
func (o *openAPI) ListVoiceChannelMembers(ctx context.Context, channelID string) ([]*dto.Member, error) {
93+
resp, err := o.request(ctx).
94+
SetPathParam("channel_id", channelID).
95+
Get(o.getURL(voiceChannelMembersURI))
96+
if err != nil {
97+
return nil, err
98+
}
99+
members := make([]*dto.Member, 0)
100+
if err := json.Unmarshal(resp.Body(), &members); err != nil {
101+
return nil, err
102+
}
103+
return members, nil
104+
}

openapi/v1/resource.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ const (
6868
httpSessionURI uri = "/gateway/webhook/sessions/{session_id}"
6969

7070
messageSettingURI uri = "/guilds/{guild_id}/message/setting"
71+
72+
voiceChannelMembersURI uri = "/channels/{channel_id}/voice/members"
7173
)
7274

7375
// getURL 获取接口地址,会处理沙箱环境判断

0 commit comments

Comments
 (0)