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.

InteractionModuleDISample.cs 441 B

1234567891011121314151617181920
  1. using Discord;
  2. public class SampleModule : InteractionModuleBase<SocketInteractionContext>
  3. {
  4. private readonly ApplicationDbContext _db;
  5. public SampleModule(ApplicationDbContext db)
  6. {
  7. _db = db;
  8. }
  9. [SlashCommand("sample", "sample")]
  10. public async Task Sample()
  11. {
  12. // Do stuff with your injected DbContext
  13. var user = _db.Users.FirstOrDefault(x => x.Id == Context.User.Id);
  14. ...
  15. }
  16. }