<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[请教一个自定义子命令别名的问题]]></title><description><![CDATA[<p dir="auto">在<code>CompositeCommand</code>中, 主指令可以在使用<code>object</code>类型的成员变量作为别名, 而子命令的别名是使用注解的参数的形式传入的, 那怎么自定义子命令的名称呢?</p>
<pre><code>object ConfigCommand: CompositeCommand(
    SetuPlugin, primaryName = "/Setu-Config",
    secondaryNames = CommandConfig.config
) {

    @SubCommand(value = CommandConfig.configGet) //error
    suspend fun CommandSender.get() {

    }
}
</code></pre>
<p dir="auto">如上是我的代码片段, <code>CommandConfig</code>为<code>object</code>类型并继承了<code>AutoSavePluginConfig</code>. <code>CommandConfig.config</code>和<code>CommandConfig.configGet</code>均为有默认值的字符串数组</p>
]]></description><link>https://mirai.mamoe.net/topic/719/请教一个自定义子命令别名的问题</link><generator>RSS for Node</generator><lastBuildDate>Tue, 12 May 2026 21:54:05 GMT</lastBuildDate><atom:link href="https://mirai.mamoe.net/topic/719.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 23 Oct 2021 11:50:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 请教一个自定义子命令别名的问题 on Mon, 25 Oct 2021 17:07:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://mirai.mamoe.net/uid/913">@hundun000</a> 这样的，那就等后续更新了_(:з」∠)_</p>
]]></description><link>https://mirai.mamoe.net/post/5289</link><guid isPermaLink="true">https://mirai.mamoe.net/post/5289</guid><dc:creator><![CDATA[popjdh]]></dc:creator><pubDate>Mon, 25 Oct 2021 17:07:36 GMT</pubDate></item><item><title><![CDATA[Reply to 请教一个自定义子命令别名的问题 on Mon, 25 Oct 2021 05:50:25 GMT]]></title><description><![CDATA[<p dir="auto">你想要的功能对应这个issue把，还是待开发状态<br />
<a href="https://github.com/mamoe/mirai-console/issues/352" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/mamoe/mirai-console/issues/352</a></p>
<div class="row github-embeds-container">
    
    
        <div class="col-md-6">
            <div class="github-embed panel panel-default">
                <div class="panel-body">
                    <div class="meta">
                        <img class="author-picture not-responsive" src="https://avatars.githubusercontent.com/u/12100985?v=4" title="Him188" />
                        <a href="https://github.com/Him188"><span class="username">Him188</span></a> created this issue <span class="timeago" title="2021-05-09T05:04:40Z"></span> in <a href="//github.com/mamoe/mirai-console">mamoe/mirai-console</a>
                    </div>
                    <h3>
                        <span class="label label-default open pull-right">open</span>
                        <a href="https://github.com/mamoe/mirai/issues/1813">为 CompositeCommand.SubCommand 增加 secondaryNames</a>
                        <span class="number">#1813</span>
                    </h3>
                </div>
            </div>
        </div>
    
    
    
