Guides for Serilog and EFCore (#2134)
* Add serilog guide * added suggestions from Rozen * Add efcore guide * Fix review changes * Fix grammatical errors & review points
This commit is contained in:
20
docs/guides/other_libs/samples/InteractionModuleDISample.cs
Normal file
20
docs/guides/other_libs/samples/InteractionModuleDISample.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Discord;
|
||||
|
||||
public class SampleModule : InteractionModuleBase<SocketInteractionContext>
|
||||
{
|
||||
private readonly ApplicationDbContext _db;
|
||||
|
||||
public SampleModule(ApplicationDbContext db)
|
||||
{
|
||||
_db = db;
|
||||
}
|
||||
|
||||
[SlashCommand("sample", "sample")]
|
||||
public async Task Sample()
|
||||
{
|
||||
// Do stuff with your injected DbContext
|
||||
var user = _db.Users.FirstOrDefault(x => x.Id == Context.User.Id);
|
||||
|
||||
...
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user