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.4 kB

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