|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | + <head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <title>V3.18 | Discord.Net Documentation </title> |
| 6 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 7 | + <meta name="title" content="V3.18 | Discord.Net Documentation "> |
| 8 | + |
| 9 | + |
| 10 | + <link rel="icon" href="../../favicon.png"> |
| 11 | + <link rel="stylesheet" href="../../public/docfx.min.css"> |
| 12 | + <link rel="stylesheet" href="../../public/main.css"> |
| 13 | + <meta name="docfx:navrel" content="../../toc.html"> |
| 14 | + <meta name="docfx:tocrel" content="../toc.html"> |
| 15 | + |
| 16 | + <meta name="docfx:rel" content="../../"> |
| 17 | + |
| 18 | + |
| 19 | + <meta name="docfx:docurl" content="https://github.com/discord-net/Discord.Net/blob/dev/docs/guides/breakings/v3.18.md/#L1"> |
| 20 | + <meta name="loc:inThisArticle" content="In this article"> |
| 21 | + <meta name="loc:searchResultsCount" content="{count} results for "{query}""> |
| 22 | + <meta name="loc:searchNoResults" content="No results for "{query}""> |
| 23 | + <meta name="loc:tocFilter" content="Filter by title"> |
| 24 | + <meta name="loc:nextArticle" content="Next"> |
| 25 | + <meta name="loc:prevArticle" content="Previous"> |
| 26 | + <meta name="loc:themeLight" content="Light"> |
| 27 | + <meta name="loc:themeDark" content="Dark"> |
| 28 | + <meta name="loc:themeAuto" content="Auto"> |
| 29 | + <meta name="loc:changeTheme" content="Change theme"> |
| 30 | + <meta name="loc:copy" content="Copy"> |
| 31 | + <meta name="loc:downloadPdf" content="Download PDF"> |
| 32 | + |
| 33 | + <script type="module" src="./../../public/docfx.min.js"></script> |
| 34 | + |
| 35 | + <script> |
| 36 | + const theme = localStorage.getItem('theme') || 'auto' |
| 37 | + document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme) |
| 38 | + </script> |
| 39 | + |
| 40 | + <meta property="og:description" content="Among the changes in V3.18 was components V2, while splendid, it did bring with it a few changes you should be aware of."><meta property="og:title" content="V3.18 | Discord.Net Documentation "><meta property="og:site_name" content="Discord.Net Docs"><meta name="theme-color" content="#995EA7"><meta property="og:image" content="https://raw.githubusercontent.com/Discord-Net/Discord.Net/dev/docs/marketing/logo/PackageLogo.png"></head> |
| 41 | + |
| 42 | + <body class="tex2jax_ignore" data-layout="" data-yaml-mime=""> |
| 43 | + <header class="bg-body border-bottom"> |
| 44 | + <nav id="autocollapse" class="navbar navbar-expand-md" role="navigation"> |
| 45 | + <div class="container-xxl flex-nowrap"> |
| 46 | + <a class="navbar-brand" href="../../index.html"> |
| 47 | + <img id="logo" class="svg" src="../../marketing/logo/SVG/Logomark Purple.svg" alt="Discord.Net"> |
| 48 | + Discord.Net |
| 49 | + </a> |
| 50 | + <button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation"> |
| 51 | + <i class="bi bi-three-dots"></i> |
| 52 | + </button> |
| 53 | + <div class="collapse navbar-collapse" id="navpanel"> |
| 54 | + <div id="navbar"> |
| 55 | + <form class="search" role="search" id="search"> |
| 56 | + <i class="bi bi-search"></i> |
| 57 | + <input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search"> |
| 58 | + </form> |
| 59 | + </div> |
| 60 | + </div> |
| 61 | + </div> |
| 62 | + </nav> |
| 63 | + </header> |
| 64 | + |
| 65 | + <main class="container-xxl"> |
| 66 | + <div class="toc-offcanvas"> |
| 67 | + <div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel"> |
| 68 | + <div class="offcanvas-header"> |
| 69 | + <h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5> |
| 70 | + <button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button> |
| 71 | + </div> |
| 72 | + <div class="offcanvas-body"> |
| 73 | + <nav class="toc" id="toc"></nav> |
| 74 | + </div> |
| 75 | + </div> |
| 76 | + </div> |
| 77 | + |
| 78 | + <div class="content"> |
| 79 | + <div class="actionbar"> |
| 80 | + <button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents"> |
| 81 | + <i class="bi bi-list"></i> |
| 82 | + </button> |
| 83 | + |
| 84 | + <nav id="breadcrumb"></nav> |
| 85 | + </div> |
| 86 | + |
| 87 | + <article data-uid="Guides.Breakings.V3_18"> |
| 88 | +<h1 id="v318">V3.18</h1> |
| 89 | + |
| 90 | +<p>Among the changes in V3.18 was components V2, while splendid, it did bring with it a few changes you should be aware of.</p> |
| 91 | +<ul> |
| 92 | +<li>IMessage</li> |
| 93 | +</ul> |
| 94 | +<p>Messages components type has changed. As a patch you can convert it to an <code>IEnumerable<ActionRowComponent></code> again like so:</p> |
| 95 | +<pre><code class="lang-cs">IMessage message = component.Message; |
| 96 | +IReadOnlyCollection<IMessageComponent>? components = message.Components; |
| 97 | +IEnumerable<ActionRowComponent>? componentsLegacy = components.OfType<ActionRowComponent>(); |
| 98 | +</code></pre> |
| 99 | +<ul> |
| 100 | +<li>Nested components</li> |
| 101 | +</ul> |
| 102 | +<p>The usage of components with <code>ActionRowBuilder</code> and <code>ComponentBuilder</code> has a type change as well. You can find examples in <a class="xref" href="../components_v2/advanced.html">Components_V2_Advanced</a>.</p> |
| 103 | +<ul> |
| 104 | +<li>Components V2 Flag</li> |
| 105 | +</ul> |
| 106 | +<p>To use Components V2 in a message (through <code>ModifyAsync</code>/<code>UpdateAsync</code>/...), a specific flag has to be set. This cannot be undone though :^). You only have to set it if you modify a message that didn't have components v2 in them to begin with (or if you already set the flag manually - obviously). This means that if you created a message with your bot that has components in it, the flag will automatically be set.</p> |
| 107 | +<p>Otherwise, you can manually set it like so:</p> |
| 108 | +<pre><code class="lang-cs">MessageFlags? flags = component.Message.Flags ?? MessageFlags.None; |
| 109 | +flags = flags | MessageFlags.ComponentsV2; |
| 110 | + |
| 111 | +await component.UpdateAsync(m => |
| 112 | + { |
| 113 | + m.Flags = flags; |
| 114 | + m.Components = cv2builder.Build(); |
| 115 | + }); |
| 116 | +</code></pre> |
| 117 | + |
| 118 | +</article> |
| 119 | + |
| 120 | + <div class="contribution d-print-none"> |
| 121 | + <a href="https://github.com/discord-net/Discord.Net/blob/dev/docs/guides/breakings/v3.18.md/#L1" class="edit-link">Edit this page</a> |
| 122 | + </div> |
| 123 | + |
| 124 | + <div class="next-article d-print-none border-top" id="nextArticle"></div> |
| 125 | + |
| 126 | + </div> |
| 127 | + |
| 128 | + <div class="affix"> |
| 129 | + <nav id="affix"></nav> |
| 130 | + </div> |
| 131 | + </main> |
| 132 | + |
| 133 | + <div class="container-xxl search-results" id="search-results"></div> |
| 134 | + |
| 135 | + <footer class="border-top text-secondary"> |
| 136 | + <div class="container-xxl"> |
| 137 | + <div class="flex-fill"> |
| 138 | + Discord.Net © 2015-2025 3.18.0 |
| 139 | + </div> |
| 140 | + </div> |
| 141 | + </footer> |
| 142 | + </body> |
| 143 | +</html> |
0 commit comments