You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

module.cs 1.5 kB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Create a module with no prefix
  2. public class Info : ModuleBase<SocketCommandContext>
  3. {
  4. // ~say hello -> hello
  5. [Command("say"), Summary("Echos a message.")]
  6. public async Task SayAsync([Remainder, Summary("The text to echo")] string echo)
  7. {
  8. // ReplyAsync is a method on ModuleBase
  9. await ReplyAsync(echo);
  10. }
  11. }
  12. // Create a module with the 'sample' prefix
  13. [Group("sample")]
  14. public class Sample : ModuleBase<SocketCommandContext>
  15. {
  16. // ~sample square 20 -> 400
  17. [Command("square"), Summary("Squares a number.")]
  18. public async Task SquareAsync([Summary("The number to square.")] int num)
  19. {
  20. // We can also access the channel from the Command Context.
  21. await Context.Channel.SendMessageAsync($"{num}^2 = {Math.Pow(num, 2)}");
  22. }
  23. // ~sample userinfo --> foxbot#0282
  24. // ~sample userinfo @Khionu --> Khionu#8708
  25. // ~sample userinfo Khionu#8708 --> Khionu#8708
  26. // ~sample userinfo Khionu --> Khionu#8708
  27. // ~sample userinfo 96642168176807936 --> Khionu#8708
  28. // ~sample whois 96642168176807936 --> Khionu#8708
  29. [Command("userinfo"), Summary("Returns info about the current user, or the user parameter, if one passed.")]
  30. [Alias("user", "whois")]
  31. public async Task UserInfoAsync([Summary("The (optional) user to get info for")] SocketUser user = null)
  32. {
  33. var userInfo = user ?? Context.Client.CurrentUser;
  34. await ReplyAsync($"{userInfo.Username}#{userInfo.Discriminator}");
  35. }
  36. }