创建日程

日程子频道创建一个日程。

注意

要求操作人具有管理频道的权限,如果是机器人,则需要将机器人设置为管理员。

使用示例

import time
import botpy
from botpy.message import Message

class MyClient(botpy.Client):
    async def on_at_message_create(self, message: Message):
        delay = 1000 * 60
        start_time = int(round(time.time() * 1000)) + delay
        end_time = start_time + delay
        await self.api.create_schedule(
            channel_id="日程子频道ID",
            name="test",
            start_timestamp=str(start_time),
            end_timestamp=str(end_time),
            jump_channel_id="日程子频道ID",
            remind_type="0",
        )

intents = botpy.Intents(public_guild_messages=True)
client = MyClient(intents=intents)
client.run(appid={appid}, token={token})

参数说明

字段名必填类型描述
channel_idstring子频道 ID
namestring日程名称
descriptionstring日程描述
start_timestampstring日程开始时间戳(ms) ,日程开始时间必须大于传当前时间
end_timestampstring日程结束时间戳(ms) ,日程结束时间必须大于日程开始时间
creatorMember创建者
jump_channel_idstring日程开始时跳转到的子频道 ID
remind_typestring日程提醒类型,取值参考RemindType

返回说明

返回 Schedule 对象。

Schedule

字段名类型描述
idstring日程 ID
namestring日程名称
descriptionstring日程描述
start_timestampstring日程开始时间戳(ms)
end_timestampstring日程结束时间戳(ms)
creatorMember创建者
jump_channel_idstring日程开始时跳转到的子频道 ID
remind_typestring日程提醒类型,取值参考RemindType

Member

字段名类型描述
userUser用户的频道基础信息,只有成员相关接口中会填充此信息
nickstring用户在频道内的昵称
joined_atstring用户加入频道的时间,是个 ISO8601 timestamp 字符串,例:"2021-11-23T15:16:48+08:00"

User

字段名类型描述
idstring用户 ID
usernamestring用户名
botboolean是否是机器人

RemindType

提醒类型 id描述
0不提醒
1开始时提醒
2开始前 5 分钟提醒
3开始前 15 分钟提醒
4开始前 30 分钟提醒
5开始前 60 分钟提醒

返回示例

data

{
  "id": "xxxxxx",
  "name": "xxxxxx",
  "description": "xxxxxx",
  "start_timestamp": "1641913200000",
  "end_timestamp": "1641916800000",
  "creator": {
    "user": {
      "id": "xxxxxx",
      "username": "xxxxxx",
      "bot": false
    },
    "nick": "",
    "joined_at": "2021-11-24T16:51:35+08:00"
  },
  "jump_channel_id": "0",
  "remind_type": "2"
}