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 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using Discord;
  2. using Discord.Commands;
  3. using Discord.WebSocket;
  4. // Create a module with no prefix
  5. public class Info : ModuleBase
  6. {
  7. // ~say hello -> hello
  8. [Command("say"), Summary("Echos a message.")]
  9. public async Task Say([Remainder, Summary("The text to echo")] string echo)
  10. {
  11. // ReplyAsync is a method on ModuleBase
  12. await ReplyAsync(echo);
  13. }
  14. }
  15. // Create a module with the 'sample' prefix
  16. [Group("sample")]
  17. public class Sample : ModuleBase
  18. {
  19. // ~sample square 20 -> 400
  20. [Command("square"), Summary("Squares a number.")]
  21. public async Task Square([Summary("The number to square.")] int num)
  22. {
  23. // We can also access the channel from the Command Context.
  24. await Context.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. // ~sample whois 96642168176807936 --> Khionu#8708
  32. [Command("userinfo"), Summary("Returns info about the current user, or the user parameter, if one passed.")]
  33. [Alias("user", "whois")]
  34. public async Task UserInfo([Summary("The (optional) user to get info for")] IUser user = null)
  35. {
  36. var userInfo = user ?? Context.Client.CurrentUser;
  37. await ReplyAsync($"{userInfo.Username}#{userInfo.Discriminator}");
  38. }
  39. }