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

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