【发布时间】:2021-01-24 00:46:00
【问题描述】:
<Group("math")>
Public Class cmd_math
Inherits ModuleBase
#Region "Add"
<Command("add")>
Public Async Function cmdAdd(ByVal num1 As Integer, <Remainder> ByVal num2 As Integer) As Task
Dim sum = num1 + num2
Dim user = Context.User
Dim channel = Context.Channel
Await channel.SendMessageAsync($"{user.Mention} the sum of the two specified numbers are {sum}")
End Function
#End Region
#Region "Subtract"
<Command("sub")>
Public Async Function cmdSub(ByVal num1 As Integer, <Remainder> ByVal num2 As Integer) As Task
Dim sum = num1 - num2
Dim user = Context.User
Dim channel = Context.Channel
Await channel.SendMessageAsync($"{user.Mention} the sum of the two specified numbers are {sum}")
End Function
#End Region
#Region "Multiply"
<Command("multi")>
Public Async Function cmdMulti(ByVal num1 As Integer, <Remainder> ByVal num2 As Integer) As Task
Dim sum = num1 * num2
Dim user = Context.User
Dim channel = Context.Channel
Await channel.SendMessageAsync($"{user.Mention} the sum of the two specified numbers are {sum}")
End Function
#End Region
#Region "Divide"
<Command("divide")>
Public Async Function cmdDivide(ByVal num1 As Integer, <Remainder> ByVal num2 As Integer) As Task
Dim sum = num1 / num2
Dim user = Context.User
Dim channel = Context.Channel
Await channel.SendMessageAsync($"{user.Mention} the sum of the two specified numbers are {sum}")
End Function
#End Region
End Class
我将如何创建一个命令,比如说称为“列表”,然后它会自动发送带有命令列表的嵌入,而无需编写嵌入并自动填充它?如果不能使用常规图像在嵌入中完成,则很好。我很确定它会为此使用 for 循环,但在那之后,我不知道如何处理它。
【问题讨论】:
-
CommandService拥有您想要做的所有事情所需的所有信息。只需通过依赖注入将其注入您的模块并查看它的各种属性。您可以获取这些模块中的所有模块、子模块、命令等。 -
我不知道从哪里开始..
-
在编码方面我真的是新手,我不知道如何进行注入或从哪里真正开始。
标签: discord discord.net