read (), filename = 'example.jpg' ) with open ( "path/to/second/image.jpg", "rb" ) as f : webhook. delete () Send Files from discord_webhook import DiscordWebhook webhook = DiscordWebhook ( url = 'your webhook url', username = "Webhook with files" ) # send two images with open ( "path/to/first/image.jpg", "rb" ) as f : webhook. edit () Delete Webhook Messages from discord_webhook import DiscordWebhook from time import sleep webhook = DiscordWebhook ( url = 'your webhook url', content = 'Webhook Content' ) webhook. content = 'After Edit' sleep ( 10 ) webhook. execute ()Įdit Webhook Messages from discord_webhook import DiscordWebhook from time import sleep webhook = DiscordWebhook ( url = 'your webhook url', content = 'Webhook content before edit' ) webhook. add_embed_field ( name = "Field 4", value = "sadipscing elitr" ) webhook. add_embed_field ( name = "Field 3", value = "amet consetetur" ) embed. add_embed_field ( name = "Field 2", value = "dolor sit", inline = False ) embed. add_embed_field ( name = "Field 1", value = "Lorem ipsum", inline = False ) embed. set_timestamp () # Set `inline=False` for the embed field to occupy the whole line embed. set_footer ( text = "Embed Footer Text" ) embed. set_author ( name = "Author Name", url = "", icon_url = "", ) embed. We can arrange them in a new line by setting inline=False as follows: from discord_webhook import DiscordWebhook, DiscordEmbed webhook = DiscordWebhook ( url = "your webhook url", username = "New Webhook Username" ) embed = DiscordEmbed ( title = "Embed Title", description = "Your Embed Description", color = '03b2f8' ) embed. execute ()īy Default, the Embed fields are placed side by side. add_embed_field ( name = 'Field 4', value = 'sadipscing elitr' ) webhook. add_embed_field ( name = 'Field 3', value = 'amet consetetur' ) embed. add_embed_field ( name = 'Field 2', value = 'dolor sit' ) embed. add_embed_field ( name = 'Field 1', value = 'Lorem ipsum' ) embed. set_footer ( text = 'Embed Footer Text' ) embed. set_author ( name = 'Author Name', url = '', icon_url = '' ) embed. This is another example with embedded content from discord_webhook import DiscordWebhook, DiscordEmbed webhook = DiscordWebhook ( url = 'your webhook url', username = "New Webhook Username" ) embed = DiscordEmbed ( title = 'Embed Title', description = 'Your Embed Description', color = '03b2f8' ) embed. add_embed_field ( name = 'Field 2', value = 'dolor sit' ) # add embed object to webhook webhook. set_timestamp () # add fields to embed embed. set_footer ( text = 'Embed Footer Text', icon_url = 'URL of icon' ) # set timestamp (default is now) embed. set_thumbnail ( url = 'your thumbnail url' ) # set footer embed. set_image ( url = 'your image url' ) # set thumbnail embed. set_author ( name = 'Author Name', url = 'author url', icon_url = 'author icon url' ) # set image embed. execute ()įrom discord_webhook import DiscordWebhook, DiscordEmbed webhook = DiscordWebhook ( url = 'your webhook url' ) # create embed object for webhook embed = DiscordEmbed ( title = 'Your Title', description = 'Lorem ipsum dolor sit', color = '03b2f8' ) # set author embed. Webhook with Embedded Content from discord_webhook import DiscordWebhook, DiscordEmbed webhook = DiscordWebhook ( url = 'your webhook url' ) # create embed object for webhook # you can set the color as a decimal (color=242424) or hex (color='03b2f8') number embed = DiscordEmbed ( title = 'Your Title', description = 'Lorem ipsum dolor sit', color = '03b2f8' ) # add embed object to webhook webhook. Manage being Rate Limited from discord_webhook import DiscordWebhook # if rate_limit_retry is True then in the event that you are being rate # limited by Discord your webhook will automatically be sent once the # rate limit has been lifted webhook = DiscordWebhook ( url = 'your webhook url', rate_limit_retry = True, content = 'Webhook Message' ) response = webhook. ![]() create_batch ( urls =, content = 'Webhook Message' ) response1 = webhook1. from discord_webhook import DiscordWebhook # you can provide any kwargs except url webhook1, webhook2 = DiscordWebhook. If you want to use multiple URLs you need to create multiple instances. Create Multiple Instances / Use multiple URLsīasic Webhook from discord_webhook import DiscordWebhook webhook = DiscordWebhook ( url = 'your webhook url', content = 'Webhook Message' ) response = webhook.Install via pip: pip install discord-webhook Execute Discord Webhooks (also has async support) Install
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |