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.3 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Discord.Commands;
  2. using Discord.WebSocket;
  3. // Create a module with no prefix
  4. [Module]
  5. public class Info
  6. {
  7. // ~say hello -> hello
  8. [Command("say"), Description("Echos a message.")]
  9. public async Task Say(IMessage msg,
  10. [Unparsed, Description("The text to echo")] string echo)
  11. {
  12. await msg.Channel.SendMessageAsync(echo);
  13. }
  14. }
  15. // Create a module with the 'sample' prefix
  16. [Module("sample")]
  17. public class Sample
  18. {
  19. // ~sample square 20 ->
  20. [Command("square"), Description("Squares a number.")]
  21. public async Task Square(IMessage msg,
  22. [Description("The number to square.")] int num)
  23. {
  24. await msg.Channel.SendMessageAsync($"{num}^2 = {Math.Pow(num, 2)}");
  25. }
  26. // ~sample userinfo --> foxbot#0282
  27. // ~sample userinfo @Khionu --> Khionu#8708
  28. // ~sample userinfo Khionu#8708 --> Khionu#8708
  29. // ~sample userinfo Khionu --> Khionu#8708
  30. // ~sample userinfo 96642168176807936 --> Khionu#8708
  31. [Command("userinfo"), Description("Returns info about the current user, or the user parameter, if one passed.")]
  32. public async Task UserInfo(IMessage msg,
  33. [Description("The (optional) user to get info for")] IUser user = null)
  34. {
  35. var userInfo = user ?? await Program.Client.GetCurrentUserAsync();
  36. await msg.Channel.SendMessageAsync($"{userInfo.Username}#{userInfo.Discriminator}");
  37. }
  38. }