{"id":385462,"date":"2024-06-29T06:07:42","date_gmt":"2024-06-29T06:07:42","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=385462"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=385462","title":{"rendered":"<span>\u041f\u0438\u0448\u0435\u043c Discord \u0431\u043e\u0442\u0430 \u043a\u0440\u0435\u0441\u0442\u0438\u043a\u0438-\u043d\u043e\u043b\u0438\u043a\u0438<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d5e\/b08\/f42\/d5eb08f425b9fa2916eb774b9ec50809.png\" alt=\"\" title=\"\" width=\"1014\" height=\"693\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d5e\/b08\/f42\/d5eb08f425b9fa2916eb774b9ec50809.png\"\/><\/figure>\n<p>\u0412\u044b \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u0445\u043e\u0442\u0435\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0431\u043e\u0442 \u0434\u043b\u044f \u0438\u0433\u0440\u044b \u0432 \u043a\u0440\u0435\u0441\u0442\u0438\u043a\u0438-\u043d\u043e\u043b\u0438\u043a\u0438 \u0432 Discord? \u0422\u0430\u043a \u0435\u0449\u0451 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 ?<em>blazingly fast<\/em>?Rust \u0438 \u043a\u0440\u0435\u0439\u0442\u0430 <code>serenity<\/code>! \u0412\u0441\u0435\u0445 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n<h3>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435<\/h3>\n<p>\u041f\u044b\u0442\u0430\u044f\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c Discord \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0431\u043e\u0442\u0430 \u043a \u043d\u0435\u043c\u0443 \u0434\u043b\u044f \u043c\u043e\u0435\u0433\u043e \u043d\u043e\u0432\u043e\u0438\u0441\u043f\u0435\u0447\u0451\u043d\u043d\u043e\u0433\u043e \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442\u0430, \u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u0432 <a href=\"https:\/\/discord.com\/developers\/docs\/intro\" rel=\"noopener noreferrer nofollow\">Discord API<\/a> \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0431\u043e\u0442\u043e\u0432, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u0432 \u0441\u0432\u043e\u0435\u0439 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435. \u0412 \u043d\u0435\u0439 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e\u0431 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043d\u044e\u0430\u043d\u0441\u0430\u0445 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f Discord \u0431\u043e\u0442\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u043e\u0432\u044b\u0445 \u0444\u0438\u0448\u0435\u043a, \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Rust, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u0440\u0435\u0439\u0442 <a href=\"https:\/\/docs.rs\/serenity\/latest\/serenity\/\" rel=\"noopener noreferrer nofollow\">serenity<\/a>.<\/p>\n<h3>\u0427\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f?<\/h3>\n<ul>\n<li>\n<p>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u043d\u0438\u0435 \u0431\u0430\u0437\u044b \u044f\u0437\u044b\u043a\u0430 Rust (Rust Book) \u0438 \u0430\u0441\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043d\u0451\u043c.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0435\u0440\u0432\u0435\u0440 \u0432 Discord&#8217;\u0435 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0441 \u043e\u0434\u043d\u0438\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u043c \u043a\u0430\u043d\u0430\u043b\u043e\u043c.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u044b<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443. \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430 \u0435\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0430\u043a\u043a\u0430\u0443\u043d\u0442 <a href=\"https:\/\/discord.com\/developers\" rel=\"noopener noreferrer nofollow\">\u043d\u0430 \u0441\u0430\u0439\u0442\u0435 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 Discord<\/a>. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u0432 \u0441\u0432\u043e\u0451\u043c Discord \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0435 \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432\u043e \u0432\u043a\u043b\u0430\u0434\u043a\u0443 <code>Applications<\/code>. \u0422\u0430\u043c \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 <code>New Application<\/code>:<\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1ff\/726\/a4f\/1ff726a4febcc8ef3a2d3b15fdbfe460.png\" width=\"1921\" height=\"928\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1ff\/726\/a4f\/1ff726a4febcc8ef3a2d3b15fdbfe460.png\"\/><\/figure>\n<p>\u0412\u0432\u043e\u0434\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430 \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c <code>Create<\/code>:<\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2f3\/c33\/ac3\/2f3c33ac3b76018471a22814b2630849.png\" width=\"1025\" height=\"628\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2f3\/c33\/ac3\/2f3c33ac3b76018471a22814b2630849.png\"\/><\/figure>\n<p>\u041f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u0432\u044b\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u043a\u043d\u043e \u043e\u0431\u0449\u0438\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0412 \u043d\u0451\u043c \u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b \u0438\u043a\u043e\u043d\u043a\u0443 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430. \u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043d\u0430\u0434\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f-\u0431\u043e\u0442\u0430 \u0432\u043e \u0432\u043a\u043b\u0430\u0434\u043a\u0435 \u0441\u043b\u0435\u0432\u0430:<\/p>\n<figure class=\"bordered\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/31f\/978\/c54\/31f978c54d6671e4768ba8b734309d28.png\" width=\"417\" height=\"598\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/31f\/978\/c54\/31f978c54d6671e4768ba8b734309d28.png\"\/><\/figure>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0431\u043e\u0442\u0430 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 <code>Add Bot<\/code> \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0430 <code>Reset Token<\/code>:<\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5f1\/14f\/ca0\/5f114fca0be73fdcc4b53b698233d91d.png\" width=\"1920\" height=\"933\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5f1\/14f\/ca0\/5f114fca0be73fdcc4b53b698233d91d.png\"\/><\/figure>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u0442\u043e\u043a\u0435\u043d, \u0438 \u0441\u0442\u0430\u0440\u0430\u0435\u043c\u0441\u044f \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043d\u0435 \u043f\u043e\u043f\u0430\u043b \u0432 \u0447\u0443\u0436\u0438\u0435 \u0440\u0443\u043a\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u0448 \u0431\u043e\u0442.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0448\u0442\u0440\u0438\u0445\u043e\u043c \u0432 \u043d\u0430\u0448\u0435\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0431\u043e\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0434\u0435\u043b <code>Privileged Gateway Intents<\/code>. <code>Intents<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043d\u0430\u043c \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c\/\u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0431\u043e\u0442\u0430 \u0442\u0430\u043a\u0438\u0435, \u043a\u0430\u043a <code>Presence Intent<\/code> (\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439), <code>Server Member Intent<\/code> (\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0447\u043b\u0435\u043d\u0430\u043c\u0438 \u0433\u0438\u043b\u044c\u0434\u0438\u0439(\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432)) \u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043d\u0430\u043c \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441 <code>Message Content Intent<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439:<\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/061\/dd2\/8bb\/061dd28bbf587df25e111795fc032d8f.png\" width=\"1920\" height=\"928\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/061\/dd2\/8bb\/061dd28bbf587df25e111795fc032d8f.png\"\/><\/figure>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0431\u043e\u0442\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430 \u043d\u0430 \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0435\u0440. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432\u043e \u0432\u043a\u043b\u0430\u0434\u043a\u0443 <code>OAuth2\/URL Generator<\/code>:<\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/632\/16d\/c81\/63216dc8104dd167f9b85bd6d3e21ce8.png\" width=\"1920\" height=\"923\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/632\/16d\/c81\/63216dc8104dd167f9b85bd6d3e21ce8.png\"\/><\/figure>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c <code>bot<\/code> \u0432 <code>Scopes<\/code>, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b. \u0410 \u0432 <code>Bot permissions<\/code> \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 <code>Administrator<\/code>. \u041e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u043d\u0430\u043c \u0442\u0432\u043e\u0440\u0438\u0442\u044c \u0432\u0441\u0451, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u0436\u0435\u043b\u0430\u0435\u043c, \u043d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0435\u0441\u044c \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0431\u043e\u0442, \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0431\u043e\u0442\u0430, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443, \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0431\u043e\u0442\u0430 \u043d\u0430 \u043d\u0430\u0448 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440:<\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/781\/770\/707\/781770707c084229eb7a450e9da2f39e.png\" width=\"1920\" height=\"927\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/781\/770\/707\/781770707c084229eb7a450e9da2f39e.png\"\/><\/figure>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/082\/c6f\/b17\/082c6fb17d869cbe7643e9004221215c.png\" width=\"1920\" height=\"931\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/082\/c6f\/b17\/082c6fb17d869cbe7643e9004221215c.png\"\/><\/figure>\n<h3>\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u0440\u043e\u0431\u0430<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u0440\u0435\u0439\u0442 <code>serenity<\/code> \u0432 \u043d\u0430\u0448 <code>Cargo.TOML<\/code> \u0444\u0430\u0439\u043b:<\/p>\n<pre><code>name = \"tic-tac-toe-discord-bot\" version = \"0.1.0\" edition = \"2021\"  [dependencies] serenity = { git = \"https:\/\/github.com\/serenity-rs\/serenity.git\", rev = \"ba3be69166f54c5986e4cc9438bc5bb4606fa4c2\", default-features = false, features = [\"builder\", \"cache\", \"client\", \"model\", \"utils\", \"gateway\", \"rustls_backend\"] } tokio = { version = \"1.22\", features = [\"rt-multi-thread\"] }<\/code><\/pre>\n<blockquote>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0435\u043d\u0438\u0435:<\/strong><br \/>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <code>serenity<\/code> \u0441 \u0432\u0435\u0442\u043a\u0438 <code>next<\/code> \u0438 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043c\u0438\u0442\u0430 (<code>ba3be69166f54c5986e4cc9438bc5bb4606fa4c2<\/code>).<\/p>\n<\/blockquote>\n<p>\u0412 <code>main.rs<\/code> \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0438 \u0432\u0441\u0451, \u043a\u0430\u043a \u043d\u0430\u0434\u043e:<\/p>\n<pre><code class=\"rust\">use serenity::async_trait; use serenity::all::{Message, Ready}; use serenity::prelude::*;  struct Handler;  #[async_trait] impl EventHandler for Handler {     async fn message(&amp;self, ctx: Context, msg: Message) {         if msg.content == \"!ping\" {             if let Err(err) = msg.reply(&amp;ctx.http, \"pong!\").await {                 eprintln!(\"Error: {err}\");             }         }     }      async fn ready(&amp;self, _: Context, ready: Ready) {         println!(\"{} has connected!\", ready.user.name);     } }  #[tokio::main] async fn main() {     let intents = GatewayIntents::GUILD_MESSAGES         | GatewayIntents::MESSAGE_CONTENT;      let mut client = Client::builder(include_str!(\".\/..\/token.txt\"), intents)         .event_handler(Handler)         .await         .expect(\"Failed to create client!\");      if let Err(err) = client.start().await {         eprintln!(\"Client error: {err:?}\");     } }<\/code><\/pre>\n<p><a href=\"https:\/\/github.com\/dpytaylo\/tic-tac-toe-discord-bot\/tree\/simple-ping-pong-bot\" rel=\"noopener noreferrer nofollow\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0434\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u043e\u0442\u0430.<\/a><\/p>\n<blockquote>\n<p>\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0430\u0439\u043b \u0441 \u0442\u043e\u043a\u0435\u043d\u043e\u043c (<code>token.txt<\/code>) \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/p>\n<\/blockquote>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0432\u0441\u0451 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0442\u043e \u043f\u0440\u0438 \u0432\u0432\u043e\u0434\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>!ping<\/code> \u0431\u043e\u0442 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043c \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c &#171;pong!&#187;:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9bd\/d77\/e6b\/9bdd77e6ba6ffa732ac82bd0218ccbe7.png\" width=\"363\" height=\"173\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9bd\/d77\/e6b\/9bdd77e6ba6ffa732ac82bd0218ccbe7.png\"\/><\/figure>\n<p>\u0412\u044b \u0441\u043a\u0430\u0436\u0435\u0442\u0435: &#171;\u0425\u043e\u0440\u043e\u0448\u043e, \u044d\u0442\u043e \u043c\u044b \u0443\u0436\u0435 \u0432\u0438\u0434\u0435\u043b\u0438 \u0434\u0432\u0435\u0441\u0442\u0438 \u0440\u0430\u0437 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430\u0445, \u043c\u043e\u0436\u0435\u0448\u044c \u043b\u0438 \u0442\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0445\u043e\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435?&#187; \u0418 \u044f \u043e\u0442\u0432\u0435\u0447\u0443 &#8212; \u0434\u0430. \u0414\u0430 \u043d\u0430\u0447\u043d\u0451\u0442\u0441\u044f \u0441 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435!<\/p>\n<h3>\u0420\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438<\/h3>\n<p>\u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 Discord \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f (<code>Interactions<\/code>), \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0435:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th data-colwidth=\"352\" width=\"352\">\n<p>\u0412\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435<\/p>\n<\/th>\n<th>\n<p>\u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td data-colwidth=\"352\" width=\"352\">\n<p align=\"left\"><a href=\"https:\/\/discord.com\/developers\/docs\/interactions\/receiving-and-responding#interaction-response-object-modal\" rel=\"noopener noreferrer nofollow\">PING<\/a><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 <code>webhook-based interactions<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"352\" width=\"352\">\n<p align=\"left\"><a href=\"https:\/\/discord.com\/developers\/docs\/interactions\/application-commands\" rel=\"noopener noreferrer nofollow\">APPLICATION_COMMAND<\/a><\/p>\n<\/td>\n<td>\n<p align=\"left\">&#8212; \u0412\u0432\u043e\u0434 \u0441 \u0447\u0430\u0442\u0430 (\u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434\u044b)<br \/>&#8212; \u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u0435 \u043c\u0435\u043d\u044e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f<br \/>&#8212; \u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u0435 \u043c\u0435\u043d\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"352\" width=\"352\">\n<p align=\"left\"><a href=\"https:\/\/discord.com\/developers\/docs\/interactions\/message-components\" rel=\"noopener noreferrer nofollow\">MESSAGE_COMPONENT<\/a><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043e\u043a, \u0432\u044b\u0431\u043e\u0440\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0435\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"352\" width=\"352\">\n<p align=\"left\"><a href=\"https:\/\/discord.com\/developers\/docs\/interactions\/receiving-and-responding#interaction-response-object-modal\" rel=\"noopener noreferrer nofollow\">APPLICATION_COMMAND_AUTOCOMPLETE<\/a><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0410\u0432\u0442\u043e\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"352\" width=\"352\">\n<p align=\"left\"><a href=\"https:\/\/discord.com\/developers\/docs\/interactions\/receiving-and-responding#interaction-response-object-modal\" rel=\"noopener noreferrer nofollow\">MODAL_SUBMIT<\/a><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0432\u0432\u043e\u0434\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u0437 \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u043a\u043e\u043d<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430, \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>Slash commands<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5ee\/f36\/96b\/5eef3696baf6d3c300a5bd9d96590b86.png\" alt=\" (\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434\u044b)\" title=\" (\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434\u044b)\" width=\"1218\" height=\"621\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5ee\/f36\/96b\/5eef3696baf6d3c300a5bd9d96590b86.png\"\/><\/p>\n<div><figcaption> (\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434\u044b)<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f Discord \u0431\u043e\u0442\u0430\u043c\u0438: \u043e\u043d\u0438 \u0434\u0430\u044e\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b, \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0443\u0440\u043e\u0432\u043d\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 (Server Settings > Apps > Integrations). \u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043d\u0438\u0445 \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u043f\u043e \u0432\u044b\u0437\u043e\u0432\u0443 \u0438\u0433\u0440\u044b:  <code>\/play<\/code>.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0432\u0430\u0436\u043d\u044b\u0445 \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0431\u043e\u0442\u043e\u0432 \u0431\u044b\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 (<code>ephemeral<\/code>), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0438\u0434\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434\u0443. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0431\u043e\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0434\u0432\u0443\u0445 \u043a\u043b\u0438\u043a\u043e\u0432 (Server Settings > Apps > App Directory). \u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0432 \u043d\u0430\u0448\u0435\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043d\u0430\u043c \u044d\u0442\u043e \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u0432\u0432\u043e\u0434\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u0445\u043e\u0434\u0430.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043d\u0430\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0437\u0430\u043b\u043e\u0436\u0435\u043d \u0432 <code>Message Components<\/code>. \u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043d\u0435\u0433\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043d\u043e\u043f\u043a\u0438, \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0438 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u043d\u043e \u0432\u0432\u043e\u0434\u0430 \u0442\u0435\u043a\u0441\u0442\u0430. \u041a\u043d\u043e\u043f\u043a\u0443 \u0438 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 <code>`ActionRow`<\/code> \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0433\u0434\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043d\u043e\u043f\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u043f\u044f\u0442\u044c, \u0430 \u0441\u043f\u0438\u0441\u043e\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d. \u0410 \u0441\u0430\u043c\u0438\u0445 <code>ActionRow<\/code> \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u043e\u0436\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u044f\u0442\u044c \u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044e. \u041e\u0442\u0441\u044e\u0434\u0430 \u043d\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e <code>ActionRow<\/code> \u0438 \u043a\u043d\u043e\u043f\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442\u044c \u043d\u0430\u043c \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0438\u0433\u0440\u043e\u0432\u043e\u043c\u0443 \u043f\u043e\u043b\u044e (3&#215;3), \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0430\u0448 \u0445\u043e\u0434 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u0438\u043a\u0443.<\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/585\/40a\/b13\/58540ab13c45d1be02d8ab94f847b241.png\" alt=\"(\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 Message Components)\" title=\"(\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 Message Components)\" width=\"849\" height=\"650\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/585\/40a\/b13\/58540ab13c45d1be02d8ab94f847b241.png\"\/><\/p>\n<div><figcaption>(\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 Message Components)<\/figcaption><\/div>\n<\/figure>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p>Interaction Callback Type<\/p>\n<\/th>\n<th data-colwidth=\"160\" width=\"160\">\n<p>CreateInteractionResponse<\/p>\n<\/th>\n<th>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">PONG<\/p>\n<\/td>\n<td data-colwidth=\"160\" width=\"160\">\n<p align=\"left\"><code>Pong<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044c <code>PING<\/code> \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">CHANNEL_MESSAGE_WITH_SOURCE<\/p>\n<\/td>\n<td data-colwidth=\"160\" width=\"160\">\n<p align=\"left\"><code>Message<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE<\/p>\n<\/td>\n<td data-colwidth=\"160\" width=\"160\">\n<p align=\"left\"><code>Defer<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c <code>interaction response<\/code> \u043f\u043e\u0437\u0436\u0435. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">DEFERRED_UPDATE_MESSAGE<\/p>\n<\/td>\n<td data-colwidth=\"160\" width=\"160\">\n<p align=\"left\"><code>Acknowledge<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">[\u0414\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432] \u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0436\u0435. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">UPDATE_MESSAGE<\/p>\n<\/td>\n<td data-colwidth=\"160\" width=\"160\">\n<p align=\"left\"><code>UpdateMessage<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">[\u0414\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432] \u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d \u043a \u043d\u0435\u043c\u0443<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">APPLICATION_COMMAND_AUTOCOMPLETE_RESULT<\/p>\n<\/td>\n<td data-colwidth=\"160\" width=\"160\">\n<p align=\"left\"><code>Autocomplete<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0430\u0432\u0442\u043e\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u043c\u0438<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">MODAL<\/p>\n<\/td>\n<td data-colwidth=\"160\" width=\"160\">\n<p align=\"left\"><code>Modal<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u0437\u0430\u043c\u0435\u043d\u0438\u043b \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 Discord API \u043d\u0430 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 <code>enum CreateInteractionResponse<\/code> \u0438\u0437 serenity, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u0430\u0448\u0435\u043c \u0431\u043e\u0442\u0435. \u0412 \u043d\u0451\u043c \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e <code>CHANNEL_MESSAGE_WITH_SOURCE<\/code> (<code>Message<\/code>) \u0438 <code>DEFERRED_UPDATE_MESSAGE<\/code> (<code>Acknowledge<\/code>). \u041f\u0435\u0440\u0432\u043e\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0441\u043b\u0430\u0442\u044c \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0445\u043e\u0434 \u0438\u0433\u0440\u043e\u043a\u0430, \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u044f \u0443\u0436\u0435 \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0435\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>CommandInteraction<\/code>.<\/p>\n<blockquote>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<\/strong><br \/>\u042d\u0442\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 Discord API \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 <a href=\"https:\/\/discord.com\/developers\/docs\/intro\" rel=\"noopener noreferrer nofollow\">https:\/\/discord.com\/developers\/docs\/intro<\/a>. \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e!<\/p>\n<\/blockquote>\n<h3>\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434<\/h3>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435, \u0441 \u0447\u0435\u0433\u043e \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u043e \u0431\u044b \u043d\u0430\u0447\u0430\u0442\u044c, \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>!ping<\/code> \u043d\u0430 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0444\u0430\u0439\u043b <code>ping.rs<\/code> \u0441 \u0434\u0432\u0443\u043c\u044f \u0444\u0443\u043d\u0446\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u043d\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434\u0443!:<\/p>\n<pre><code class=\"rust\">use serenity::all::{CommandInteraction, CreateCommand, CreateInteractionResponse, CreateInteractionResponseMessage}; use serenity::prelude::Context;  pub fn register() -> CreateCommand {     CreateCommand::new(\"ping\")         .description(\"Creates ephemeral message with \\\"pong\\\" text\") }  pub async fn command(ctx: Context, interaction: CommandInteraction) {     interaction.create_response(&amp;ctx.http, CreateInteractionResponse::Message(         CreateInteractionResponseMessage::new()             .ephemeral(true)             .content(\"pong!\")     ))     .await     .expect(\"failed to create interaction\"); }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>register<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0438\u043c\u044f \u043d\u0430\u0448\u0435\u0439 \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a \u043d\u0435\u0439 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 (\u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u0432\u0432\u043e\u0434\u0430), \u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>application_command<\/code> \u043c\u044b \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0432\u044b\u0434\u0430\u0432\u0430\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044e.<\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u043d\u0430\u0448 \u043c\u043e\u0434\u0443\u043b\u044c <code>ping<\/code> \u0441 \u043d\u0430\u0448\u0435\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <code>interaction_create<\/code> \u043c\u0435\u0442\u043e\u0434 \u0432 <code>EventHandler<\/code> \u0442\u0440\u0435\u0439\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 <code>main.rs<\/code> \u0444\u0430\u0439\u043b\u0435:<\/p>\n<pre><code class=\"rust\">mod ping;  use serenity::all::Interaction; use serenity::builder::{CreateInteractionResponse, CreateInteractionResponseMessage};  #[async_trait] impl EventHandler for Handler {     async fn interaction_create(&amp;self, ctx: Context, interaction: Interaction) {         match interaction {             Interaction::Command(command) => {                 match command.data.name.as_str() {                     \"ping\" => ping::command(ctx, command).await,                     _ => {                         command.create_response(&amp;ctx.http, CreateInteractionResponse::Message(                             CreateInteractionResponseMessage::new()                                 .ephemeral(true)                                 .content(\"Invalid command!\")                         ))                         .await                         .expect(\"failed to create response\");                     }                 }                            }              _ => (),         }     }      async fn ready(&amp;self, ctx: Context, ready: Ready) {         println!(\"{} has connected!\", ready.user.name);          \/\/ Trying to get our guild         let guild = ready.guilds[0];         assert_eq!(guild.unavailable, true);         let guild_id = guild.id;          \/\/ We use guild application commands because         \/\/ Command::create_global_application_command may take up         \/\/ to an hour to be updated in the user slash commands list.         guild_id.set_application_commands(&amp;ctx.http, vec![             ping::register(),          ])         .await         .expect(\"failed to create application command\");     } }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>ready<\/code>. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443, \u0438 \u043e\u043d\u0430 \u0442\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0430\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0431\u043e\u0442\u0430, \u043d\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b, \u043c\u044b \u0435\u0451 \u0431\u0443\u0434\u0435\u043c \u0432\u0441\u0435\u0433\u0434\u0430 \u0435\u0451 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u0431\u043e\u0442\u0430.<\/p>\n<blockquote>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<\/strong><br \/>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434\u0443, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>GuildId::delete_application_command<\/code>.<\/p>\n<\/blockquote>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<figure class=\"bordered\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f0a\/924\/4a3\/f0a9244a3f52d5642a2545c73b1c4167.png\" width=\"515\" height=\"267\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f0a\/924\/4a3\/f0a9244a3f52d5642a2545c73b1c4167.png\"\/><\/figure>\n<p>\u0410 \u0442\u0430\u043a\u0436\u0435 \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0432 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430 (Server Settings > Apps > Integrations):<\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/479\/e7c\/a69\/479e7ca698b86704b84f9b4b6255781a.png\" width=\"1252\" height=\"926\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/479\/e7c\/a69\/479e7ca698b86704b84f9b4b6255781a.png\"\/><\/figure>\n<blockquote>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<\/strong><br \/>\u0427\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u0438\u0434\u0435\u0442\u044c ID \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0435\u0445 \u0436\u0435 \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434), \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0438 \u043f\u043e \u043d\u0438\u043c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0440\u0435\u0436\u0438\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0432 User Settings > App Settings > Advanced > Developer Mode.<\/p>\n<\/blockquote>\n<p><a href=\"https:\/\/github.com\/dpytaylo\/tic-tac-toe-discord-bot\/tree\/ping-pong-bot-with-slash-command\" rel=\"noopener noreferrer nofollow\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u044d\u0442\u0430\u043f\u0430.<\/a><\/p>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u0434\u0435\u0438 \u043a\u0440\u0435\u0441\u0442\u0438\u043a\u043e\u0432-\u043d\u043e\u043b\u0438\u043a\u043e\u0432<\/h3>\n<p>\u0418\u043c\u0435\u044f \u043d\u0430 \u0440\u0443\u043a\u0430\u0445 \u043e\u043f\u044b\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>\/play<\/code>, \u0432\u044b\u0432\u043e\u0434\u044f\u0449\u0443\u044e <code>ephemeral<\/code> \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0451 \u0432\u0432\u0435\u0434\u0435\u0442. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0433\u0440\u043e\u043a, \u0432\u0432\u043e\u0434\u044f \u044d\u0442\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u0443, \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u0441\u043e\u043e\u0431\u0449\u0430\u044e\u0449\u0435\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0438\u0433\u0440\u043e\u043a\u0430, \u0438\u043b\u0438 \u0441\u0440\u0430\u0437\u0443 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u0438\u0433\u0440\u043e\u0432\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e. \u041a\u0430\u0436\u0434\u0443\u044e \u0438\u0433\u0440\u043e\u0432\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 <code>Vec&lt;Arc&lt;Mutex&lt;GameSession>><\/code>, \u0433\u0434\u0435, \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b <code>GameSession<\/code> \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044b \u043e\u0434\u043d\u0438\u043c <code>Mutex<\/code>&#8216;\u043e\u043c. \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u043a\u0430\u0440\u0442\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u043d\u043e\u043f\u043a\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e \u0442\u043e, \u0447\u0442\u043e \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c\u044b\u043c\u0438, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0445\u043e\u0434\u0430.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u0438\u0433\u0440\u0443 \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0430\u0441\u043e\u0447\u043d\u043e\u0439, \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u0440\u0435\u0439\u0442\u044b <code>image<\/code> \u0438 <code>imageproc<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u043d\u0430\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u0438\u0433\u0440\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435:<\/p>\n<pre><code>[dependencies] image = \"0.24\" imageproc = \"0.23\" serenity = { git = \"https:\/\/github.com\/serenity-rs\/serenity.git\", branch = \"next\", default-features = false, features = [\"client\", \"gateway\", \"rustls_backend\", \"model\", \"unstable_discord_api\"] } tokio = { version = \"1.22\", features = [\"rt-multi-thread\"] } <\/code><\/pre>\n<p>\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043a\u0440\u0435\u0441\u0442\u0438\u043a\u0430, \u043d\u043e\u043b\u0438\u043a\u0430 \u0438 \u043f\u043e\u043b\u043e\u0441\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u0431\u0435\u0434\u043d\u0443\u044e \u0442\u0440\u043e\u0438\u0446\u0443. \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u043e\u0442\u0440\u0438\u0441\u0443\u0435\u043c \u0438\u0433\u0440\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435 \u0438 \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0432 <code>new_game_canvas<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0438\u0433\u0440\u0430. \u041f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>\/play<\/code> \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c, \u0445\u043e\u0447\u0435\u0442 \u043b\u0438 \u0435\u0449\u0451 \u043a\u0442\u043e-\u0442\u043e \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c \u0432 <code>wait_user<\/code>, \u0435\u0441\u043b\u0438 \u0434\u0430, \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0451 \u0432 <code>sessions<\/code>, \u0438\u043d\u0430\u0447\u0435 \u043f\u043e\u043b\u043e\u0436\u0438\u043c \u043d\u0430\u0448\u0435\u0433\u043e \u0438\u0433\u0440\u043e\u043a\u0430 \u043f\u043e\u0434\u043e\u0436\u0434\u0430\u0442\u044c \u0432 \u043f\u043e\u043b\u0435 <code>wait_user<\/code>:<\/p>\n<pre><code class=\"rust\">use std::sync::Arc;  use image::{ImageBuffer, Rgba, Rgb}; use serenity::all::{UserId, CommandInteraction, Message}; use tokio::sync::Mutex;  #[derive(Default)] pub struct Game {     x_image: ImageBuffer&lt;Rgb&lt;u8>, Vec&lt;u8>>,     o_image: ImageBuffer&lt;Rgb&lt;u8>, Vec&lt;u8>>,      horizontal_scratch: ImageBuffer&lt;Rgba&lt;u8>, Vec&lt;u8>>,     vertical_scratch: ImageBuffer&lt;Rgba&lt;u8>, Vec&lt;u8>>,     diagonal_scratch_1: ImageBuffer&lt;Rgba&lt;u8>, Vec&lt;u8>>, \/\/ Left to right     diagonal_scratch_2: ImageBuffer&lt;Rgba&lt;u8>, Vec&lt;u8>>, \/\/ Right to left      new_game_canvas: ImageBuffer&lt;Rgb&lt;u8>, Vec&lt;u8>>,      wait_user: Mutex&lt;Option&lt;(UserId, CommandInteraction, String, Message)>>,      sessions: Mutex&lt;Vec&lt;Arc&lt;Mutex&lt;GameSession>>>>, } <\/code><\/pre>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, <code>wait_user<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e id \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043d\u043e \u0442\u0430\u043a\u0436\u0435 <code>CommandInteraction<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u043b\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0445\u043e\u043b\u0441\u0442\u0430 \u0438\u0433\u0440\u044b \u0438 \u043a\u043d\u043e\u043f\u043e\u043a. \u0422\u0440\u0435\u0442\u044c\u044f <code>String<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u043b\u0438\u0431\u043e \u0438\u043c\u044f \u0447\u043b\u0435\u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0430 \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u043d\u0435\u0442 &#8212; \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u043c\u044f). \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f, \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435: <a href=\"https:\/\/discord.com\/developers\/docs\/reference#message-formatting\" rel=\"noopener noreferrer nofollow\">&lt;@USER_ID><\/a> &#8212; \u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e <code>UserId<\/code>, \u043d\u043e \u043e\u043d\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u0445 <code>embed<\/code> \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u0438\u043c\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0438\u0433\u0440\u043e\u043a\u0430 \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u0435\u0433\u043e \u0438\u0433\u0440\u043e\u0432\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043a\u043e\u0440\u0442\u0435\u0436\u0430 (<code>Message<\/code>) \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0432\u0441\u0435\u043c, \u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0445\u043e\u0434 \u0438\u0433\u0440\u044b \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0438\u0433\u0440\u043e\u043a\u0430\u043c\u0438.<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0438\u0433\u0440\u043e\u0432\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438:<\/p>\n<pre><code class=\"rust\">#[derive(Clone, Copy, PartialEq)] enum GameCell {     None,     First,     Second, }  impl Default for GameCell {     fn default() -> Self {         GameCell::None     } }  struct GameSession {     player: (UserId, CommandInteraction, String, Message), \/\/ Third element is a name of player     player2: (UserId, CommandInteraction, String, Option&lt;Message>), \/\/ No message in a same channel      stage: usize,     cursor_pos: usize,      map: [GameCell; 9],     canvas: ImageBuffer&lt;Rgb&lt;u8>, Vec&lt;u8>>, } <\/code><\/pre>\n<p>\u0418\u0437 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e, \u0437\u0434\u0435\u0441\u044c \u0438\u043c\u0435\u0435\u0442\u0441\u044f <code>stage<\/code> \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c, \u043a\u0442\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0445\u043e\u0434\u0438\u0442, \u0430 \u0442\u0430\u043a\u0436\u0435 <code>cursor_pos<\/code> \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u0445\u0440\u0430\u043d\u044f\u0449\u0430\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e &#171;\u043a\u0443\u0440\u0441\u043e\u0440\u0430&#187; \u0438\u0433\u0440\u043e\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0434\u0438\u0442 \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442.<\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0441 \u043f\u043e\u0434\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/695\/aaf\/911\/695aaf9110691b631c5a9d9e0e96af19.png\" alt=\"(\u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0438 \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0432 GitHub \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438)\" title=\"(\u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0438 \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0432 GitHub \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438)\" width=\"1753\" height=\"364\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/695\/aaf\/911\/695aaf9110691b631c5a9d9e0e96af19.png\"\/><\/p>\n<div><figcaption>(\u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0438 \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0432 GitHub \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438)<\/figcaption><\/div>\n<\/figure>\n<pre><code class=\"rust\">impl Game {     pub fn new() -> Self {         let x_image = image::open(\".\/resources\/x.png\").expect(\"x.png\").into_rgb8();         let o_image = image::open(\".\/resources\/o.png\").expect(\"o.png\").into_rgb8();          let horizontal_scratch = image::open(\".\/resources\/1.png\").expect(\"1.png\").into_rgba8();         let vertical_scratch = image::open(\".\/resources\/2.png\").expect(\"2.png\").into_rgba8();         let diagonal_scratch_1 = image::open(\".\/resources\/3.png\").expect(\"3.png\").into_rgba8();         let diagonal_scratch_2 = image::open(\".\/resources\/4.png\").expect(\"4.png\").into_rgba8();          let new_game_canvas = draw_new_game_canvas();          Self {             x_image,             o_image,              horizontal_scratch,             vertical_scratch,             diagonal_scratch_1,             diagonal_scratch_2,              new_game_canvas,              ..Default::default()         }     } }<\/code><\/pre>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>draw_new_game_canvas()<\/code> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044f:<\/p>\n<pre><code class=\"rust\">use imageproc::drawing::draw_filled_rect_mut; use imageproc::rect::Rect;  fn draw_new_game_canvas() -> ImageBuffer&lt;Rgb&lt;u8>, Vec&lt;u8>> {     let mut canvas = ImageBuffer::new(300, 300);      \/\/ Background     draw_filled_rect_mut(         &amp;mut canvas,         Rect::at(0, 0).of_size(300, 300),         BACKGROUND,     );      draw_filled_rect_mut(         &amp;mut canvas,         Rect::at(98, 0).of_size(4, 300),         GRAY,     );      draw_filled_rect_mut(         &amp;mut canvas,         Rect::at(198, 0).of_size(4, 300),         GRAY,     );      draw_filled_rect_mut(         &amp;mut canvas,         Rect::at(0, 98).of_size(300, 4),         GRAY,     );      draw_filled_rect_mut(         &amp;mut canvas,         Rect::at(0, 198).of_size(300, 4),         GRAY,     );      canvas } <\/code><\/pre>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u0435\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0422\u0430\u043a\u0436\u0435 \u044f \u0440\u0435\u0448\u0438\u043b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443-\u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0443 <code>\/stop<\/code>:<\/p>\n<pre><code class=\"rust\">use serenity::all::CreateCommand;  impl Game { \/\/ ...  pub fn register_play() -> CreateCommand { CreateCommand::new(\"play\") .description(\"Start the game\") }  pub fn register_stop() -> CreateCommand { CreateCommand::new(\"stop\") .description(\"Unimplemented\") }  \/\/ ... }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0432\u0430\u0436\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b: <code>command()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432\u0432\u043e\u0434 \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>\/play<\/code> \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438\u0433\u0440\u043e\u0432\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e:<\/p>\n<pre><code class=\"rust\">use serenity::all::Context;  impl Game { \/\/ ...  pub async fn command(&amp;self, ctx: Context, interaction: CommandInteraction) { \/\/ ... }  \/\/ ... }<\/code><\/pre>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u043e\u0442\u0441\u0435\u0438\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u043d\u0430\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432. \u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0440\u0430\u0437\u0443 \u043e\u0442\u0441\u0435\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>\/stop<\/code>, \u0432\u044b\u0432\u043e\u0434\u044f \u0442\u0435\u043a\u0441\u0442 &#171;Unimplemented!&#187;:<\/p>\n<pre><code class=\"rust\">use serenity::all::{CreateInteractionResponse, CreateInteractionResponseMessage};  pub async fn command(&amp;self, ctx: Context, interaction: CommandInteraction) { if interaction.data.name == \"stop\" { interaction.create_response(&amp;ctx.http, CreateInteractionResponse::Message( CreateInteractionResponseMessage::new() .ephemeral(true) .content(\"Unimplemented!\") )) .await .unwrap();  return; }  if self.is_player_already_in_game(&amp;ctx.http, &amp;interaction).await { return; }  \/\/ ... }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0435\u0441\u0442\u044c \u043b\u0438 \u043d\u0430\u0448 \u0438\u0433\u0440\u043e\u043a \u0443\u0436\u0435 \u0432 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0438\u0433\u0440\u0435:<\/p>\n<pre><code class=\"rust\">use serenity::all::{CreateEmbed, Http};  impl Game { \/\/ ...  async fn is_player_already_in_game(&amp;self, http: &amp;Http, interaction: &amp;CommandInteraction) -> bool {         let message = CreateInteractionResponse::Message(             CreateInteractionResponseMessage::new()                 .ephemeral(true)                 .embed(                     CreateEmbed::new()                         .title(\"Start a new game\")                         .description(\"You have already in the game. For starting a new game you should use the `\/stop` command.\")                 )         );          {             if let Some(val) = self.wait_user.lock().await.as_ref() {                 if val.0 == interaction.user.id {                     interaction.create_response(http, message)                     .await                     .unwrap();                      return true;                 }             }         }          let sessions = self.sessions.lock().await;          for session in &amp;*sessions {             let session = session.lock().await;              if session.player.0 == interaction.user.id                 || session.player2.0 == interaction.user.id             {                 interaction.create_response(http, message)                 .await                 .unwrap();                  return true;             }         }          false     }  \/\/ ... }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0449\u0435\u043c \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 <code>UserId<\/code> \u0432 <code>self.wait_user<\/code>, \u0430 \u043f\u043e\u0442\u043e\u043c \u0432\u043e \u0432\u0441\u0435\u0445 \u0443\u0436\u0435 \u0438\u0434\u0443\u0449\u0438\u0445 \u0438\u0433\u0440\u043e\u0432\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u044f\u0445. \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u043e\u0442\u0441\u0435\u044f\u043b\u0438 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u043d\u0430\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b, \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0436\u0434\u0435\u0442 \u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0435\u0449\u0451 \u0441\u0442\u0430\u0440\u0442\u0430 \u0438\u0433\u0440\u044b \u0432 <code>self.wait_user<\/code>, \u0438\u043d\u0430\u0447\u0435 \u043c\u044b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u0448\u0435\u0433\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0438\u0433\u0440\u043e\u043a\u0430 \u0432 \u044d\u0442\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e:<\/p>\n<pre><code class=\"rust\">use serenity::all::{CreateEmbedAuthor, CreateMessage};  pub async fn command(&amp;self, ctx: Context, interaction: CommandInteraction) { \/\/ ...  let (player, player2) = { let val = { self.wait_user.lock().await.take() };  let name = match &amp;interaction.member { Some(val) => val.nick.clone().unwrap_or_else(|| interaction.user.name.clone()), None => interaction.user.name.clone(), };  if let Some(val) = val { interaction.create_response(&amp;ctx.http, CreateInteractionResponse::Message( CreateInteractionResponseMessage::new() .ephemeral(true) .embed( CreateEmbed::new() .title(\"Please, wait\") ) ) ) .await .unwrap();  \/\/ Channel ids are unique if interaction.channel_id != val.1.channel_id { let message = interaction.channel_id.send_message(&amp;ctx.http,  CreateMessage::new() .embed( CreateEmbed::new() .title( format!( \"The game between {} and {} in progress!\", val.2, name, ) ) ) ) .await .unwrap();  ( val, (interaction.user.id, interaction, name, Some(message)), ) } else { ( val, (interaction.user.id, interaction, name, None), ) } } else { let icon_url = interaction.user.avatar_url().unwrap_or_else(|| interaction.user.default_avatar_url() );  let message = interaction.channel_id.send_message(&amp;ctx.http, CreateMessage::new() .embed( CreateEmbed::new() .author( CreateEmbedAuthor::new(name.clone()) .icon_url(icon_url) ) .title(format!(\"{} wants to play tic-tac-toe game!\", name)) .description(\"You can join to him\/her\/them by using the `\/play` command.\") ) ) .await .unwrap();  interaction.create_response(&amp;ctx.http, CreateInteractionResponse::Message( CreateInteractionResponseMessage::new() .ephemeral(true) .embed( CreateEmbed::new() .title(\"Please, wait for second player...\") ) ) ) .await .unwrap();  *self.wait_user.lock().await = Some((interaction.user.id, interaction, name, message));  return; } };  \/\/ ... }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u0434\u043e\u0436\u0434\u0430\u043b\u0438\u0441\u044c \u0434\u0432\u0443\u0445 \u0438\u0433\u0440\u043e\u043a\u043e\u0432, \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0438\u0445 \u0432 \u043e\u0431\u0449\u0438\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0432\u0441\u0435\u0445 \u0438\u0433\u0440\u043e\u0432\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u0439:<\/p>\n<pre><code class=\"rust\">pub async fn command(&amp;self, ctx: Context, interaction: CommandInteraction) { \/\/ ...   let new_game = Arc::new(Mutex::new(GameSession { player, player2,  stage: 0, cursor_pos: 4,  map: Default::default(), canvas: self.new_game_canvas.clone(), }));  { self.sessions.lock().await.push(Arc::clone(&amp;new_game)); }  self.process_session(&amp;ctx.http, &amp;mut *new_game.lock().await).await; }<\/code><\/pre>\n<p>\u0418 \u043f\u043e\u0434 \u043a\u043e\u043d\u0435\u0446 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <code>self.process_session()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u0430\u0434\u0440 \u043d\u0430\u0448\u0435\u0439 \u0438\u0433\u0440\u044b:<\/p>\n<pre><code class=\"rust\">impl Game { async fn process_session(&amp;self, http: &amp;Http, session: &amp;mut GameSession) {         match session.stage {             0 => {                 show_game_message(                     http,                     &amp;session.player.1,                     session.cursor_pos,                     &amp;session.map,                     &amp;session.canvas,                 ).await;                  show_wait_and_common_message(                     http,                     &amp;session.player2.1,                     &amp;session.canvas,                     &amp;session.player.2,                     &amp;session.player2.2,                     &amp;mut session.player.3,                     session.player2.3.as_mut(),                 ).await;             }             1 => {                 show_game_message(                     http,                     &amp;session.player2.1,                     session.cursor_pos,                     &amp;session.map,                     &amp;session.canvas,                 ).await;                  show_wait_and_common_message(                     http,                     &amp;session.player.1,                     &amp;session.canvas,                     &amp;session.player.2,                     &amp;session.player2.2,                     &amp;mut session.player.3,                     session.player2.3.as_mut(),                 ).await;             }             _ => unreachable!(),         }     } }<\/code><\/pre>\n<p>\u041d\u0438\u0436\u0435 \u044f \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043a\u0430\u0436\u0443 \u0442\u0440\u0438 \u043f\u043e\u0445\u043e\u0436\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442 \u043e\u043a\u043d\u043e \u0443 \u0438\u0433\u0440\u043e\u043a\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0436\u0434\u0451\u0442 \u043b\u0438 \u043e\u043d \u0445\u043e\u0434\u0430 \u0438\u043b\u0438 \u0443\u0436\u0435 \u0445\u043e\u0434\u0438\u0442:<\/p>\n<pre><code class=\"rust\">use serenity::all::{ComponentInteraction, EditInteractionResponse, EditMessage};  async fn show_wait_and_common_message(     http: &amp;Http,     interaction: &amp;CommandInteraction,     canvas: &amp;ImageBuffer&lt;Rgb&lt;u8>, Vec&lt;u8>>,     player_name: &amp;str,     player2_name: &amp;str,     common_message: &amp;mut Message,     common_message2: Option&lt;&amp;mut Message>, ) {     let embed = CreateEmbed::new()         .title(\"Game in process\")         .description(\"Waiting for your turn.\")         .thumbnail(\"attachment:\/\/thumbnail.png\");      let action_row = generate_disabled_action_row();     let attachment = generate_attachment_rgb8(canvas, \"canvas.png\");      interaction.edit_response(http, EditInteractionResponse::new()         .add_embed(embed)         .components(vec![action_row])         .new_attachment(attachment.clone())     ).await.unwrap();      let edited_message = EditMessage::new()         .embed(CreateEmbed::new()             .title(format!(                 \"Game between {} and {} in the progress!\",                 player_name,                 player2_name,             ))             .description(\"You can play this game too by using the `\/play` command.\")             .attachment(\"canvas.png\")         )         .attachment(attachment);      if let Some(val) = common_message2 {         val.edit(http, edited_message.clone()).await.unwrap();     }      common_message.edit(http, edited_message).await.unwrap(); }  async fn show_game_message(     http: &amp;Http,     interaction: &amp;CommandInteraction,     cursor_pos: usize,     map: &amp;[GameCell],     canvas: &amp;ImageBuffer&lt;Rgb&lt;u8>, Vec&lt;u8>>, ) {     let embed = CreateEmbed::new()     .title(\"Your turn\")     .description(\"Press arrows buttons for moving selection square.\");      let action_row = if map[cursor_pos] != GameCell::None {         generate_game_action_row(true, cursor_pos)     }     else {         generate_game_action_row(false, cursor_pos)     };      let mut cloned = canvas.clone();      draw_select_outline(&amp;mut cloned, cursor_pos);      interaction.edit_response(http, EditInteractionResponse::new()         .embed(embed)         .components(vec![action_row])         .new_attachment(generate_attachment_rgb8(&amp;cloned, \"canvas.png\"))     )     .await     .unwrap(); }  async fn update_game_message(http: &amp;Http, interaction: &amp;ComponentInteraction, session: &amp;GameSession) {     let embed = CreateEmbed::new()         .title(\"Your turn\")         .description(\"Press arrows buttons for moving selection square.\");      let action_row = if session.map[session.cursor_pos] != GameCell::None {         generate_game_action_row(true, session.cursor_pos)     }     else {         generate_game_action_row(false, session.cursor_pos)     };      let mut cloned = session.canvas.clone();      draw_select_outline(&amp;mut cloned, session.cursor_pos);      interaction.edit_response(http, EditInteractionResponse::new()         .embed(embed)         .components(vec![action_row])         .new_attachment(generate_attachment_rgb8(&amp;cloned, \"canvas.png\"))     )     .await     .unwrap(); }<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>update_game_message()<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>ComponentInteraction<\/code>, \u0430 \u043d\u0435 <code>CommandInteraction<\/code>. \u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043e\u043a, \u0432\u044b\u0431\u043e\u0440 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0438 \u0432\u0432\u043e\u0434 \u0442\u0435\u043a\u0441\u0442\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 <code>Message Component interaction<\/code>, \u0430 \u043d\u0435 <code>Application Command interaction<\/code>, \u043a\u0430\u043a \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434. \u0412 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043e\u043a.<\/p>\n<p>\u0422\u0440\u0435\u0442\u044c\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>update_game_message()<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u0438\u0433\u0440\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0434\u0438\u0442, \u0434\u0432\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u043a\u0430\u0440\u0442\u0435:<\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f23\/c4a\/128\/f23c4a1285dab68e385c85211002c7a8.png\" width=\"580\" height=\"627\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f23\/c4a\/128\/f23c4a1285dab68e385c85211002c7a8.png\"\/><\/figure>\n<p>\u0414\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0430 \u0432\u044b\u0431\u043e\u0440\u0430 \u043a\u043b\u0435\u0442\u043a\u0438, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439:<\/p>\n<pre><code class=\"rust\">fn draw_select_outline(canvas: &amp;mut ImageBuffer&lt;Rgb&lt;u8>, Vec&lt;u8>>, cell: usize) {     match cell {         0 => {             draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0 + 98, CELLS[cell].1).of_size(4, 102),                  RED,             );                  draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0, CELLS[cell].1 + 98).of_size(98, 4),                  RED,             );         }          1 => {             draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0 + 98, CELLS[cell].1).of_size(4, 102),                  RED,             );                  draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0 - 2, CELLS[cell].1 + 98).of_size(100, 4),                  RED,             );              draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0 - 2, CELLS[cell].1).of_size(4, 98),                  RED,             );         }          2 => {             draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0 - 2, CELLS[cell].1 + 98).of_size(102, 4),                  RED,             );              draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0 - 2, CELLS[cell].1).of_size(4, 98),                  RED,             );         }          3 => {             draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0, CELLS[cell].1 - 2).of_size(102, 4),                  RED,             );              draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0 + 98, CELLS[cell].1 + 2).of_size(4, 100),                  RED,             );                  draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0, CELLS[cell].1 + 98).of_size(98, 4),                  RED,             );         }          4 => {             draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0 - 2, CELLS[cell].1 - 2).of_size(104, 4),                  RED,             );              draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0 + 98, CELLS[cell].1 + 2).of_size(4, 100),                  RED,             );                  draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0 - 2, CELLS[cell].1 + 98).of_size(100, 4),                  RED,             );              draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0 - 2, CELLS[cell].1 + 2).of_size(4, 96),                  RED,             );         }          5 => {             draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0 - 2, CELLS[cell].1 - 2).of_size(102, 4),                  RED,             );              draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0 - 2, CELLS[cell].1 + 98).of_size(102, 4),                  RED,             );              draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0 - 2, CELLS[cell].1 + 2).of_size(4, 96),                  RED,             );         }          6 => {             draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0, CELLS[cell].1 - 2).of_size(102, 4),                  RED,             );              draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0 + 98, CELLS[cell].1 + 2).of_size(4, 98),                  RED,             );         }          7 => {             draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0 - 2, CELLS[cell].1 - 2).of_size(104, 4),                  RED,             );              draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0 + 98, CELLS[cell].1 + 2).of_size(4, 98),                  RED,             );                  draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0 - 2, CELLS[cell].1 + 2).of_size(4, 98),                  RED,             );         }          8 => {             draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0 - 2, CELLS[cell].1 - 2).of_size(102, 4),                  RED,             );              draw_filled_rect_mut(                 canvas,                 Rect::at(CELLS[cell].0 - 2, CELLS[cell].1 + 2).of_size(4, 98),                  RED,             );         }          _ => unreachable!(),     } }<\/code><\/pre>\n<p>\u0413\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432 <code>CELLS<\/code> &#8212; \u0437\u0430\u0445\u0430\u0440\u0434\u043a\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u0439 \u044f\u0447\u0435\u0435\u043a:<\/p>\n<pre><code class=\"rust\">const CELLS: [(i32, i32); 9] = [     (0, 0),     (100, 0),     (200, 0),      (0, 100),     (100, 100),     (200, 100),      (0, 200),     (100, 200),     (200, 200), ];<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 (<code>generate_disabled_action_row()<\/code> \u0438 <code>generate_game_action_row()<\/code>) \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430 \u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0435 \u0443\u0431\u0438\u0440\u0430\u0442\u044c \u043a\u043d\u043e\u043f\u043a\u0438 \u0438\u0433\u0440\u043e\u043a\u0443, \u043e\u0436\u0438\u0434\u0430\u044e\u0449\u0435\u043c\u0443 \u0441\u0432\u043e\u0435\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0445 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c:<\/p>\n<pre><code class=\"rust\">use serenity::all::{ButtonStyle, CreateActionRow, CreateButton};  fn generate_disabled_action_row() -> CreateActionRow {     let left = CreateButton::new(\"left\")         .label(\"\u2190\")         .style(ButtonStyle::Secondary)         .disabled(true);          let down = CreateButton::new(\"down\")         .label(\"\u2193\")         .style(ButtonStyle::Secondary)         .disabled(true);      let up = CreateButton::new(\"up\")         .label(\"\u2191\")         .style(ButtonStyle::Secondary)         .disabled(true);      let right = CreateButton::new(\"right\")         .label(\"\u2192\")         .style(ButtonStyle::Secondary)         .disabled(true);      let send = CreateButton::new(\"send\")         .label(\"Send\")         .style(ButtonStyle::Primary)         .disabled(true);      let action_row = CreateActionRow::Buttons(vec![         left,         down,         up,         right,         send,     ]);      action_row }  fn generate_game_action_row(send_disabled: bool, cursor_position: usize) -> CreateActionRow {     let mut left = CreateButton::new(\"left\")         .label(\"\u2190\")         .style(ButtonStyle::Secondary);          if [0, 3, 6].contains(&amp;cursor_position) {         left = left.disabled(true);     }          let mut down = CreateButton::new(\"down\")         .label(\"\u2193\")         .style(ButtonStyle::Secondary);       if cursor_position >= 6 {         down = down.disabled(true);     }      let mut up = CreateButton::new(\"up\")         .label(\"\u2191\")         .style(ButtonStyle::Secondary);      if cursor_position &lt;= 2 {         up = up.disabled(true);     }      let mut right = CreateButton::new(\"right\")         .label(\"\u2192\")         .style(ButtonStyle::Secondary);       if [2, 5, 8].contains(&amp;cursor_position) {         right = right.disabled(true);     }      let send = CreateButton::new(\"send\")         .label(\"Send\")         .style(ButtonStyle::Primary)         .disabled(send_disabled);      let action_row = CreateActionRow::Buttons(vec![         left,         down,         up,         right,         send,     ]);      action_row }<\/code><\/pre>\n<p>\u041e\u0441\u0442\u0430\u043b\u0430\u0441\u044c \u043e\u0434\u043d\u0430 \u043d\u0435\u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u0438\u0435 (<code>CreateAttachment<\/code>) \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"rust\">use std::io::{BufWriter, Cursor}; use image::{ColorType, ImageOutputFormat}; use serenity::all::CreateAttachment;  fn generate_attachment(image: &amp;[u8], width: u32, height: u32, name: &amp;'static str, color_type: ColorType) -> CreateAttachment {     let buffer = Vec::new();     let cursor = Cursor::new(buffer);     let mut buffered_writer = BufWriter::new(cursor);      image::write_buffer_with_format(         &amp;mut buffered_writer,         &amp;image,         width,         height,         color_type,         ImageOutputFormat::Png,     )     .expect(\"failed to write in buffer\");      let buffer = buffered_writer.into_inner().unwrap().into_inner();      CreateAttachment::bytes(buffer, name) }  fn generate_attachment_rgb8(image: &amp;ImageBuffer&lt;Rgb&lt;u8>, Vec&lt;u8>>, name: &amp;'static str) -> CreateAttachment {     generate_attachment(image, image.width(), image.height(), name, ColorType::Rgb8) }<\/code><\/pre>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0443\u0436\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c <code>Message Component interaction<\/code>:<\/p>\n<pre><code class=\"rust\">impl Game { \/\/ ...  pub async fn component(&amp;self, ctx: Context, component: ComponentInteraction) {         \/\/ We are calling this because we are editing the component         \/\/ interaction or answering to the original interaction in the progress_game()         component.create_response(&amp;ctx.http, CreateInteractionResponse::Acknowledge).await.unwrap();          let original_session = self.get_current_game(&amp;component).await.unwrap();         let mut session = original_session.lock().await;          match component.data.custom_id.as_str() {             \"left\" => {                 if ![0, 3, 6].contains(&amp;session.cursor_pos) {                     session.cursor_pos -= 1;                 }                  update_game_message(&amp;ctx.http, &amp;component, &amp;session).await;             }              \"down\" => {                 if session.cursor_pos &lt;= 5 {                     session.cursor_pos += 3                 }                  update_game_message(&amp;ctx.http, &amp;component, &amp;session).await;             }              \"up\" => {                 if session.cursor_pos >= 3 {                     session.cursor_pos -= 3                 }                  update_game_message(&amp;ctx.http, &amp;component, &amp;session).await;             }              \"right\" => {                 if ![2, 5, 8].contains(&amp;session.cursor_pos) {                     session.cursor_pos += 1                 }                  update_game_message(&amp;ctx.http, &amp;component, &amp;session).await;             }              \"send\" => {                 'condition: {                     if component.user.id == session.player.0 {                         if session.map[session.cursor_pos] != GameCell::None { \/\/ Unreachable in default situation                             break 'condition;                         }                          let cursor_pos = session.cursor_pos;                         session.map[cursor_pos] = GameCell::First;                         self.draw_x(&amp;mut session.canvas, cursor_pos);                     }                     else {                         if session.map[session.cursor_pos] != GameCell::None {                             break 'condition;                         }                          let cursor_pos = session.cursor_pos;                         session.map[cursor_pos] = GameCell::Second;                         self.draw_o(&amp;mut session.canvas, cursor_pos);                     }                 };                  let map = &amp;session.map;                                  \/\/ Checking for win                 \/\/ 0 1 2                 \/\/ 3 4 5                 \/\/ 6 7 8                 let (win_player, id) = if map[0] != GameCell::None &amp;&amp; (map[0] == map[1]) &amp;&amp; (map[1] == map[2]) {                     (map[0], 0)                 }                 else if map[3] != GameCell::None &amp;&amp; (map[3] == map[4]) &amp;&amp; (map[4] == map[5]) {                     (map[3], 1)                 }                 else if map[6] != GameCell::None &amp;&amp; (map[6] == map[7]) &amp;&amp; (map[7] == map[8]) {                     (map[6], 2)                 }                  else if map[0] != GameCell::None &amp;&amp; (map[0] == map[3]) &amp;&amp; (map[3] == map[6]) {                     (map[0], 3)                 }                 else if map[1] != GameCell::None &amp;&amp; (map[1] == map[4]) &amp;&amp; (map[4] == map[7]) {                     (map[1], 4)                 }                 else if map[2] != GameCell::None &amp;&amp; (map[2] == map[5]) &amp;&amp; (map[5] == map[8]) {                     (map[2], 5)                 }                  else if map[0] != GameCell::None &amp;&amp; (map[0] == map[4]) &amp;&amp; (map[4] == map[8]) {                     (map[0], 6)                 }                 else if map[2] != GameCell::None &amp;&amp; (map[2] == map[4]) &amp;&amp; (map[4] == map[6]) {                     (map[2], 7)                 }                  else {                     let mut was_none = false;                     for cell in map {                         if *cell == GameCell::None {                             was_none = true;                             break;                         }                     }                                          if !was_none {                         let message = EditMessage::new()                             .add_embed(CreateEmbed::new()                                 .title(                                     format!(                                         \"The game between {} and {} has finished!\",                                         session.player.2,                                         session.player2.2,                                     )                                 )                                 .description(\"No one wins!\")                                 .attachment(\"canvas.png\")                             )                             .attachment(generate_attachment_rgb8(&amp;session.canvas, \"canvas.png\"));                          self.end_game_with_message(&amp;ctx.http, &amp;mut session, &amp;original_session, message).await;                         return;                     }                      session.stage = (session.stage + 1) % 2;                     session.cursor_pos = 4;                      self.process_session(&amp;ctx.http, &amp;mut session).await;                     return;                 };                  let attachment = self.generate_end_attachment(&amp;mut session, id).await;                  match win_player {                     GameCell::First => {                         let message = EditMessage::new()                             .add_embed(CreateEmbed::new()                                 .title(                                     format!(                                         \"The game between {} and {} has finished!\",                                         session.player.2,                                         session.player2.2,                                     )                                 )                                 .description(format!(\"? {} has won! ?\", session.player.2))                                 .attachment(\"canvas.png\")                             )                             .attachment(attachment);                          self.end_game_with_message(&amp;ctx.http, &amp;mut session, &amp;original_session, message).await;                     },                     GameCell::Second => {                         let message = EditMessage::new()                             .add_embed(CreateEmbed::new()                                 .title(                                     format!(                                         \"The game between {} and {} has finished!\",                                         session.player.2,                                         session.player2.2,                                     )                                 )                                 .description(format!(\"? {} has won! ?\", session.player.2))                                 .attachment(\"canvas.png\")                             )                             .attachment(attachment);                          self.end_game_with_message(&amp;ctx.http, &amp;mut session, &amp;original_session, message).await;                     },                     GameCell::None => unreachable!(),                 }             }             _ => unreachable!(),         }     }  \/\/ ... }<\/code><\/pre>\n<p>\u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<pre><code class=\"rust\">use imageproc::drawing::Canvas;  impl Game { \/\/ ...  async fn get_current_game(&amp;self, message_component: &amp;ComponentInteraction) -> Option&lt;Arc&lt;Mutex&lt;GameSession>>> {         let sessions = self.sessions.lock().await;          let mut has_game = None;         for session in sessions.iter() {             let session_lock = session.lock().await;             if session_lock.player.0 == message_component.user.id ||                  session_lock.player2.0 == message_component.user.id             {                 has_game = Some(Arc::clone(session));             }         }          has_game     }          fn draw_x(&amp;self, image: &amp;mut ImageBuffer&lt;Rgb&lt;u8>, Vec&lt;u8>>, cell_index: usize) {         for y in 0..80 {             for x in 0..80 {                 image.draw_pixel(                     CELLS[cell_index].0 as u32 + 10 + x,                     CELLS[cell_index].1 as u32 + 10 + y,                     *self.x_image.get_pixel(x, y),                 );             }         }     }          fn draw_o(&amp;self, image: &amp;mut ImageBuffer&lt;Rgb&lt;u8>, Vec&lt;u8>>, cell_index: usize) {         for y in 0..80 {             for x in 0..80 {                 image.draw_pixel(                     CELLS[cell_index].0 as u32 + 10 + x,                     CELLS[cell_index].1 as u32 + 10 + y,                     *self.o_image.get_pixel(x, y),                 );             }         }      }  \/\/ ... }<\/code><\/pre>\n<p>\u041c\u044b \u0431\u044b\u043b\u0438 \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0438 \u0441\u0432\u043e\u0439 <code>custom id<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u043b\u0441\u044f \u0437\u0434\u0435\u0441\u044c, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u0430\u043a\u0430\u044f \u043a\u043d\u043e\u043f\u043a\u0430 \u0431\u044b\u043b\u0430 \u043d\u0430\u0436\u0430\u0442\u0430. \u0422\u0443\u0442 \u0436\u0435 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u043d\u0435 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0430\u0441\u044c \u043b\u0438 \u043d\u0430\u0448\u0430 \u0438\u0433\u0440\u0430 \u043f\u043e\u0431\u0435\u0434\u043e\u0439 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0438\u0433\u0440\u043e\u043a\u0430, \u043b\u0438\u0431\u043e \u043d\u0438\u0447\u044c\u0435\u0439. \u0412 \u043a\u043e\u043d\u0446\u0435 \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0433\u0440\u043e\u043a\u0430 <code>ephemeral<\/code> \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u044b\u043b\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0432\u0441\u0435\u043c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0438\u0448\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0435\u0439 \u0438\u0433\u0440\u044b:<\/p>\n<pre><code class=\"rust\">impl Game { \/\/ ... async fn generate_end_attachment(&amp;self, session: &amp;mut GameSession, id: u32) -> CreateAttachment {                 match id {             0..=2 => {                 for y in 100 * id..100 * (id + 1) {                     for x in 0..300 {                         fill_pixel(&amp;mut session.canvas, &amp;self.horizontal_scratch, x, y);                     }                 }             }              3..=5 => {                 for y in 0..300 {                      for x in 100 * (id - 3)..100 * (id - 2) {                         fill_pixel(&amp;mut session.canvas, &amp;self.vertical_scratch, x, y);                     }                 }             }              6 => {                 for y in 0..300 {                      for x in 0..300 {                         fill_pixel(&amp;mut session.canvas, &amp;self.diagonal_scratch_1, x, y);                     }                 }             }              7 => {                 for y in 0..300 {                      for x in 0..300 {                         fill_pixel(&amp;mut session.canvas, &amp;self.diagonal_scratch_2, x, y);                     }                 }             }              _ => unreachable!(),         }          generate_attachment_rgb8(&amp;session.canvas, \"canvas.png\")     }      async fn end_game_with_message(&amp;self, http: &amp;Http, session: &amp;mut GameSession, original_session: &amp;Arc&lt;Mutex&lt;GameSession>>, message: EditMessage) {         session.player.1.delete_response(http).await.unwrap();         session.player2.1.delete_response(http).await.unwrap();          if let Some(val) = &amp;mut session.player2.3 {             val.edit(http, message.clone()).await.unwrap();         }          session.player.3.edit(http, message).await.unwrap();                  let mut games = self.sessions.lock().await;         let pos = games.iter().position(|val| Arc::ptr_eq(val, original_session));         games.swap_remove(pos.unwrap());     } }<\/code><\/pre>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 <code>generate_end_attachment()<\/code> \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: \u043c\u044b \u0431\u0435\u0440\u0451\u043c \u043f\u043e\u043b\u0443\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043d\u0430\u0448\u0435\u0439 \u043f\u043e\u043b\u043e\u0441\u043a\u0438 (\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0435\u0440\u0435\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u0431\u0435\u0434\u043d\u0443\u044e \u0442\u0440\u043e\u0438\u0446\u0443) \u0438 \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0445\u043e\u043b\u0441\u0442\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>fill_pixel()<\/code>:<\/p>\n<pre><code class=\"rust\">fn fill_pixel(canvas: &amp;mut ImageBuffer&lt;Rgb&lt;u8>, Vec&lt;u8>>, scratch: &amp;ImageBuffer&lt;Rgba&lt;u8>, Vec&lt;u8>>, x: u32, y: u32) {     let pixel = canvas.get_pixel(x, y).0;     let pixel2 = scratch.get_pixel(x, y).0;      let alpha = pixel2[3] as f32 \/ 255.0;     let mut output = Rgb([0, 0, 0]);      for i in 0..=2 {         let pixel_f32 = pixel[i] as f32 \/ 255.0;         let pixel2_f32 = pixel2[i] as f32 \/ 255.0;          output.0[i] = ((pixel_f32 * (1.0 - alpha) + pixel2_f32 * alpha) * 255.0).clamp(0.0, 255.0) as u8;     }      canvas.draw_pixel(x, y, output); }<\/code><\/pre>\n<p>\u041d\u0430\u043c \u044d\u0442\u043e\u043c \u0442\u043e\u0447\u043d\u043e \u0432\u0441\u0451. \u0422\u043e \u0435\u0441\u0442\u044c \u0432\u0441\u0451 \u0441 \u043c\u043e\u0434\u0443\u043b\u0435\u043c <code>game.rs<\/code>, \u043c\u044b \u0441 \u043d\u0438\u043c \u043f\u043e\u043a\u043e\u043d\u0447\u0438\u043b\u0438. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u043f\u0440\u0430\u0432\u0438\u0442\u044c <code>main.rs<\/code> \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430!:<\/p>\n<pre><code class=\"rust\">\/\/ main.rs mod game;  use game::Game;  struct Handler {     game: Game, }  impl Handler {     fn new() -> Self {         Self {             game: Game::new(),         }     } }  #[async_trait] impl EventHandler for Handler {     async fn interaction_create(&amp;self, ctx: Context, interaction: Interaction) {         match interaction {             Interaction::Command(command) => {                 match command.data.name.as_str() {                     \"ping\" => ping::command(ctx, command).await,                     \"play\" => self.game.command(ctx, command).await,                     _ => {                         command.create_response(&amp;ctx.http, CreateInteractionResponse::Message(                             CreateInteractionResponseMessage::new()                                 .ephemeral(true)                                 .content(\"Invalid command!\")                         ))                         .await                         .expect(\"failed to create response\");                     }                 }                            }              Interaction::Component(component) => {                 self.game.component(ctx, component).await;             }              _ => (), \/\/ Now other variants are not important         }     }      async fn ready(&amp;self, ctx: Context, ready: Ready) {         println!(\"{} has connected!\", ready.user.name);          \/\/ Trying to get our guild         let guild = ready.guilds[0];         assert_eq!(guild.unavailable, true);         let guild_id = guild.id;          \/\/ We use guild application commands because         \/\/ Command::create_global_application_command may take up         \/\/ to an hour to be updated in the user slash commands list.         guild_id.set_application_commands(&amp;ctx.http, vec![             Game::register_play(),             Game::register_stop(),             ping::register(),          ])         .await         .expect(\"failed to create application command\");     } }  #[tokio::main] async fn main() {     let intents = GatewayIntents::GUILD_MESSAGES         | GatewayIntents::MESSAGE_CONTENT;      let mut client = Client::builder(include_str!(\".\/..\/token.txt\"), intents)         .event_handler(Handler::new()) \/\/ Calling the new() function         .await         .expect(\"Failed to create client!\");      if let Err(err) = client.start().await {         eprintln!(\"Client error: {err:?}\");     } }<\/code><\/pre>\n<p><a href=\"https:\/\/github.com\/dpytaylo\/Tic-tac-toe-Discord-bot\/tree\/current\" rel=\"noopener noreferrer nofollow\">\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0431\u043e\u0442\u0430.<\/a><\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0431\u043e\u0442\u0430 \u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/63af77c5200df56fc17a4cb8\" data-style=\"\" id=\"63af77c5200df56fc17a4cb8\" width=\"\"><\/div>\n<p>\u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432 Discord \u0438\u043c\u0435\u044e\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0430\u0439\u043c\u0430\u0443\u0442. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u0435\u0449\u0451 \u0432\u043d\u043e\u0441\u0438\u0442 \u0441\u0432\u043e\u044e \u043b\u0435\u043f\u0442\u0443 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u043c\u0435\u043d\u044f\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443. \u0422\u0430\u043a \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u043d\u044b\u0445 \u0438\u0433\u0440 \u044d\u0442\u043e \u043d\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0441\u0435\u0439\u0447\u0430\u0441 \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b (\u043f\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0435 Nitro) \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0432 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0445 \u043a\u0430\u043d\u0430\u043b\u0430\u0445, \u043f\u0440\u0430\u0432\u0434\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430 Discord. \u0422\u0430\u043a\u0436\u0435 \u044f \u043d\u0435 \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u043c\u044b \u0432 \u0441\u043a\u043e\u0440\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0443\u0432\u0438\u0434\u0438\u043c \u0438\u0445 \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u0445\u043e\u0442\u044f \u044f \u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u043d\u0430 \u044d\u0442\u043e. \u041d\u043e \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0446\u0435\u043b\u044c \u044d\u0442\u043e\u0433\u043e \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430 &#8212; \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0432\u043e\u0435\u0433\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0431\u043e\u0442\u0430 &#8212; \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0438.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e. \u041c\u043e\u0433\u0443 \u043e\u0442 \u0441\u0435\u0431\u044f \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044f \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u043f\u043e\u043d\u044f\u043b, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u044f\u0436\u0435\u043b\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u0438. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0438 \u044d\u0442\u0430 \u043a\u043e\u043c\u0443-\u0442\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0438\u043b\u0438 \u0434\u0430\u0441\u0442 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0435\u043d\u0438\u0435. \u041f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u0432\u0430\u0448\u0438 \u0437\u0430\u043c\u0435\u0447\u0435\u043d\u0438\u044f \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0439\u0442\u0435 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <code>CTRL + Enter<\/code> \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u0432\u0430\u043c\u0438 \u043e\u0447\u0435\u043f\u044f\u0442\u043a\u0438!<\/p>\n<p><strong>UPD:<br \/><\/strong><a class=\"mention\" href=\"\/users\/thedanikreal\">@TheDanikReal<\/a> \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043f\u043e\u0434\u043c\u0435\u0442\u0438\u043b, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0440\u044f\u0434 \u0438\u0437 \u043a\u043d\u043e\u043f\u043e\u043a (3&#215;3), \u0442.\u043a. \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432(\u0434\u043e 5) <code>ActionRow<\/code> \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044e. \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u044f \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u043b \u0442\u0430\u043a, \u0442\u0430\u043a \u043a\u0430\u043a \u0437\u043d\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043a <code>ActionRow<\/code> \u0434\u043e 5 \u043a\u043d\u043e\u043f\u043e\u043a. \u0415\u0441\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0434\u0435\u044e <a class=\"mention\" href=\"\/users\/thedanikreal\">@TheDanikReal<\/a> \u0438\u0437 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 (\u0441\u0434\u0435\u043b\u0430\u0442\u044c 9 \u043a\u043d\u043e\u043f\u043e\u043a, \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0435 \u043d\u0430 \u043e\u0434\u043d\u0443 \u044f\u0447\u0435\u0439\u043a\u0443 \u043f\u043e\u043b\u044f) \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u043d\u044b\u0439 \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0433\u0435\u0439\u043c\u043f\u043b\u0435\u0439 \u0438\u0437-\u0437\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0435\u0440\u0436\u0435\u043a \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0438\u0433\u0440\u044b.<\/p>\n<h3>\u0421\u0441\u044b\u043b\u043a\u0438:<\/h3>\n<ul>\n<li>\n<p><a href=\"https:\/\/discord.com\/developers\/docs\/intro\" rel=\"noopener noreferrer nofollow\">Discord API<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/serenity-rs\/serenity\" rel=\"noopener noreferrer nofollow\">serenity<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/dpytaylo\/tic-tac-toe-discord-bot\" rel=\"noopener noreferrer nofollow\">\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><\/p>\n<div class=\"tm-article-poll-container\"><!--[--><\/p>\n<div class=\"tm-article-poll tm-article-poll_variant-bordered\">\n<div class=\"tm-notice tm-notice_positive tm-article-poll__notice\"><!----><\/p>\n<div class=\"tm-notice__inner\"><!----><\/p>\n<div class=\"tm-notice__content\" data-test-id=\"notice-content\"><!--[--><span>\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a rel=\"nofollow\" href=\"\/kek\/v1\/auth\/habrahabr\/?back=\/ru\/articles\/710158\/&#038;hl=ru\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/span><!--]--><\/div>\n<\/div>\n<\/div>\n<p><!--[--><\/p>\n<div class=\"tm-article-poll__header\">\u041a\u0430\u043a \u0432\u044b \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u0442\u0435 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u0443 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0435\u0439 \u0432 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0445 \u0447\u0430\u0442\u0430\u0445?<\/div>\n<div class=\"tm-article-poll__answers\"><!--[--><\/p>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">25% <\/span><span class=\"tm-article-poll__answer-label\">\u041f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u0432\u0435\u0449\u044c<\/span><span class=\"tm-article-poll__answer-votes\">2<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 25%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent tm-article-poll__answer-percent_winning\">50% <\/span><span class=\"tm-article-poll__answer-label\">\u0411\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u0430, \u043a\u043e\u0433\u0434\u0430 \u0434\u0430\u0434\u0443\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c Discord<\/span><span class=\"tm-article-poll__answer-votes\">4<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress tm-article-poll__answer-progress_winning\" style=\"width: 50%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">12.5% <\/span><span class=\"tm-article-poll__answer-label\">\u0411\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u0430 \/ \u041d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0430<\/span><span class=\"tm-article-poll__answer-votes\">1<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 12.5%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">12.5% <\/span><span class=\"tm-article-poll__answer-label\">\u041d\u0435 \u0437\u043d\u0430\u044e \/ \u041d\u0435 \u0441\u043b\u044b\u0448\u0430\u043b \u043e\u0431 \u044d\u0442\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438<\/span><span class=\"tm-article-poll__answer-votes\">1<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 12.5%\"><\/div>\n<\/div>\n<\/div>\n<p><!--]--><\/div>\n<div class=\"tm-article-poll__stats\"> \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 8 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.   \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u043b\u0441\u044f 1 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c. <\/div>\n<p><!--]--><\/div>\n<p><!--]--><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/710158\/\"> https:\/\/habr.com\/ru\/articles\/710158\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<p>\u0412\u044b \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u0445\u043e\u0442\u0435\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0431\u043e\u0442 \u0434\u043b\u044f \u0438\u0433\u0440\u044b \u0432 \u043a\u0440\u0435\u0441\u0442\u0438\u043a\u0438-\u043d\u043e\u043b\u0438\u043a\u0438 \u0432 Discord? \u0422\u0430\u043a \u0435\u0449\u0451 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 ?<em>blazingly fast<\/em>?Rust \u0438 \u043a\u0440\u0435\u0439\u0442\u0430 <code>serenity<\/code>! \u0412\u0441\u0435\u0445 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n<h3>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435<\/h3>\n<p>\u041f\u044b\u0442\u0430\u044f\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c Discord \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0431\u043e\u0442\u0430 \u043a \u043d\u0435\u043c\u0443 \u0434\u043b\u044f \u043c\u043e\u0435\u0433\u043e \u043d\u043e\u0432\u043e\u0438\u0441\u043f\u0435\u0447\u0451\u043d\u043d\u043e\u0433\u043e \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442\u0430, \u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u0432 <a href=\"https:\/\/discord.com\/developers\/docs\/intro\" rel=\"noopener noreferrer nofollow\">Discord API<\/a> \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0431\u043e\u0442\u043e\u0432, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u0432 \u0441\u0432\u043e\u0435\u0439 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435. \u0412 \u043d\u0435\u0439 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e\u0431 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043d\u044e\u0430\u043d\u0441\u0430\u0445 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f Discord \u0431\u043e\u0442\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u043e\u0432\u044b\u0445 \u0444\u0438\u0448\u0435\u043a, \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Rust, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u0440\u0435\u0439\u0442 <a href=\"https:\/\/docs.rs\/serenity\/latest\/serenity\/\" rel=\"noopener noreferrer nofollow\">serenity<\/a>.<\/p>\n<h3>\u0427\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f?<\/h3>\n<ul>\n<li>\n<p>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u043d\u0438\u0435 \u0431\u0430\u0437\u044b \u044f\u0437\u044b\u043a\u0430 Rust (Rust Book) \u0438 \u0430\u0441\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043d\u0451\u043c.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0435\u0440\u0432\u0435\u0440 \u0432 Discord&#8217;\u0435 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0441 \u043e\u0434\u043d\u0438\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u043c \u043a\u0430\u043d\u0430\u043b\u043e\u043c.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u044b<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443. \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430 \u0435\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0430\u043a\u043a\u0430\u0443\u043d\u0442 <a href=\"https:\/\/discord.com\/developers\" rel=\"noopener noreferrer nofollow\">\u043d\u0430 \u0441\u0430\u0439\u0442\u0435 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 Discord<\/a>. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u0432 \u0441\u0432\u043e\u0451\u043c Discord \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0435 \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432\u043e \u0432\u043a\u043b\u0430\u0434\u043a\u0443 <code>Applications<\/code>. \u0422\u0430\u043c \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 <code>New Application<\/code>:<\/p>\n<figure class=\"bordered full-width\"><\/figure>\n<p>\u0412\u0432\u043e\u0434\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430 \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c <code>Create<\/code>:<\/p>\n<figure class=\"bordered full-width\"><\/figure>\n<p>\u041f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u0432\u044b\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u043a\u043d\u043e \u043e\u0431\u0449\u0438\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0412 \u043d\u0451\u043c \u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b \u0438\u043a\u043e\u043d\u043a\u0443 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430. \u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043d\u0430\u0434\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f-\u0431\u043e\u0442\u0430 \u0432\u043e \u0432\u043a\u043b\u0430\u0434\u043a\u0435 \u0441\u043b\u0435\u0432\u0430:<\/p>\n<figure class=\"bordered\"><\/figure>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0431\u043e\u0442\u0430 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 <code>Add Bot<\/code> \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0430 <code>Reset Token<\/code>:<\/p>\n<figure class=\"bordered full-width\"><\/figure>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u0442\u043e\u043a\u0435\u043d, \u0438 \u0441\u0442\u0430\u0440\u0430\u0435\u043c\u0441\u044f \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043d\u0435 \u043f\u043e\u043f\u0430\u043b \u0432 \u0447\u0443\u0436\u0438\u0435 \u0440\u0443\u043a\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u0448 \u0431\u043e\u0442.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0448\u0442\u0440\u0438\u0445\u043e\u043c \u0432 \u043d\u0430\u0448\u0435\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0431\u043e\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0434\u0435\u043b <code>Privileged Gateway Intents<\/code>. <code>Intents<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043d\u0430\u043c \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c\/\u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0431\u043e\u0442\u0430 \u0442\u0430\u043a\u0438\u0435, \u043a\u0430\u043a <code>Presence Intent<\/code> (\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439), <code>Server Member Intent<\/code> (\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0447\u043b\u0435\u043d\u0430\u043c\u0438 \u0433\u0438\u043b\u044c\u0434\u0438\u0439(\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432)) \u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043d\u0430\u043c \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441 <code>Message Content Intent<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439:<\/p>\n<figure class=\"bordered full-width\"><\/figure>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0431\u043e\u0442\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430 \u043d\u0430 \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0435\u0440. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432\u043e \u0432\u043a\u043b\u0430\u0434\u043a\u0443 <code>OAuth2\/URL Generator<\/code>:<\/p>\n<figure class=\"bordered full-width\"><\/figure>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c <code>bot<\/code> \u0432 <code>Scopes<\/code>, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b. \u0410 \u0432 <code>Bot permissions<\/code> \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 <code>Administrator<\/code>. \u041e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u043d\u0430\u043c \u0442\u0432\u043e\u0440\u0438\u0442\u044c \u0432\u0441\u0451, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u0436\u0435\u043b\u0430\u0435\u043c, \u043d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0435\u0441\u044c \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0431\u043e\u0442, \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0431\u043e\u0442\u0430, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443, \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0431\u043e\u0442\u0430 \u043d\u0430 \u043d\u0430\u0448 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440:<\/p>\n<figure class=\"bordered full-width\"><\/figure>\n<figure class=\"bordered full-width\"><\/figure>\n<h3>\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u0440\u043e\u0431\u0430<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u0440\u0435\u0439\u0442 <code>serenity<\/code> \u0432 \u043d\u0430\u0448 <code>Cargo.TOML<\/code> \u0444\u0430\u0439\u043b:<\/p>\n<pre><code>name = \"tic-tac-toe-discord-bot\" version = \"0.1.0\" edition = \"2021\"  [dependencies] serenity = { git = \"https:\/\/github.com\/serenity-rs\/serenity.git\", rev = \"ba3be69166f54c5986e4cc9438bc5bb4606fa4c2\", default-features = false, features = [\"builder\", \"cache\", \"client\", \"model\", \"utils\", \"gateway\", \"rustls_backend\"] } tokio = { version = \"1.22\", features = [\"rt-multi-thread\"] }<\/code><\/pre>\n<blockquote>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0435\u043d\u0438\u0435:<\/strong><br \/>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <code>serenity<\/code> \u0441 \u0432\u0435\u0442\u043a\u0438 <code>next<\/code> \u0438 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043c\u0438\u0442\u0430 (<code>ba3be69166f54c5986e4cc9438bc5bb4606fa4c2<\/code>).<\/p>\n<\/blockquote>\n<p>\u0412 <code>main.rs<\/code> \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0438 \u0432\u0441\u0451, \u043a\u0430\u043a \u043d\u0430\u0434\u043e:<\/p>\n<pre><code class=\"rust\">use serenity::async_trait; use serenity::all::{Message, Ready}; use serenity::prelude::*;  struct Handler;  #[async_trait] impl EventHandler for Handler {     async fn message(&amp;self, ctx: Context, msg: Message) {         if msg.content == \"!ping\" {             if let Err(err) = msg.reply(&amp;ctx.http, \"pong!\").await {                 eprintln!(\"Error: {err}\");             }         }     }      async fn ready(&amp;self, _: Context, ready: Ready) {         println!(\"{} has connected!\", ready.user.name);     } }  #[tokio::main] async fn main() {     let intents = GatewayIntents::GUILD_MESSAGES         | GatewayIntents::MESSAGE_CONTENT;      let mut client = Client::builder(include_str!(\".\/..\/token.txt\"), intents)         .event_handler(Handler)         .await         .expect(\"Failed to create client!\");      if let Err(err) = client.start().await {         eprintln!(\"Client error: {err:?}\");     } }<\/code><\/pre>\n<p><a href=\"https:\/\/github.com\/dpytaylo\/tic-tac-toe-discord-bot\/tree\/simple-ping-pong-bot\" rel=\"noopener noreferrer nofollow\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0434\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u043e\u0442\u0430.<\/a><\/p>\n<blockquote>\n<p>\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0430\u0439\u043b \u0441 \u0442\u043e\u043a\u0435\u043d\u043e\u043c (<code>token.txt<\/code>) \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/p>\n<\/blockquote>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0432\u0441\u0451 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0442\u043e \u043f\u0440\u0438 \u0432\u0432\u043e\u0434\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>!ping<\/code> \u0431\u043e\u0442 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043c \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c &#171;pong!&#187;:<\/p>\n<figure class=\"\"><\/figure>\n<p>\u0412\u044b \u0441\u043a\u0430\u0436\u0435\u0442\u0435: &#171;\u0425\u043e\u0440\u043e\u0448\u043e, \u044d\u0442\u043e \u043c\u044b \u0443\u0436\u0435 \u0432\u0438\u0434\u0435\u043b\u0438 \u0434\u0432\u0435\u0441\u0442\u0438 \u0440\u0430\u0437 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430\u0445, \u043c\u043e\u0436\u0435\u0448\u044c \u043b\u0438 \u0442\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0445\u043e\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435?&#187; \u0418 \u044f \u043e\u0442\u0432\u0435\u0447\u0443 &#8212; \u0434\u0430. \u0414\u0430 \u043d\u0430\u0447\u043d\u0451\u0442\u0441\u044f \u0441 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435!<\/p>\n<h3>\u0420\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438<\/h3>\n<p>\u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 Discord \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f (<code>Interactions<\/code>), \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0435:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th data-colwidth=\"352\" width=\"352\">\n<p>\u0412\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435<\/p>\n<\/th>\n<th>\n<p>\u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td data-colwidth=\"352\" width=\"352\">\n<p align=\"left\"><a href=\"https:\/\/discord.com\/developers\/docs\/interactions\/receiving-and-responding#interaction-response-object-modal\" rel=\"noopener noreferrer nofollow\">PING<\/a><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 <code>webhook-based interactions<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"352\" width=\"352\">\n<p align=\"left\"><a href=\"https:\/\/discord.com\/developers\/docs\/interactions\/application-commands\" rel=\"noopener noreferrer nofollow\">APPLICATION_COMMAND<\/a><\/p>\n<\/td>\n<td>\n<p align=\"left\">&#8212; \u0412\u0432\u043e\u0434 \u0441 \u0447\u0430\u0442\u0430 (\u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434\u044b)<br \/>&#8212; \u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u0435 \u043c\u0435\u043d\u044e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f<br \/>&#8212; \u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u0435 \u043c\u0435\u043d\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"352\" width=\"352\">\n<p align=\"left\"><a href=\"https:\/\/discord.com\/developers\/docs\/interactions\/message-components\" rel=\"noopener noreferrer nofollow\">MESSAGE_COMPONENT<\/a><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043e\u043a, \u0432\u044b\u0431\u043e\u0440\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0435\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"352\" width=\"352\">\n<p align=\"left\"><a href=\"https:\/\/discord.com\/developers\/docs\/interactions\/receiving-and-responding#interaction-response-object-modal\" rel=\"noopener noreferrer nofollow\">APPLICATION_COMMAND_AUTOCOMPLETE<\/a><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0410\u0432\u0442\u043e\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"352\" width=\"352\">\n<p align=\"left\"><a href=\"https:\/\/discord.com\/developers\/docs\/interactions\/receiving-and-responding#interaction-response-object-modal\" rel=\"noopener noreferrer nofollow\">MODAL_SUBMIT<\/a><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0432\u0432\u043e\u0434\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u0437 \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u043a\u043e\u043d<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430, \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>Slash commands<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"bordered full-width\">\n<div><figcaption> (\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434\u044b)<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f Discord \u0431\u043e\u0442\u0430\u043c\u0438: \u043e\u043d\u0438 \u0434\u0430\u044e\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b, \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0443\u0440\u043e\u0432\u043d\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 (Server Settings > Apps > Integrations). \u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043d\u0438\u0445 \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u043f\u043e \u0432\u044b\u0437\u043e\u0432\u0443 \u0438\u0433\u0440\u044b:  <code>\/play<\/code>.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0432\u0430\u0436\u043d\u044b\u0445 \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0431\u043e\u0442\u043e\u0432 \u0431\u044b\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 (<code>ephemeral<\/code>), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0438\u0434\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434\u0443. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0431\u043e\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0434\u0432\u0443\u0445 \u043a\u043b\u0438\u043a\u043e\u0432 (Server Settings > Apps > App Directory). \u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0432 \u043d\u0430\u0448\u0435\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043d\u0430\u043c \u044d\u0442\u043e \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u0432\u0432\u043e\u0434\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u0445\u043e\u0434\u0430.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043d\u0430\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0437\u0430\u043b\u043e\u0436\u0435\u043d \u0432 <code>Message Components<\/code>. \u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043d\u0435\u0433\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043d\u043e\u043f\u043a\u0438, \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0438 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u043d\u043e \u0432\u0432\u043e\u0434\u0430 \u0442\u0435\u043a\u0441\u0442\u0430. \u041a\u043d\u043e\u043f\u043a\u0443 \u0438 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 <code>`ActionRow`<\/code> \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0433\u0434\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043d\u043e\u043f\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u043f\u044f\u0442\u044c, \u0430 \u0441\u043f\u0438\u0441\u043e\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d. \u0410 \u0441\u0430\u043c\u0438\u0445 <code>ActionRow<\/code> \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u043e\u0436\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u044f\u0442\u044c \u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044e. \u041e\u0442\u0441\u044e\u0434\u0430 \u043d\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e <code>ActionRow<\/code> \u0438 \u043a\u043d\u043e\u043f\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442\u044c \u043d\u0430\u043c \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0438\u0433\u0440\u043e\u0432\u043e\u043c\u0443 \u043f\u043e\u043b\u044e (3&#215;3), \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0430\u0448 \u0445\u043e\u0434 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u0438\u043a\u0443.<\/p>\n<figure class=\"bordered full-width\">\n<div><figcaption>(\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 Message Components)<\/figcaption><\/div>\n<\/figure>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p>Interaction Callback Type<\/p>\n<\/th>\n<th data-colwidth=\"160\" width=\"160\">\n<p>CreateInteractionResponse<\/p>\n<\/th>\n<th>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">PONG<\/p>\n<\/td>\n<td data-colwidth=\"160\" width=\"160\">\n<p align=\"left\"><code>Pong<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044c <code>PING<\/code> \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">CHANNEL_MESSAGE_WITH_SOURCE<\/p>\n<\/td>\n<td data-colwidth=\"160\" width=\"160\">\n<p align=\"left\"><code>Message<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE<\/p>\n<\/td>\n<td data-colwidth=\"160\" width=\"160\">\n<p align=\"left\"><code>Defer<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c <code>interaction response<\/code> \u043f\u043e\u0437\u0436\u0435. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">DEFERRED_UPDATE_MESSAGE<\/p>\n<\/td>\n<td data-colwidth=\"160\" width=\"160\">\n<p align=\"left\"><code>Acknowledge<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">[\u0414\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432] \u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0436\u0435. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">UPDATE_MESSAGE<\/p>\n<\/td>\n<td data-colwidth=\"160\" width=\"160\">\n<p align=\"left\"><code>UpdateMessage<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">[\u0414\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432] \u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d \u043a \u043d\u0435\u043c\u0443<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">APPLICATION_COMMAND_AUTOCOMPLETE_RESULT<\/p>\n<\/td>\n<td data-colwidth=\"160\" width=\"160\">\n<p align=\"left\"><code>Autocomplete<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0430\u0432\u0442\u043e\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u043c\u0438<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">MODAL<\/p>\n<\/td>\n<td data-colwidth=\"160\" width=\"160\">\n<p align=\"left\"><code>Modal<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u0437\u0430\u043c\u0435\u043d\u0438\u043b \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 Discord API \u043d\u0430 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 <code>enum CreateInteractionResponse<\/code> \u0438\u0437 serenity, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u0430\u0448\u0435\u043c \u0431\u043e\u0442\u0435. \u0412 \u043d\u0451\u043c \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e <code>CHANNEL_MESSAGE_WITH_SOURCE<\/code> (<code>Message<\/code>) \u0438 <code>DEFERRED_UPDATE_MESSAGE<\/code> (<code>Acknowledge<\/code>). \u041f\u0435\u0440\u0432\u043e\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0441\u043b\u0430\u0442\u044c \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0445\u043e\u0434 \u0438\u0433\u0440\u043e\u043a\u0430, \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u044f \u0443\u0436\u0435 \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0435\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>CommandInteraction<\/code>.<\/p>\n<blockquote>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<\/strong><br \/>\u042d\u0442\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 Discord API \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 <a href=\"https:\/\/discord.com\/developers\/docs\/intro\" rel=\"noopener noreferrer nofollow\">https:\/\/discord.com\/developers\/docs\/intro<\/a>. \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e!<\/p>\n<\/blockquote>\n<h3>\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434<\/h3>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435, \u0441 \u0447\u0435\u0433\u043e \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u043e \u0431\u044b \u043d\u0430\u0447\u0430\u0442\u044c, \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>!ping<\/code> \u043d\u0430 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0444\u0430\u0439\u043b <code>ping.rs<\/code> \u0441 \u0434\u0432\u0443\u043c\u044f \u0444\u0443\u043d\u0446\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u043d\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434\u0443!:<\/p>\n<pre><code class=\"rust\">use serenity::all::{CommandInteraction, CreateCommand, CreateInteractionResponse, CreateInteractionResponseMessage}; use serenity::prelude::Context;  pub fn register() -> CreateCommand {     CreateCommand::new(\"ping\")         .description(\"Creates ephemeral message with \\\"pong\\\" text\") }  pub async fn command(ctx: Context, interaction: CommandInteraction) {     interaction.create_response(&amp;ctx.http, CreateInteractionResponse::Message(         CreateInteractionResponseMessage::new()             .ephemeral(true)             .content(\"pong!\")     ))     .await     .expect(\"failed to create interaction\"); }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>register<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0438\u043c\u044f \u043d\u0430\u0448\u0435\u0439 \u0441\u043b\u044d\u0448-\u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a \u043d\u0435\u0439 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 (\u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u0432\u0432\u043e\u0434\u0430), \u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>application_command<\/code> \u043c\u044b \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0432\u044b\u0434\u0430\u0432\u0430\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044e.<\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u043d\u0430\u0448 \u043c\u043e\u0434\u0443\u043b\u044c <code>ping<\/code> \u0441 \u043d\u0430\u0448\u0435\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <code>interaction_create<\/code> \u043c\u0435\u0442\u043e\u0434 \u0432 <code>EventHandler<\/code> \u0442\u0440\u0435\u0439\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 <code>main.rs<\/code> \u0444\u0430\u0439\u043b\u0435:<\/p>\n<pre><code class=\"rust\">mod ping;  use serenity::all::Interaction; use serenity::builder::{CreateInteractionResponse, CreateInteractionResponseMessage};  #[async_trait] impl EventHandler for Handler {     async fn interaction_create(&amp;self, ctx: Context, interaction: Interaction) {         match interaction {             Interaction::Command(command) => {                 match command.data.name.as_str() {                     \"ping\" => ping::command(ctx, command).await,                     _ => {                         command.create_response(&amp;ctx.http, CreateInteractionResponse::Message(                             CreateInteractionResponseMessage::new()                                 .ephemeral(true)                                 .content(\"Invalid command!\")                         ))                         .await                         .expect(\"failed to create response\");                     }           <\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-385462","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/385462","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=385462"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/385462\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=385462"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=385462"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=385462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}