Skip to content

Commit

Permalink
Deploying to gh-pages from @ a06c77f 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobCoffee committed Nov 21, 2023
1 parent 0cd3141 commit 3df8316
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 120 deletions.
67 changes: 38 additions & 29 deletions latest/_modules/src/byte/lib/utils.html
Original file line number Diff line number Diff line change
Expand Up @@ -244,38 +244,47 @@
<article class="yue" role="main">
<h1>Source code for src.byte.lib.utils</h1><div class="highlight"><pre>
<span></span><span id="1-1"><span class="sd">&quot;&quot;&quot;Byte utilities.&quot;&quot;&quot;</span>
</span><span id="1-2"><span class="kn">from</span> <span class="nn">discord.ext</span> <span class="kn">import</span> <span class="n">commands</span>
</span><span id="1-3"><span class="kn">from</span> <span class="nn">discord.ext.commands</span> <span class="kn">import</span> <span class="n">Context</span><span class="p">,</span> <span class="n">check</span>
</span><span id="1-4">
</span><span id="1-5"><span class="kn">from</span> <span class="nn">src.byte.lib</span> <span class="kn">import</span> <span class="n">settings</span>
</span><span id="1-6">
</span><span id="1-7"><span class="n">__all__</span> <span class="o">=</span> <span class="p">(</span><span class="s2">&quot;is_byte_dev_or_owner&quot;</span><span class="p">,)</span>
</span><span id="1-8">
</span><span id="1-2"><span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">annotations</span>
</span><span id="1-3">
</span><span id="1-4"><span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">TYPE_CHECKING</span>
</span><span id="1-5">
</span><span id="1-6"><span class="kn">from</span> <span class="nn">discord.ext</span> <span class="kn">import</span> <span class="n">commands</span>
</span><span id="1-7">
</span><span id="1-8"><span class="kn">from</span> <span class="nn">src.byte.lib</span> <span class="kn">import</span> <span class="n">settings</span>
</span><span id="1-9">
<div class="viewcode-block" id="is_byte_dev_or_owner">
<a class="viewcode-back" href="../../../../byte/api/lib/utils.html#src.byte.lib.utils.is_byte_dev_or_owner">[docs]</a>
</span><span id="1-10"><span class="k">def</span> <span class="nf">is_byte_dev_or_owner</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="n">check</span><span class="p">:</span>
</span><span id="1-11"><span class="w"> </span><span class="sd">&quot;&quot;&quot;Check if the user is a Byte Dev or Owner.</span>
</span><span id="1-10"><span class="k">if</span> <span class="n">TYPE_CHECKING</span><span class="p">:</span>
</span><span id="1-11"> <span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Any</span>
</span><span id="1-12">
</span><span id="1-13"><span class="sd"> Returns:</span>
</span><span id="1-14"><span class="sd"> A check function.</span>
</span><span id="1-15"><span class="sd"> &quot;&quot;&quot;</span>
</span><span id="1-16">
</span><span id="1-17"> <span class="k">async</span> <span class="k">def</span> <span class="nf">predicate</span><span class="p">(</span><span class="n">ctx</span><span class="p">:</span> <span class="n">Context</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
</span><span id="1-18"><span class="w"> </span><span class="sd">&quot;&quot;&quot;Check if the user is a Byte Dev or Owner.</span>
</span><span id="1-19">
</span><span id="1-20"><span class="sd"> Args:</span>
</span><span id="1-21"><span class="sd"> ctx: Context object.</span>
</span><span id="1-22">
</span><span id="1-23"><span class="sd"> Returns:</span>
</span><span id="1-24"><span class="sd"> True if the user is a Byte Dev or Owner, False otherwise.</span>
</span><span id="1-25"><span class="sd"> &quot;&quot;&quot;</span>
</span><span id="1-26"> <span class="k">if</span> <span class="k">await</span> <span class="n">ctx</span><span class="o">.</span><span class="n">bot</span><span class="o">.</span><span class="n">is_owner</span><span class="p">(</span><span class="n">ctx</span><span class="o">.</span><span class="n">author</span><span class="p">)</span> <span class="ow">or</span> <span class="n">ctx</span><span class="o">.</span><span class="n">author</span><span class="o">.</span><span class="n">id</span> <span class="o">==</span> <span class="n">settings</span><span class="o">.</span><span class="n">discord</span><span class="o">.</span><span class="n">DEV_USER_ID</span><span class="p">:</span>
</span><span id="1-27"> <span class="k">return</span> <span class="kc">True</span>
</span><span id="1-13"> <span class="kn">from</span> <span class="nn">discord.ext.commands</span> <span class="kn">import</span> <span class="n">Context</span>
</span><span id="1-14"> <span class="kn">from</span> <span class="nn">discord.ext.commands._types</span> <span class="kn">import</span> <span class="n">Check</span>
</span><span id="1-15">
</span><span id="1-16"><span class="n">__all__</span> <span class="o">=</span> <span class="p">(</span><span class="s2">&quot;is_byte_dev&quot;</span><span class="p">,)</span>
</span><span id="1-17">
</span><span id="1-18">
<div class="viewcode-block" id="is_byte_dev">
<a class="viewcode-back" href="../../../../byte/api/lib/utils.html#src.byte.lib.utils.is_byte_dev">[docs]</a>
</span><span id="1-19"><span class="k">def</span> <span class="nf">is_byte_dev</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="n">Check</span><span class="p">[</span><span class="n">Any</span><span class="p">]:</span>
</span><span id="1-20"><span class="w"> </span><span class="sd">&quot;&quot;&quot;Check if the user is a Byte developer.</span>
</span><span id="1-21">
</span><span id="1-22"><span class="sd"> Returns:</span>
</span><span id="1-23"><span class="sd"> A check function.</span>
</span><span id="1-24"><span class="sd"> &quot;&quot;&quot;</span>
</span><span id="1-25">
</span><span id="1-26"> <span class="k">async</span> <span class="k">def</span> <span class="nf">predicate</span><span class="p">(</span><span class="n">ctx</span><span class="p">:</span> <span class="n">Context</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
</span><span id="1-27"><span class="w"> </span><span class="sd">&quot;&quot;&quot;Check if the user is a Byte Dev or Owner.</span>
</span><span id="1-28">
</span><span id="1-29"> <span class="k">return</span> <span class="nb">any</span><span class="p">(</span><span class="n">role</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">&quot;byte-dev&quot;</span> <span class="k">for</span> <span class="n">role</span> <span class="ow">in</span> <span class="n">ctx</span><span class="o">.</span><span class="n">author</span><span class="o">.</span><span class="n">roles</span><span class="p">)</span>
</span><span id="1-30">
</span><span id="1-31"> <span class="k">return</span> <span class="n">commands</span><span class="o">.</span><span class="n">check</span><span class="p">(</span><span class="n">predicate</span><span class="p">)</span></div>
</span><span id="1-29"><span class="sd"> Args:</span>
</span><span id="1-30"><span class="sd"> ctx: Context object.</span>
</span><span id="1-31">
</span><span id="1-32"><span class="sd"> Returns:</span>
</span><span id="1-33"><span class="sd"> True if the user is a Byte Dev or Owner, False otherwise.</span>
</span><span id="1-34"><span class="sd"> &quot;&quot;&quot;</span>
</span><span id="1-35"> <span class="k">if</span> <span class="k">await</span> <span class="n">ctx</span><span class="o">.</span><span class="n">bot</span><span class="o">.</span><span class="n">is_owner</span><span class="p">(</span><span class="n">ctx</span><span class="o">.</span><span class="n">author</span><span class="p">)</span> <span class="ow">or</span> <span class="n">ctx</span><span class="o">.</span><span class="n">author</span><span class="o">.</span><span class="n">id</span> <span class="o">==</span> <span class="n">settings</span><span class="o">.</span><span class="n">discord</span><span class="o">.</span><span class="n">DEV_USER_ID</span><span class="p">:</span>
</span><span id="1-36"> <span class="k">return</span> <span class="kc">True</span>
</span><span id="1-37">
</span><span id="1-38"> <span class="k">return</span> <span class="nb">any</span><span class="p">(</span><span class="n">role</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">&quot;byte-dev&quot;</span> <span class="k">for</span> <span class="n">role</span> <span class="ow">in</span> <span class="n">ctx</span><span class="o">.</span><span class="n">author</span><span class="o">.</span><span class="n">roles</span><span class="p">)</span>
</span><span id="1-39">
</span><span id="1-40"> <span class="k">return</span> <span class="n">commands</span><span class="o">.</span><span class="n">check</span><span class="p">(</span><span class="n">predicate</span><span class="p">)</span></div>

</span></pre></div>
</article>
Expand Down
Loading

0 comments on commit 3df8316

Please sign in to comment.