Skip to main content

dsc.gg API 的简单易用的完全异步包装器。

项目描述

dsc.py 徽章 徽章 2

dsc.gg API 的简单易用的完全异步包装器。

安装

pip install dsc.py

用法

您可以在下面找到该库的所有方法和客户端初始化的示例用法。
有关库返回的对象的参考,请查看此

初始化客户端

import dsc

client = dsc.Client(key='YOUR_API_KEY')

获取用户

user = await client.get_user(USER_ID)

print(f"This user joined dsc.gg on {user.created_at}")

获取链接

link = await client.get_link('link')  # Can be either a slug or a full URL

print(f"This link owner's ID is: {link.owner_id}, and it leads to {link.redirect}")

获取应用

app = await client.get_app(APP_ID)

print(f"This app's owner's ID is {app.owner_id} and it was created at {app.created_at}")

获取热门链接

links = await client.get_top_links()

print(links[1].id)

获取用户的链接(仅限白名单)

links = await client.get_user_links(USER_ID)

print(links[0].redirect)

获取用户的应用程序(仅限白名单)

apps = await client.get_user_apps(USER_ID)

print(any([app.verified for app in apps]))  # check if the user has any verified apps

搜索(仅限白名单)

links = await client.search('search_query', limit=50)  # optional limit

print(len(links))

创建链接

你可以看中这个,并创建一个嵌入与链接一起使用,见下文。请注意,只有在更新链接时,创建时颜色才会起作用。

创建嵌入
embed = dsc.Embed(
    color=dsc.Color.red(),
    title='Embed title',
    image='image url',
    description='Embed description'
)

除了蛞蝓和重定向之外的任何东西都是可选的!构造函数。

res = await client.create_link('link slug', 'redirect', embed=embed)

if res.status == 200:
    print('Link created!')
else:
    print('An error occurred.')

更新链接

与创建类似,除了链接 slug 必须是现有链接之外,无需传入type
不将某些参数传递到嵌入将导致仅更新这些字段而将其他字段保持原样。

updated_embed = dsc.Embed(color=dsc.Color.red())
await client.update_link('link slug', password='youshallnotpass', unlisted=True, embed=updated_embed)

删除链接

await client.delete_link('link slug')

对象

dsc.py 包括 4 个对象 - 用户、链接、嵌入和颜色。将列出对象的每个属性,日期时间值采用 UTC。


应用程序

属性
  • ID:int
  • 所有者ID:int
  • 已验证:bool
  • created_at:datetime
  • 键:(Optional[str]仅当您拥有该应用程序时才显示)
方法
  • to_dict()- 以字典的形式返回对象

用户

属性
  • ID:int
  • 优质的:bool
  • 已验证:bool
  • 加入时间:datetime
  • 职员:bool
方法
  • to_dict()- 以字典的形式返回对象

关联

属性
  • ID:str
  • 重定向:str
  • 所有者ID:int
  • 嵌入:(dsc.Embed见下面的对象)
  • 编辑:List[int]
  • created_at:datetime
  • 类型:(str“机器人”、“服务器”、“模板”或“链接”)
  • 未上市:str
  • 禁用:bool
  • 撞到:datetime
  • 领域:str
方法
  • to_dict()- 以字典的形式返回对象

嵌入

在响应或用户创建中返回,嵌入是使您的链接脱颖而出的一种方式。

属性
  • 颜色:(dsc.Color见下图)
  • 标题:str
  • 描述:str
  • 图片str(图片网址)
方法
  • to_dict()- 以字典的形式返回对象
类方法
  • from_dict(data: dict)- 返回使用字典中的值初始化的嵌入对象

颜色

这与 discord.py 的 Color 非常相似,但也允许传递字符串。
所有 discord.py 内置颜色类方法也都在这里,例如。dsc.Color.red()

属性
  • 价值:int
方法
  • to_dict()- 以字典的形式返回对象
类方法

贡献

这个包是开源的,所以任何有足够python经验的人都可以为这个项目做出贡献!

报告问题

如果您在包或代码中发现任何错误/错误/错误,请随时创建问题并在此处报告。

修复/编辑内容

如果你想为这个包做出贡献,请 fork 存储库,进行更改,然后简单地创建一个 Pull Request!

接触

如果你想联系我:
邮件 - wulf.developer@gmail.com
Discord - wulf#9632

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

dsc.py-1.1.3.tar.gz (13.7 kB 查看哈希

已上传 source

内置分布

dsc.py-1.1.3-py3-none-any.whl (14.2 kB 查看哈希

已上传 py3