You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
discord.Color and discord.Colour are BOTH acceptable
Discord.py has a bunch of colors pre-stored as classmethods
importdiscord# Maybe use a hex value??!!?!?!sky_blue=discord.Color(0xCCFFFF) # 0x + hex value# Or grab the RED TO THE GREEN TO THE BLUE valuesyellow=discord.Color.from_rgb(r=255,g=255,b=51) # You've got the color yellow! AND ITS HOMEMADE!!!# Or just like, use intellisense and find something built-in -_-built_in_red=discord.Color.red()
The only real reason anyone uses discord.Color is to set the color for discord.Embed's
To create an embed you simply create a new discord.Embed class
importdiscordnew_embed=discord.Embed()
Embed object properties
new_embed.title="My Embed Title"new_embed.description="Embed Description"new_embed.url="URL hyperlink that will come in the embed title"importdatetimenew_embed.timestamp=datetime.datetime.now() # Embed timestamp shows up in the footer of your embednew_embed.color=discord.Color.red() # or discord.Color(your_hex)
Your embed would look like this if you did all that (and gave a valid URL)
Class Functions
Fields
You can add up to 25 fields in a single embed before you reach the limit
new_embed.add_field(
name="Field Name",
value="Field Value",
inline=True
)
new_embed.add_field(
name="Field Name Two",
value="Field Value Two",
inline=True
)
To make your embed follow a single downwards line you just set inline=False instead of True
Your embed will show up like this:
You can also add a field at a certain index (location) within the embed using insert_field_at
new_embed.set_footer(
text="I am the foot! Zz",
icon_url="Some image URL"
)
And now we have an 'footer' in our embed, you will notice that the timestamp is still there, but is separated by a • this is just discord standard and can not be changed as of yet
Author, Image and Thumbnail
Now lets add our author, our image AND our thumbnail!
new_embed.set_author(
name = "Your Humble Author Zz",
url = "When you click on the author, you can get redirected to whatever URl you put here",
icon_url = "The image that shows up next to the author name"
)
new_embed.set_thumbnail(url="image url")
new_embed.set_image(url="another image url")
And our magical embed, so many beautiful faces 😍
For more detailed and other miniature tasks you may want to use for your embeds refer to the documentation
If you want to know how to change your embed color look at the default color library within the discord.py module!
While your file is within the current working directory
my_file_name="names.txt"my_file=open(my_file_name,mode='rb') # Open in the read in binary mode (rb)my_disc_file=discord.File(
fp=my_file,
filename="names_file.txt"# This is what it will be called when you send it,spoiler=False# Send as a spoiler or not
)
awaitchannel.send(file=my_disc_file) # If sending just one fileawaitchannel.send(
files= [
my_disc_file_one,
my_disc_file_two
]
)
So sending a number of files just define files as a list of discord.Files
Otherwise send a single discord.File as file
importdiscord# You have built in activities like my_special_activity=discord.Game(name="PAC MAN") # Returns Playing PAC MAN# Or you can have different activity types like watching my_very_stalky_activity=discord.Activity(
name=" you",
type=discord.ActivityType.watching
)
# Comes out as Watching you 👀
You also have activity types like listening and more, you can see them here
In order to actually change the activity of your bot user you can just use change_presence like so: