public async Task LinkSystem(Context ctx) { ctx.CheckSystem(); var account = await ctx.MatchUser() ?? throw new PKSyntaxError("You must pass an account to link with (either ID or @mention)."); var accountIds = await ctx.Repository.GetSystemAccounts(ctx.System.Id); if (accountIds.Contains(account.Id)) { throw Errors.AccountAlreadyLinked; } var existingAccount = await ctx.Repository.GetSystemByAccount(account.Id); if (existingAccount != null) { throw Errors.AccountInOtherSystem(existingAccount); } var msg = $"{account.Mention()}, please confirm the link."; if (!await ctx.PromptYesNo(msg, "Confirm", account, false)) { throw Errors.MemberLinkCancelled; } await ctx.Repository.AddAccount(ctx.System.Id, account.Id); await ctx.Reply($"{Emojis.Success} Account linked to system."); }
public async Task LinkSystem(Context ctx) { ctx.CheckSystem(); var account = await ctx.MatchUser() ?? throw new PKSyntaxError("You must pass an account to link with (either ID or @mention)."); var accountIds = await _systems.GetLinkedAccountIds(ctx.System); if (accountIds.Contains(account.Id)) { throw Errors.AccountAlreadyLinked; } var existingAccount = await _systems.GetByAccount(account.Id); if (existingAccount != null) { throw Errors.AccountInOtherSystem(existingAccount); } var msg = await ctx.Reply($"{account.Mention}, please confirm the link by clicking the {Emojis.Success} reaction on this message."); if (!await ctx.PromptYesNo(msg, user: account)) { throw Errors.MemberLinkCancelled; } await _systems.Link(ctx.System, account.Id); await ctx.Reply($"{Emojis.Success} Account linked to system."); }
public async Task LinkSystem(IUser account) { var accountIds = await Systems.GetLinkedAccountIds(Context.SenderSystem); if (accountIds.Contains(account.Id)) { throw Errors.AccountAlreadyLinked; } var existingAccount = await Systems.GetByAccount(account.Id); if (existingAccount != null) { throw Errors.AccountInOtherSystem(existingAccount); } var msg = await Context.Channel.SendMessageAsync( $"{account.Mention}, please confirm the link by clicking the {Emojis.Success} reaction on this message."); if (!await Context.PromptYesNo(msg, user: account)) { throw Errors.MemberLinkCancelled; } await Systems.Link(Context.SenderSystem, account.Id); await Context.Channel.SendMessageAsync($"{Emojis.Success} Account linked to system."); }