</div>]]></description><link>https://mirai.mamoe.net/post/5277</link><guid isPermaLink="true">https://mirai.mamoe.net/post/5277</guid><dc:creator><![CDATA[hundun000]]></dc:creator><pubDate>Mon, 25 Oct 2021 05:50:25 GMT</pubDate></item><item><title><![CDATA[Reply to 请教一个自定义子命令别名的问题 on Sun, 24 Oct 2021 03:32:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://mirai.mamoe.net/uid/794">@orisland</a> 如果在注解值里面用成员变量, 会提示<code>Error: An annotation argument must be a compile-time constant</code>, 我以前没怎么用过注解的值, 不知道这个只能用常量(. 不过也没其他方法给子命令设置别名了.<br />
如果用<code>SimpleCommand</code>, 然后用一个参数表示子命令倒也能达到效果. 不过我另一个帖子有提到那个命令默认给了所有人权限, 不知道怎么取消这个, 默认给所有人权限的话就没法用权限系统了.</p>
]]></description><link>https://mirai.mamoe.net/post/5259</link><guid isPermaLink="true">https://mirai.mamoe.net/post/5259</guid><dc:creator><![CDATA[popjdh]]></dc:creator><pubDate>Sun, 24 Oct 2021 03:32:24 GMT</pubDate></item><item><title><![CDATA[Reply to 请教一个自定义子命令别名的问题 on Sun, 24 Oct 2021 03:06:10 GMT]]></title><description><![CDATA[<p dir="auto">目前没有</p>
]]></description><link>https://mirai.mamoe.net/post/5258</link><guid isPermaLink="true">https://mirai.mamoe.net/post/5258</guid><dc:creator><![CDATA[Karlatemp]]></dc:creator><pubDate>Sun, 24 Oct 2021 03:06:10 GMT</pubDate></item><item><title><![CDATA[Reply to 请教一个自定义子命令别名的问题 on Sun, 24 Oct 2021 03:04:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://mirai.mamoe.net/uid/2">@karlatemp</a> 这个我已经了解了，那有没有别的方法给子命令设置别名，类似<code>secondaryNames = CommandConfig.config</code>这样的</p>
]]></description><link>https://mirai.mamoe.net/post/5257</link><guid isPermaLink="true">https://mirai.mamoe.net/post/5257</guid><dc:creator><![CDATA[popjdh]]></dc:creator><pubDate>Sun, 24 Oct 2021 03:04:49 GMT</pubDate></item><item><title><![CDATA[Reply to 请教一个自定义子命令别名的问题 on Sun, 24 Oct 2021 01:07:36 GMT]]></title><description><![CDATA[<p dir="auto">jvm注解值本来只能给常量，建议寻找java相关的书籍阅读</p>
]]></description><link>https://mirai.mamoe.net/post/5255</link><guid isPermaLink="true">https://mirai.mamoe.net/post/5255</guid><dc:creator><![CDATA[Karlatemp]]></dc:creator><pubDate>Sun, 24 Oct 2021 01:07:36 GMT</pubDate></item><item><title><![CDATA[Reply to 请教一个自定义子命令别名的问题 on Sat, 23 Oct 2021 23:52:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://mirai.mamoe.net/uid/3096">@popjdh</a> 是不是和生命周期与加载顺序有关，配置文件的读取的代码行和命令注册写反了导致命令注册的时候该配置文件仍未加载（空）<br />
<s>（你倒是给堆栈异常的信息啊）</s>。</p>
]]></description><link>https://mirai.mamoe.net/post/5253</link><guid isPermaLink="true">https://mirai.mamoe.net/post/5253</guid><dc:creator><![CDATA[Orisland]]></dc:creator><pubDate>Sat, 23 Oct 2021 23:52:39 GMT</pubDate></item><item><title><![CDATA[Reply to 请教一个自定义子命令别名的问题 on Sat, 23 Oct 2021 16:49:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://mirai.mamoe.net/uid/794">@orisland</a> 如果注解的值是字面量肯定没问题，就是想把一个成员变量放进去，这样就能在配置文件里面修改子命令的名称，不用重新编译一遍_(:з」∠)_</p>
]]></description><link>https://mirai.mamoe.net/post/5250</link><guid isPermaLink="true">https://mirai.mamoe.net/post/5250</guid><dc:creator><![CDATA[popjdh]]></dc:creator><pubDate>Sat, 23 Oct 2021 16:49:00 GMT</pubDate></item><item><title><![CDATA[Reply to 请教一个自定义子命令别名的问题 on Sat, 23 Oct 2021 16:37:47 GMT]]></title><description><![CDATA[<pre><code class="language-java"> @SubCommand("function_1_name")
 @Description("xxxxx")
    public void simg(CommandSenderOnMessage sender) throws IOException{}
</code></pre>
<p dir="auto"><code>java</code>这么写是正确的啊，原来<code>kotlin</code>不能用的吗？在<code>SubCommand</code>里传入的名称将代替原方法名，作为命令注册。</p>
]]></description><link>https://mirai.mamoe.net/post/5249</link><guid isPermaLink="true">https://mirai.mamoe.net/post/5249</guid><dc:creator><![CDATA[Orisland]]></dc:creator><pubDate>Sat, 23 Oct 2021 16:37:47 GMT</pubDate></item></channel></rss>