public async Task AddTempRoleAsync(ulong userId, ulong roleId, TimeSpan duration, string reason) { var role = new RiftTempRole { UserId = userId, RoleId = roleId, ObtainedFrom = reason, ObtainedTime = DateTime.UtcNow, ExpirationTime = DateTime.UtcNow + duration, }; if (!IonicHelper.GetGuildUserById(Settings.App.MainGuildId, userId, out var sgUser)) { return; } if (!IonicHelper.GetRole(Settings.App.MainGuildId, roleId, out var serverRole)) { return; } await sgUser.AddRoleAsync(serverRole); await DB.TempRoles.AddAsync(role); }
public async Task AddAsync(RiftTempRole role) { await DB.Users.EnsureExistsAsync(role.UserId); await using var context = new RiftContext(); await context.TempRoles.AddAsync(role); await context.SaveChangesAsync(); }
public async Task RemoveAsync(ulong userId, ulong roleId) { var rtr = new RiftTempRole { UserId = userId, RoleId = roleId, }; await using var context = new RiftContext(); context.TempRoles.Remove(rtr); await context.SaveChangesAsync(); }