{"id":8155,"date":"2026-09-02T21:34:38","date_gmt":"2026-09-02T21:34:38","guid":{"rendered":"https:\/\/kutia.net\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\/"},"modified":"2026-09-02T21:34:38","modified_gmt":"2026-09-02T21:34:38","slug":"create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python","status":"publish","type":"post","link":"https:\/\/kutia.net\/fr\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python\/","title":{"rendered":"Cr\u00e9ez un bot Discord qui utilise OpenAI pour g\u00e9n\u00e9rer des r\u00e9ponses aux messages \u00e0 l'aide de Python"},"content":{"rendered":"<p class=\"wp-block-paragraph\">This article intends to explain how to create a simple Discord bot that replies as OpenAI\u2019s chat would do. And gives you a walkthrough of containerizing the application.<\/p>\n<h2 class=\"wp-block-heading\" id=\"db60\">What do you need?<\/h2>\n<p class=\"wp-block-paragraph\" id=\"d8a6\">You need an OpenAI account&nbsp;<code>api-key<\/code>&nbsp;which you can find in your&nbsp;<a href=\"https:\/\/beta.openai.com\/account\/api-keys\" rel=\"noreferrer noopener\" target=\"_blank\">OpenAI account<\/a>.<\/p>\n<p class=\"wp-block-paragraph\" id=\"8695\">You need a configured Discord bot,<a href=\"https:\/\/www.ionos.co.uk\/digitalguide\/server\/know-how\/creating-discord-bot\/\" rel=\"noreferrer noopener\" target=\"_blank\">&nbsp;here is how to do that<\/a>.<\/p>\n<p class=\"wp-block-paragraph\" id=\"20a4\">Make sure your Discord bot has permission to read and send messages, and that it\u2019s added to your discord channel.<\/p>\n<p class=\"wp-block-paragraph\" id=\"d695\">First things first let\u2019s use&nbsp;<a href=\"https:\/\/pypi.org\/project\/discord.py\/\" rel=\"noreferrer noopener\" target=\"_blank\">discord<\/a>\u2019s Client class to create the bot, and install this library with the command:<\/p>\n<p class=\"wp-block-paragraph\" id=\"1184\"><code>pip install discord.py<\/code><\/p>\n<p class=\"wp-block-paragraph\" id=\"e773\">We\u2019ll first create our own class named&nbsp;<code>OpenAIBot<\/code>&nbsp;which will inherit the&nbsp;<code>Client<\/code>&nbsp;class and add two more functions to it. This&nbsp;<code>Client<\/code>&nbsp;class takes intents as a constructor argument on initialization.<br \/>You could use the default&nbsp;<code>Intents<\/code>&nbsp;unless you have a particular one to specify.<\/p>\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"281\" src=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.10.51-AM-1024x281.png\" alt=\"\" class=\"wp-image-4476\" srcset=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.10.51-AM-1024x281.webp 1024w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.10.51-AM-300x82.webp 300w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.10.51-AM-768x211.webp 768w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.10.51-AM.webp 1436w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<p class=\"wp-block-paragraph\">Let\u2019s override the asynchronous function&nbsp;<code>on_message<\/code>, which is triggered when a message is sent to the channel you added to your discord bot.<\/p>\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"536\" src=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.11.57-AM-1024x536.png\" alt=\"\" class=\"wp-image-4479\" srcset=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.11.57-AM-1024x536.webp 1024w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.11.57-AM-300x157.webp 300w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.11.57-AM-768x402.webp 768w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.11.57-AM.webp 1426w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<p class=\"wp-block-paragraph\" id=\"5370\">Now we have to deal with&nbsp;<a href=\"https:\/\/github.com\/openai\/openai-python\" rel=\"noreferrer noopener\" target=\"_blank\">OpenAI\u2019s library for python<\/a>, first, let&#8217;s install it:<\/p>\n<p class=\"wp-block-paragraph\" id=\"79f0\"><code>pip install --upgrade openai<\/code><\/p>\n<p class=\"wp-block-paragraph\" id=\"e475\">The only thing we need for OpenAI to be able to respond to our messages is the&nbsp;<code>Completion<\/code>&nbsp;engine and that is possible with a simple request:<\/p>\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"367\" src=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.12.35-AM-1024x367.png\" alt=\"\" class=\"wp-image-4482\" srcset=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.12.35-AM-1024x367.webp 1024w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.12.35-AM-300x108.webp 300w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.12.35-AM-768x275.webp 768w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.12.35-AM.webp 1400w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<p class=\"wp-block-paragraph\" id=\"9098\">For more information on customizing this call check out the&nbsp;<a href=\"https:\/\/beta.openai.com\/docs\/api-reference\/completions\" rel=\"noreferrer noopener\" target=\"_blank\">API reference of OpenAI<\/a>.<\/p>\n<p class=\"wp-block-paragraph\" id=\"292c\">Back to our code, we will now add a function called&nbsp;<code>openai_response<\/code>&nbsp;which takes a message as an argument and returns a message from OpenAPI.<\/p>\n<p class=\"wp-block-paragraph\" id=\"9f5e\">We will use&nbsp;<code>openai.Completion.create()<\/code>&nbsp;functions to help us out with the communication:<\/p>\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"753\" src=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.13.10-AM-1024x753.png\" alt=\"\" class=\"wp-image-4485\" srcset=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.13.10-AM-1024x753.webp 1024w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.13.10-AM-300x221.webp 300w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.13.10-AM-768x565.webp 768w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.13.10-AM.webp 1404w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<p class=\"wp-block-paragraph\" id=\"a541\">Great!<\/p>\n<p class=\"wp-block-paragraph\" id=\"7d02\">Now running the bot would require the initialization of this class and the call of&nbsp;<code>run<\/code>&nbsp;of the super-class Client.<\/p>\n<p class=\"wp-block-paragraph\" id=\"3cf2\">We\u2019ll use the condition&nbsp;<code>if __name__==\"__main\":<\/code>&nbsp;to avoid starting the bot when we (if we) import&nbsp;<code>OpenAIBot<\/code>&nbsp;in the near future.<\/p>\n<p class=\"wp-block-paragraph\" id=\"f674\">Now the code looks like this:<\/p>\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1017\" height=\"1024\" src=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.14.24-AM-1017x1024.png\" alt=\"\" class=\"wp-image-4488\" srcset=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.14.24-AM-1017x1024.webp 1017w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.14.24-AM-298x300.webp 298w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.14.24-AM-150x150.webp 150w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.14.24-AM-768x774.webp 768w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.14.24-AM-418x420.png 418w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.14.24-AM.webp 1392w\" sizes=\"auto, (max-width: 1017px) 100vw, 1017px\" \/><\/figure>\n<p class=\"wp-block-paragraph\" id=\"f0e4\">There is a problem here, it\u2019s not good to directly insert confidential data like API keys on your code. We will use&nbsp;<code>os.getenv<\/code>&nbsp;to load these constants from our system.<\/p>\n<p class=\"wp-block-paragraph\" id=\"8cca\">After some minor tweaks the code will look like this:<\/p>\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"868\" height=\"1024\" src=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.15.18-AM-868x1024.png\" alt=\"\" class=\"wp-image-4491\" srcset=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.15.18-AM-868x1024.webp 868w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.15.18-AM-254x300.webp 254w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.15.18-AM-768x906.webp 768w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.15.18-AM-1302x1536.webp 1302w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.15.18-AM.webp 1402w\" sizes=\"auto, (max-width: 868px) 100vw, 868px\" \/><\/figure>\n<p class=\"wp-block-paragraph\" id=\"b7f5\">Assuming our main python script is named&nbsp;<code>main.py<\/code>we can proceed to execute it:<\/p>\n<p class=\"wp-block-paragraph\" id=\"2b1d\"><code>python3 main.py<\/code><\/p>\n<p class=\"wp-block-paragraph\" id=\"dba2\">Now you will see indications that our discord bot is running if you configured everything correctly.<\/p>\n<h1 class=\"wp-block-heading\" id=\"657f\">How about using docker?<\/h1>\n<p class=\"wp-block-paragraph\" id=\"1239\">I love Docker, so yes\u2026<\/p>\n<p class=\"wp-block-paragraph\" id=\"fb0c\">Let\u2019s create&nbsp;<code>Dockerfile<\/code>&nbsp;and&nbsp;<code>docker-compose.yml<\/code>&nbsp;for our docker configuration then&nbsp;<code>.env<\/code>&nbsp;for our environment variables, our project structure now looks like this:<\/p>\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"308\" src=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.16.15-AM-1024x308.png\" alt=\"\" class=\"wp-image-4494\" srcset=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.16.15-AM-1024x308.webp 1024w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.16.15-AM-300x90.webp 300w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.16.15-AM-768x231.webp 768w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.16.15-AM.webp 1388w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<p class=\"wp-block-paragraph\">Here we can explain the content and functionality of our new files,&nbsp;<code>.env<\/code>&nbsp;will hold the Discord and OpenAI tokens.<\/p>\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"162\" src=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.16.38-AM-1024x162.png\" alt=\"\" class=\"wp-image-4497\" srcset=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.16.38-AM-1024x162.webp 1024w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.16.38-AM-300x47.webp 300w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.16.38-AM-768x121.webp 768w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.16.38-AM.webp 1392w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<p class=\"wp-block-paragraph\" id=\"e017\">A new file in our project is&nbsp;<code>requirements.txt<\/code>&nbsp;as well, you can generate by freezing dependencies to this file with the command:&nbsp;<\/p>\n<p class=\"wp-block-paragraph\" id=\"e017\"><code>pip freeze -&gt; requirements.txt<\/code><\/p>\n<p class=\"wp-block-paragraph\" id=\"04fd\">Avoiding getting extra dependencies written in requirements here is the file I generated using a virtual environment:<\/p>\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"805\" src=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.17.05-AM-1024x805.png\" alt=\"\" class=\"wp-image-4500\" srcset=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.17.05-AM-1024x805.webp 1024w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.17.05-AM-300x236.webp 300w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.17.05-AM-768x604.webp 768w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.17.05-AM.webp 1414w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<p class=\"wp-block-paragraph\">Now let\u2019s explain&nbsp;<code>Dockerfile<\/code>, first, we\u2019ll use&nbsp;python:3.8-slim-buster&nbsp;as the base image to build our container on, then set&nbsp;\/bot&nbsp;as our working directory, copy&nbsp;bot&nbsp;the directory from the project root to the container and install the required dependencies:<\/p>\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"329\" src=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.17.48-AM-1024x329.png\" alt=\"\" class=\"wp-image-4503\" srcset=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.17.48-AM-1024x329.webp 1024w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.17.48-AM-300x96.webp 300w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.17.48-AM-768x247.webp 768w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.17.48-AM.webp 1400w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<p class=\"wp-block-paragraph\">Simple&nbsp;<code>docker-compose.yml<\/code>&nbsp;configuration with a single container which is built based on the instructions on&nbsp;<code>Dockerfile<\/code>:<\/p>\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"310\" src=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.18.20-AM-1024x310.png\" alt=\"\" class=\"wp-image-4506\" srcset=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.18.20-AM-1024x310.webp 1024w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.18.20-AM-300x91.webp 300w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.18.20-AM-768x232.webp 768w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.18.20-AM.webp 1396w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<p class=\"wp-block-paragraph\" id=\"9300\">Build the docker image and spin up the container:<\/p>\n<p class=\"wp-block-paragraph\" id=\"8374\"><code>docker-compose up --build -d<\/code><\/p>\n<p class=\"wp-block-paragraph\" id=\"4d09\">And now you have the OpenAI discord bot running in a container.<\/p>\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"656\" src=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.20.19-AM-1024x656.png\" alt=\"\" class=\"wp-image-4512\" srcset=\"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.20.19-AM-1024x656.webp 1024w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.20.19-AM-300x192.webp 300w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.20.19-AM-768x492.webp 768w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.20.19-AM-1536x984.webp 1536w, https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/Screenshot-2022-12-20-at-11.20.19-AM-2048x1313.webp 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Cet article a pour but d&#8217;expliquer comment cr\u00e9er un simple bot Discord qui r\u00e9pond comme le ferait le chat d&#8217;OpenAI. <\/p>\n","protected":false},"author":0,"featured_media":4516,"comment_status":"","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[82],"tags":[],"class_list":["post-8155","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-non-classifiee"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Create a Discord bot that uses OpenAI to generate responses to messages using Python - Kutia<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kutia.net\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create a Discord bot that uses OpenAI to generate responses to messages using Python - Kutia\" \/>\n<meta property=\"og:description\" content=\"Cet article a pour but d&#039;expliquer comment cr\u00e9er un simple bot Discord qui r\u00e9pond comme le ferait le chat d&#039;OpenAI.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kutia.net\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Kutia\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-02T21:34:38+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/kutia.net\\\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/kutia.net\\\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\\\/\"},\"author\":{\"name\":\"\",\"@id\":\"\"},\"headline\":\"Cr\u00e9ez un bot Discord qui utilise OpenAI pour g\u00e9n\u00e9rer des r\u00e9ponses aux messages \u00e0 l'aide de Python\",\"datePublished\":\"2026-09-02T21:34:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/kutia.net\\\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\\\/\"},\"wordCount\":14,\"image\":{\"@id\":\"https:\\\/\\\/kutia.net\\\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/kutia.net\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/DiscordBlog_Banner.webp\",\"articleSection\":[\"Non classifi\u00e9(e)\"],\"inLanguage\":\"fr-FR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/kutia.net\\\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\\\/\",\"url\":\"https:\\\/\\\/kutia.net\\\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\\\/\",\"name\":\"Create a Discord bot that uses OpenAI to generate responses to messages using Python - Kutia\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/kutia.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/kutia.net\\\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/kutia.net\\\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/kutia.net\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/DiscordBlog_Banner.webp\",\"datePublished\":\"2026-09-02T21:34:38+00:00\",\"author\":{\"@id\":\"\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/kutia.net\\\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\\\/\\\/kutia.net\\\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\\\/#primaryimage\",\"url\":\"https:\\\/\\\/kutia.net\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/DiscordBlog_Banner.webp\",\"contentUrl\":\"https:\\\/\\\/kutia.net\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/DiscordBlog_Banner.webp\",\"width\":10000,\"height\":5250},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/kutia.net\\\/#website\",\"url\":\"https:\\\/\\\/kutia.net\\\/\",\"name\":\"Kutia\",\"description\":\"Custom software, team augmentation, IT recruitment\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/kutia.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create a Discord bot that uses OpenAI to generate responses to messages using Python - Kutia","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/kutia.net\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\/","og_locale":"fr_FR","og_type":"article","og_title":"Create a Discord bot that uses OpenAI to generate responses to messages using Python - Kutia","og_description":"Cet article a pour but d'expliquer comment cr\u00e9er un simple bot Discord qui r\u00e9pond comme le ferait le chat d'OpenAI.","og_url":"https:\/\/kutia.net\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\/","og_site_name":"Kutia","article_published_time":"2026-09-02T21:34:38+00:00","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/kutia.net\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\/#article","isPartOf":{"@id":"https:\/\/kutia.net\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\/"},"author":{"name":"","@id":""},"headline":"Cr\u00e9ez un bot Discord qui utilise OpenAI pour g\u00e9n\u00e9rer des r\u00e9ponses aux messages \u00e0 l'aide de Python","datePublished":"2026-09-02T21:34:38+00:00","mainEntityOfPage":{"@id":"https:\/\/kutia.net\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\/"},"wordCount":14,"image":{"@id":"https:\/\/kutia.net\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\/#primaryimage"},"thumbnailUrl":"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/DiscordBlog_Banner.webp","articleSection":["Non classifi\u00e9(e)"],"inLanguage":"fr-FR"},{"@type":"WebPage","@id":"https:\/\/kutia.net\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\/","url":"https:\/\/kutia.net\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\/","name":"Create a Discord bot that uses OpenAI to generate responses to messages using Python - Kutia","isPartOf":{"@id":"https:\/\/kutia.net\/#website"},"primaryImageOfPage":{"@id":"https:\/\/kutia.net\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\/#primaryimage"},"image":{"@id":"https:\/\/kutia.net\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\/#primaryimage"},"thumbnailUrl":"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/DiscordBlog_Banner.webp","datePublished":"2026-09-02T21:34:38+00:00","author":{"@id":""},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kutia.net\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\/"]}]},{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/kutia.net\/create-a-discord-bot-that-uses-openai-to-generate-responses-to-messages-using-python-2\/#primaryimage","url":"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/DiscordBlog_Banner.webp","contentUrl":"https:\/\/kutia.net\/wp-content\/uploads\/2022\/12\/DiscordBlog_Banner.webp","width":10000,"height":5250},{"@type":"WebSite","@id":"https:\/\/kutia.net\/#website","url":"https:\/\/kutia.net\/","name":"Kutia","description":"Custom software, team augmentation, IT recruitment","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kutia.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"}]}},"_links":{"self":[{"href":"https:\/\/kutia.net\/fr\/wp-json\/wp\/v2\/posts\/8155","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kutia.net\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kutia.net\/fr\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/kutia.net\/fr\/wp-json\/wp\/v2\/comments?post=8155"}],"version-history":[{"count":0,"href":"https:\/\/kutia.net\/fr\/wp-json\/wp\/v2\/posts\/8155\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kutia.net\/fr\/wp-json\/wp\/v2\/media\/4516"}],"wp:attachment":[{"href":"https:\/\/kutia.net\/fr\/wp-json\/wp\/v2\/media?parent=8155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kutia.net\/fr\/wp-json\/wp\/v2\/categories?post=8155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kutia.net\/fr\/wp-json\/wp\/v2\/tags?post=8155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}