DC bot py
maybe 3?
Embed
老喜歡用這個
discord.Embed
邊框顏色,標題,種類,標題連結,描述
class discord.Embed(*, color=None, title=None, type='rich', url=None, description=None)
discord.Embed
title:str,最多256個字符
description:str,最多4096個字符
color:discord.Color.顏色(),16進制色號
url:str,就連結
type:默認通用'rich',即通用
discord.Embed
embed.set_thumbnail(url = "")
#設定縮圖
embed.set_author(name = "", url = "", icon_url = "")
#設定作者
embed.set_image(url = "")
#設定大圖
embed.set_footer(text = "", icon_url = "")
#設定尾巴
embed.add_field(name = "", value = "", inline = bool)
#加小標
discord.Embed
@bot.command()
async def genshin(ctx):
str = "你說的對,但是《你說的對》是由你說的對自主研發的一款全新你說的對。 你說的對發生在一個被稱作「你說的對」的你說的對世界,在這裡被你說的對選中的你說的對將被授予「你說的對」,引導你說的對之力。 你將扮演一位名為「你說的對」的神秘角色,在自由的旅行中邂逅你說的對、你說的對的你說的對們,和你說的對一起擊敗你說的對,尋找失散的你說的對,同時,逐步發掘「你說的對」的真相。"
url = "https://upload.wikimedia.org/wikipedia/zh/f/fc/%E5%8E%9F%E7%A5%9E_%E5%9C%8B%E9%9A%9B%E7%89%88.jpeg"
web = "https://genshin.hoyoverse.com/zh-tw/"
embed = discord.Embed(title="原神", description=str, url= web, color=discord.Color.blue())
embed.set_thumbnail(url = url)
embed.add_field(name = "該玩原神了吧", value = "不然blue archive也不錯", inline = False)
await ctx.channel.send(embed = embed)
記得 (embed = 你的embed名稱)
Button
鈕扣
discord.ui.button
標籤,可用與否,風格,emoji,列
@discord.ui.button(*, label=None, disabled=False, style=ButtonStyle, emoji=None, row=None)
discord.ui.button
label:str,最多256個字符
disabled:是否禁用,bool
emoji:discord內建表符可以ctrl + .直接設定
非內建表符先打出 \ +表符再複製表符編號
row:int,最多5行,在0~4之間
discord.ui.button
style:discord.ButtonStyle.以下擇一

discord.ui.button
callback() 回呼函式
就是按下按鈕後要做的事
async def button_callback(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_message("Never Gonna Give You Up")
discord.ui.button
class ButtonForGenshin(discord.ui.View):
def __init__(self, *, timeout=None):
super().__init__(timeout=timeout)
@discord.ui.button(label="點點看", style=discord.ButtonStyle.primary, emoji="<:danger:1188425778308849684>")
async def button_callback(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.message.reply("Never Gonna Give You Up")
想要很多個按鈕就多做幾個
discord.ui.Button
連結按鈕
bt = discord.ui.Button(label="這也可以點點看", url = "https://genshin.hoyoverse.com/zh-tw/")
self.add_item(bt)
discord.ui.button
class ButtonForGenshin(discord.ui.View):
def __init__(self, *, timeout=None):
super().__init__(timeout=timeout)
bt = discord.ui.Button(label="這也可以點點看", url = "https://genshin.hoyoverse.com/zh-tw/")
self.add_item(bt)
@discord.ui.button(label="點點看", style=discord.ButtonStyle.primary, emoji="<:danger:1188425778308849684>")
async def button_callback(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.message.reply("Never Gonna Give You Up")
discord.ui.Button
class ButtonForGenshin(discord.ui.View):
def __init__(self, *, timeout=None):
super().__init__(timeout=timeout)
bt = discord.ui.Button(label="這也可以點點看", url = "https://genshin.hoyoverse.com/zh-tw/")
self.add_item(bt)
@discord.ui.button(label="點點看", style=discord.ButtonStyle.primary, emoji="<:danger:1188425778308849684>")
async def button_callback(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.message.reply("Never Gonna Give You Up")
記得在你要輸出按鈕的那則訊息加上
(view = 你的class名稱)
DC bot
By ganyumywife
DC bot
- 173