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