예제 #1
0
        public async Task AcceptOfferAsync(string offerId)
        {
            if (Context.Account.Offers.All(x => x.Id != offerId))
            {
                await Context.Channel.SendMessageAsync(Format.Warning("Could not find an offer with the specified ID."));

                return;
            }

            TradeOffer offer = Context.Account.Offers.First(x => x.Id == offerId);

            if (!offer.Author.Id.HasValue)
            {
                throw new Exception("Expected author ID to be specified in trade offer");
            }

            if (!Context.TryGetUser(offer.Author.Id.Value, out ArcadeUser account))
            {
                throw new Exception("Expected user account to exist from the specified offer");
            }

            string result = TradeHelper.AcceptOffer(Context.Account, account, offer);
            await Context.Channel.SendMessageAsync(result);
        }