dsc.py
1.0.0
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'
)除了slug和重定向以外的任何其他内容都是可选的!构造函数。
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个对象 - 用户,链接,嵌入和颜色。将列出对象的每个属性,DateTime值位于UTC中。
intintbooldatetimeOptional[str] (仅在您拥有该应用程序的情况下出现) to_dict() - 以字典的形式返回对象intboolbooldatetimebool to_dict() - 以字典的形式返回对象strstrintdsc.Embed (请参阅下面的对象)List[int]datetimestr ('bot','server',“模板”或“链接”)strbooldatetimestr to_dict() - 以字典的形式返回对象在响应或创建的用户中返回,嵌入是使您的链接脱颖而出的一种方式。
dsc.Color (请参阅下面的对象)strstrstr (图像URL) to_dict() - 以字典的形式返回对象from_dict(data: dict) - 返回用字典中的值初始化的嵌入对象这与Discord.py的颜色非常相似,尽管也允许传递字符串。
所有Discord.py内置的颜色类方法也在这里,例如。 dsc.Color.red()
int to_dict() - 以字典的形式返回对象此软件包是开源的,因此任何具有足够Python体验的人都可以为该项目做出贡献!
如果您在软件包中找到任何错误/错误/错误,或者在代码中找到了随意创建问题并在此处报告。
如果您想为此软件包做出贡献,请分配存储库,进行更改,然后创建一个拉请请求!
如果您想与我联系:
邮件 - [email protected]
DISCORD wulf#9632